apache / apache/jmeter

Parent Controller Path Caching Optimization

Open
#6,720 5 comments 0 reactions 0 assignees View on GitHub
enhancement to-triage
Dominant language
Java
Stars
9.5k
Forks
2.3k
Avg merge
1d 22h
Merged PRs (30d)
5

Description

### Use case

### Description
In JMeter, when a sampler fails with `onErrorStartNextLoop` enabled, or when loop logical actions (such as Break/Continue) are triggered, JMeter is forced to find the parent controller hierarchy from the current sampler up to the thread group root.

Currently, this is done by executing `testTree.traverse()` with a `FindTestElementsUpToRootTraverser` every time the loop action is triggered. For large test plans with deep nesting structures, this full DFS tree walk is highly redundant since the test tree's hierarchical structure does not change during the execution run. This leads to severe performance degradation and high CPU usage under high-failure loads.

### Possible solution

### Proposed Improvement
Add a thread-local parent controller path cache (`Map>`) inside `JMeterThread`. When resolving parent controllers:
1. Query the map to see if the sampler's parent controllers list has already been resolved.
2. If it is a cache miss, perform the `testTree.traverse()` once and store the result.
3. If it is a cache hit, return a lightweight mock traverser containing the cached controllers list directly, completely skipping the expensive DFS tree traversal.

### Possible workarounds

_No response_

### JMeter Version

6.0.0-SNAPSHOT

### Java Version

_No response_

### OS Version

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating JMeterThread and the existing testTree.traverse() call using FindTestElementsUpToRootTraverser for sampler loop actions. Compare the cache-miss and cache-hit paths, preserving the resolved parent-controller order; done means repeated lookups avoid the full traversal without changing onErrorStartNextLoop, Break, or Continue behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
performance, tooling
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.