-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[IMPROVED] Reduce allocations in writeMsgRecord
#6576
Conversation
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.
LGTM
Looks like |
Signed-off-by: Neil Twigg <neil@nats.io>
18995b0
to
18a2f3b
Compare
writeMsgRecord
writeMsgRecord
I've backed out one of the changes as I think it may change baseline memory usage and I want to spend more time on that one before committing to it. |
ok let's keep watching and testing. The pools work but can cause memory growth quite quickly in this situation vs what was there before. |
Indeed, the other remaining changes in this PR will still reduce allocations and GC pressure in the meantime. |
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.
LGTM
writeMsgRecord
writeMsgRecord
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.
LGTM
The following changes are all to reduce GC pressure:
hdr
array looked like it should be stack-allocated but was actually always escaping to the heap because of the highwayhash writer, so instead of allocating a ton of those, just preallocate space on the underlying cache buffer instead (since that has already escaped to the heap);stringToBytes
for the subject, avoiding a further copy.Signed-off-by: Neil Twigg neil@nats.io