Uh oh!
There was an error while loading. Please reload this page.
stream: bump default highWaterMark - #46608
Conversation
nodejs-github-bot
commented
Feb 10, 2023
Review requested:
|
ronag
commented
Feb 10, 2023
TBH I would like to bump it even further to 128k but I don't think I will get consensus on that one. |
mcollina
commented
Feb 10, 2023
Failed to start CI- Validating Jenkins credentials ✖ Jenkins credentials invalidhttps://github.com/nodejs/node/actions/runs/4145265543 |
mscdex
left a comment
There was a problem hiding this comment.
-1 I don't think we should do this. Node runs on all kinds of setups, including more resource-constrained hardware. The current defaults work well memory usage-wise in either kind of setup.
I think a better solution would be to allow end users to set something like Stream.defaultObjectWaterMark/Stream.defaultWaterMark which would default to the current 16/16KB respectively.
This way users could just set this at the top of their main script and get the same effect if they want to take on that kind of potential extra memory consumption.
lpinca
commented
Feb 10, 2023
My memory tells me that this was already proposed in the past but I can't find the PRs/issues. I kind of agree with @mscdex. Instead of changing the default for everyone, make it customizable. |
The problem with that is that most users will not bother/dare/known how to set it. So we are slowing it down for everyone to be compatible with a few... not saying that's wrong, but is there any middle ground? Can we e.g. check the total available system memory and base it on that? Messing around with hwm and Buffer.poolSize is kind of advanced user usage. |
mscdex
commented
Feb 10, 2023
The properties I proposed would be in the documentation, which I think developers would already be looking at (especially if they are at the point where the stream high water mark is actually becoming a bottleneck), so I don't see this as an issue.
It could be argued both ways. I don't think it's fair to say that everyone is running node in environments where memory usage is not a concern.
I believe what I proposed is a middle ground. Besides, we already employ similar user-tweakable limits throughout node core, so this would just be making things more consistent in that regard.
I don't think there is any realistic way of doing something like this as that'd be making the assumption that the node process is the only thing running on the OS that is using any considerable amount of resources. |
benjamingr
left a comment
There was a problem hiding this comment.
I agree there is a tradeoff here and nuance but I think we're currently too conservative and so agree with this change. Constrained systems can usually override this.
LiviaMedeiros
commented
Feb 10, 2023
@ronag unrelated to contents of this PR but why the removal of
needs-ci |
BridgeAR
commented
Feb 10, 2023
Increasing the highWaterMark is going to finish the process faster and thus, could actually lead to less memory pressure for high load scenarios.
Our defaults are always concern for debate and we will likely never have the correct default for everyone. What we should IMO strive for is a default that is best for most users, so that only a few have to change the them. Many users are not aware of these things and only check for them, in case they know, they have to be cautious (what I would expect for users running in an environment where memory is a concern). Using a heuristic where we check for the available memory sounds like a good idea to me. That way we will likely have the right setting for more users than we have currently. One difficult part might be to define the thresholds and what memory to look at (overall memory vs. free memory). For now, I would just use |
vweevers
commented
Feb 11, 2023
Heuristics can't tell how many parallel streams will be created and what the intended purpose of the available memory is. I like that streams slow down and leave room. I also prefer baby steps here. The effect of increasing a hardcoded default is relatively easy to measure and doesn't mess with user expectations that much, compared to heuristics. Increasing the hwm every so often (and gradually) can improve performance for a majority of users, while still giving others a chance to test it out (even unknowingly). |
ronag
commented
Feb 11, 2023
We don't land anything without CI. Don't worry. I just missed adding the request-ci label. |
This increases the HWM by eight times while leaving the default for object mode unchanged. It will increase memory usage by eight times on a proxy that pipes data to a slower destination. That is almost an order of magnitude. FWIW we are using 64 KiB for file system streams. |
nodejs-github-bot
commented
Apr 6, 2023
richardlau
commented
Apr 6, 2023
test-http-no-read-no-dump is failing in the GitHub actions workflows -- it may be linked to #47450, but I don't think I've seen it fail elsewhere. |
debadree25
commented
May 6, 2023
This would require a rebase I think? removed the author ready for the time being |
marco-ippolito
commented
Jun 8, 2023
for reference: #27121 |
aduh95
commented
Sep 29, 2023
This needs a rebase. |
This should give a performance boost accross the board. Given that the old limit is a decod old and memory capacity has doubled many times since I think it is appropriate to slightly bump the default limit.
a480e09 to
b01b94eComparenodejs-github-bot
commented
Sep 29, 2023
Quite a few CI failures that would need to be addressed. |
RafaelGSS
commented
Oct 8, 2023
@ronag do you need help with that? Would be great to have this on v21 proposal. |
ronag
commented
Oct 8, 2023
Feel free to take over. |
RafaelGSS
commented
Oct 10, 2023
@ronag Apparently, I don't have push permissions to this PR (nor nxtedition fork). I'll create another PR cherry-picking this commit. |
FYI: In kubernetes with flannel, 256k and 512k only increase throughput on red hat linux 8 with defaults. any other values make no difference a value higher than 600k starts to drop throughput, see also test scenario streaming more than 200MB, the 16k is unable to get the TCP state machine working: https://github.com/orgs/nodejs/discussions/51082 |
This should give a performance boost accross the board. Given that the old limit is a decod old and memory capacity has doubled many times since I think it is appropriate to slightly bump the default limit. PR-URL: nodejs#52037 Refs: nodejs#46608 Refs: nodejs#50120
This should give a performance boost accross the board. Given that the old limit is a decod old and memory capacity has doubled many times since I think it is appropriate to slightly bump the default limit. PR-URL: nodejs#52037 Refs: nodejs#46608 Refs: nodejs#50120
This should give a performance boost accross the board at the cost of slightly higher memory usage.
Given that the old limit is a decode old and memory capacity has doubled many times since I think it is appropriate to slightly bump the default limit.