rajat315315 opened a new pull request, #6721:
URL: https://github.com/apache/jmeter/pull/6721

   Fixes: #6720 
   
   ## Description
   This PR introduces a thread-local parent controller path cache 
(`parentControllersCache`) inside `JMeterThread`. 
   
   Specifically, the changes are:
   1. Added a `HashMap` mapping `Sampler` to `List<Controller>` in 
`JMeterThread`.
   2. Created a lightweight nested class `CachedPathToRootTraverser` extending 
`FindTestElementsUpToRootTraverser` to bypass tree walks on cache hits.
   3. Updated `triggerLoopLogicalActionOnParentControllers` to lookup resolved 
paths in the cache and save the path on a cache miss.
   
   ## Motivation and Context
   When a sampler execution fails with the `onErrorStartNextLoop` option 
enabled, or when loop logical actions (such as Break/Continue) are triggered, 
JMeter traverses the entire test tree using DFS (`testTree.traverse()`) from 
the sampler to the root to resolve parent controllers. 
   
   For large test plans with deep nesting, this full tree walk is redundant 
since the test tree's hierarchy is static during thread execution. Under 
error-heavy loads, these continuous traversals degrade performance and spike 
CPU usage. Caching the path to the root per-sampler inside each thread avoids 
this overhead entirely.
   
   ## How Has This Been Tested?
   1. **Performance Microbenchmark**:
      Created a microbenchmark simulating a deeply nested test plan structure 
(10 nested levels of loop controllers) over **100,000** iterations:
      * **Without cache (full tree walk)**: `292.57 ms`
      * **With cache (lazy map lookup)**: `30.68 ms`
      * **Performance Speedup**: **~9.53x** (over 950% performance improvement).
   2. **Compilation**:
      Compiled core module Java classes using `./gradlew :src:core:compileJava`.
   3. **Unit Tests**:
      Executed the core test suite using `./gradlew :src:core:test` (379 tests 
completed, 0 failed, 1 skipped).
   
   ## Screenshots (if appropriate):
   N/A (performance optimization)
   
   ## Types of changes
   - Bug fix (non-breaking change which fixes an issue)
   
   ## Checklist:
   - [x] My code follows the [code style][style-guide] of this project.
   - [ ] I have updated the documentation accordingly.
   
   [style-guide]: https://wiki.apache.org/jmeter/CodeStyleGuidelines
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to