New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug 66269: Add NoThreadClone to HeaderManager to reduce heap utilization #727
base: master
Are you sure you want to change the base?
Conversation
The change would impact the ones who attempt to add/remove headers dynamically via JSR223 or something similar. For instance, https://sqa.stackexchange.com/questions/41708/jmeter-header-manager-alters-the-headers-during-test attempts sampler.getHeaderManager().add(new Header("Authorization","Bearer " + vars.get("BEARER"))); |
8b78e35
to
cb51d19
Compare
I've added I'm inclined to merge this as I do not expect it to cause major disruption. At the same time, JMeter's recorder produces header manager for every HTTP sampler, so RAM savings are significant. |
Well, it triggers test failures:
|
cb51d19
to
1a7ba3f
Compare
Don't you think, this is done more often, than we think about it? I think we have recommended such a workaround for other problems with the samplers setting/not setting headers in the past. Can we implement a switch to enable sharing of the header manager and expose it with a property (set default to share instances)? |
if (isRunningVersion()) { | ||
throw new IllegalStateException( | ||
"Cannot modify HeaderManager " + getName() + " while test is running. " + | ||
"If you need dynamic headers, prefer using ${...} expressions in your headers." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vlsi probably better to use JMeter functions than "${...} expressions", because in JMeter's manuel the terms is JMeter functions and variables https://jmeter.apache.org/usermanual/functions.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the manual says "Functions and Variables". Do you suggest If you need dynamic headers, prefer using ${...} functions or variables in your headers
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I think it makes sense to add a common name for "JMeter expression language"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure that the functions in JMeter can be call "expression language", but why not. if you would change to "JMeter expression language", then the manual need to be update (remplace the terms "functions" to "JMeter expression language"), and in JMeter self (menu Tools > Function Helper Dialog)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function Helper Dialog generates functions. I'm not sure it can generate variables.
expression language
Well, the language is something that declares parsing and semantic rules.
For instance, neither function nor variable can specify if nested ${...} are allowed. Neither function nor variable can specify the way to escape $ if the user needs literal $ value without replacements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, in the context of this failure message "function or variable" sounds good enough
Hello @vlsi , how would people requiring this feature do then ? Thanks |
I think it's fine through a PreProcessor if you confirm dynamic Headers would still work |
…decide if they need cloning or not Previously, components could implements NoThreadClone to prevent cloning in each thread, however, there was no way to "unimplement" the interface. By default, isShareable returns true, so existing components work as before.
…nts by sharing the managers across threads
@@ -602,6 +602,23 @@ JMETER-SERVER</source> | |||
</property> | |||
</properties> | |||
</section> | |||
|
|||
<section name="§-num;.14 HTTP Header Manager configuration" anchor="http_header_manager"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that §-num;.14
duplicates the number of the previous section, however, I believe we'll remove section numbers in #5915
It turns out the case is harder than I thought. Apparently, that fails in case HTTP Header Managers are shared across threads. The next issue is that the "temporary" header managers are not reset after HTTP sampler execution, and they are re-created only before the next execution. In other words, even if we eliminate HTTP Header Manager cloning "before thread starts", then it would generate copies during test execution anyway. The worst thing is that Frankly speaking, I'm quite disappointed by all that. |
Based on the analysis above, I'm moving this PR to the next milestone, so it no longer holds the release. I wish we could deprecate and drop |
I would push a PR that deprecates the problematic methods. There's a chance the users would notice it and stop using it or ask for a raplacement |
Motivation and Context
HeaderManager consumes heap, and it looks it can be reused between threads.
Fixes #5708