-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
Improve allocation speed and reduce memory copying to increase HTTP pars... #199
Improve allocation speed and reduce memory copying to increase HTTP pars... #199
Conversation
Before we go into specifics, am I right to understand that you ran the benchmarks and saw an improvement? Can you post the numbers? I would expect a difference only with benchmarks that split the request headers over multiple TCP chunks and I'm not sure if we actually have those; if not, you are more than welcome to add some. :-) I should mention that the http benchmarks tend to have fairly high variance. I usually benchmark using median-of-three or median-of-five, with a few seconds cool-off between each run. If the difference is only 1 or 2%, it's statistically insignificant and probably just noise (because of the aforementioned variance) unless it's consistent across many (10, 20 or more) runs. |
Yes I saw the highish variance. And I am guessing the new allocator is a
I am not sure but I think the speedup is there in most cases even without node benchmark/http/end-vs-write-end.js | grep buf yields originally these measurements: and after the patch yields http/end-vs-write-end.js type=buf kb=64 c=100 method=write: 9830 I guess that is pretty typical. It is roughly equivalent in many cases, I should mention that the TCP fragmentation case was the main reason for Thanks for the feedback. On Tue, Dec 23, 2014 at 4:38 AM, Ben Noordhuis notifications@github.com
Happy to Code with Integrity : Software Engineering Code of Ethics and |
I'm running on battery power right now - not an ideal environment for benchmarking - so I can't really confirm if it's faster. I did some quick tests yesterday but the results were inconclusive. I had a look at the existing benchmarks and I don't think any of them really stress the 'split headers' case. I would suggest adding one that:
By the way, if you just want to run the buf tests, you can do so like this:
|
Thank you for these great tips. I have already started reading the On Wed, Dec 24, 2014 at 3:08 AM, Ben Noordhuis notifications@github.com
Happy to Code with Integrity : Software Engineering Code of Ethics and |
I pushed the new node javascript client and server in the benchmarks Rudi On Wed, Dec 24, 2014 at 8:58 AM, Rudi Cilibrasi cilibrar@gmail.com wrote:
Happy to Code with Integrity : Software Engineering Code of Ethics and |
I think the idea of having a tiny memory pool used in one area is a bad idea, especially with the implementation in the same file. It would probably improve performance some, but I think if memory pools were to be used in io.js it should be done all around with a larger subsystem for handling it. Perhaps something like boost::pool, which is tried and tested. Otherwise, trusting the OS not to handle memory too slowly is reasonable, or just optimizing current code to reduce copying and reallocations. |
I wanted to let you know that the leak exists in v0.12 without the new code In general I agree with you about memory allocation code that is over On Fri, Dec 26, 2014 at 10:27 AM, Aaron Trent notifications@github.com
Happy to Code with Integrity : Software Engineering Code of Ethics and |
@rudi-cilibrasi Can you make the benchmarks part of the benchmark suite? Take a look at the files in (for example) benchmark/net for guidance; the goal is to make them fully automatic. I'll leave some comments on the PR itself. |
if (has_keep_alive) { | ||
WriteWithCRLF(channel, "Connection: keep-alive"); | ||
} | ||
WriteWithCRLF(channel, "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"); |
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.
Please wrap at 80 columns and please use single quotes. (The latter is not a hard requirement but it's the norm in core and code that deviates always looks a little grating.)
This allocator attempts to increase performance by a few percent in benchmark/http/end-vs-write-end.js and other cases. This experimental effort was initiated by a TODO indicator from Ben.
ping @bnoordhuis |
i'm happy to let this one go if you like since the performance boost was uncertain last i checked and it is a bit more complex. if somebody likes it or gets good test results i am happy to see it in also. my feeling is that my other PR is more quality and hopefully more likely to go in now but I'm still waiting for more feedback. #228 |
Since this doesn't look like it's going anywhere, going to close in light of #1457, let me know if it should be re-opened. |
- Delete the node_api_*internal.h headers - Don't crash when casting numbers when V8_ENABLE_CHECKS is defined - Return 0 when getting NaN value as an integer - Always set callback data internal field to prevent crashing when V8_ENABLE_CHECKS is defined - Style: replace `if (ptr)` with `if (ptr != nullptr)` - Fix extern "C" in node_api_async.h - Minor doc changes
- Delete the node_api_*internal.h headers - Don't crash when casting numbers when V8_ENABLE_CHECKS is defined - Return 0 when getting NaN value as an integer - Always set callback data internal field to prevent crashing when V8_ENABLE_CHECKS is defined - Style: replace `if (ptr)` with `if (ptr != nullptr)` - Fix extern "C" in node_api_async.h - Minor doc changes
...er performance by 1-2 (and occasionally more) percent in many cases such as benchmark/http/end-vs-write-end.js based on slab allocator todo by Ben.