|Summary:||Reduce memory allocations for better throughput|
|Component:||Main||Assignee:||JMeter issues mailing list <issues>|
Description benoit.wiart 2016-07-18 21:01:08 UTC
I've been profiling jmeter memory allocation under different conditions the PR linked to this bug gives substantial improvements. Gain really depends on the test but in the worst case (compressed content, no embedded resources) it's about 15% less allocations (in bytes) When not compressed (no embedded resources) and if content-length is sent by the server my test gives 30% reduction in bytes allocated As always YMMV but this PR is always a win in all my different tests. Reduction in memory allocated comes from Better usage of ByteArrayOutputStream by - directly accessing the buffer instead of copying it - or by using the commons-lang implementation which avoid copying memory around when extending the buffer - or by creating the string directly from the buffer instead of a temporary copy Avoid unneeded string concatenation due to missing log.isDebugEnabled() if possible use httpclient CharArrayBuffer to avoid memory allocations Do not create unneeded silent exceptions Do not allocate 2 empty iterators on each call to executeSamplePackage - LinkedList.iterator() is a stinky monkey. Also see HTTPCORE-361 Set better default size to StringBuilder buffers improve JOrphanUtils#replaceAllChars : provides a fast path which does not allocate memory etc.. Remark : When using ssl, jsse is a major source of unneeded allocation !!!! (sun.security.ssl.SSLContextImpl#getDefaultCipherSuiteList(boolean)) https://bugs.openjdk.java.net/browse/JDK-8133070 should improve the situation (I did not test it) the title of the bug is misleading as it's also about an internal cache beeing cleared on each method call.
Comment 2 Philippe Mouawad 2016-07-31 14:42:07 UTC
Added: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/DirectAccessByteArrayOutputStream.java (with props) Modified: jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractTestElement.java jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java jmeter/trunk/xdocs/changes.xml