-
-
Notifications
You must be signed in to change notification settings - Fork 425
fix: use Buffer.alloc() with snappy-wasm #8671
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
Conversation
Summary of ChangesHello @twoeths, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical performance issue related to excessive garbage collection by modifying how memory buffers are allocated within the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request addresses a performance issue related to garbage collection by replacing Buffer.allocUnsafe() with Buffer.alloc() when handling snappy compression and decompression. The changes are correct and effectively resolve the reported problem. My review includes suggestions to improve the new code comments for better clarity and long-term maintainability, and also points out an additional security benefit of the change in one of the cases.
|
this fixes the issue specified on PR-8647
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## cayman/snappy #8671 +/- ##
==============================================
Coverage 52.03% 52.03%
==============================================
Files 848 848
Lines 65809 65809
Branches 4809 4809
==============================================
Hits 34241 34241
Misses 31499 31499
Partials 69 69 🚀 New features to boost your workflow:
|
**Motivation** - improve memory by transferirng gossipsub message data from network thread to the main thread - In snappy decompression in #8647 we had to do `Buffer.alloc()` instead of `Buffer.allocUnsafe()`. We don't have to feel bad about that because `Buffer.allocUnsafe()` does not work with this PR, and we don't waste any memory. **Description** - use `transferList` param when posting messages from network thread to the main thread part of #8629 **Testing** I've tested this on `feat2` for 3 days, the previous branch was #8671 so it's basically the current stable, does not see significant improvement but some good data for different nodes - no change on 1k or `novc` - on hoodi `sas` node we have better memory there on main thread with same mesh peers, same memory on network thread <img width="851" height="511" alt="Screenshot 2025-12-12 at 11 05 27" src="https://github.com/user-attachments/assets/8d7b2c2f-8213-4f89-87e0-437d016bc24a" /> - on mainnnet `sas` node, we have better memory on network thread, a little bit worse on the main thread <img width="854" height="504" alt="Screenshot 2025-12-12 at 11 08 42" src="https://github.com/user-attachments/assets/7e638149-2dbe-4c7e-849c-ef78f6ff4d6f" /> - but for this mainnet node, the most interesting metric is `forward msg avg peers`, we're faster than majority of them <img width="1378" height="379" alt="Screenshot 2025-12-12 at 11 11 00" src="https://github.com/user-attachments/assets/3ba5eeaa-5a11-4cad-adfa-1e0f68a81f16" /> --------- Co-authored-by: Tuyen Nguyen <[email protected]>




Motivation
MarkSweepCompactgc on feat: use snappy-wasm (#6483) #8647Buffer.allocUnsafe()as found in feat: use different snappy implementations for different topics #8670 (comment)Description
@chainsafe/snappy-wasmfor all topics but withBuffer.alloc()feat2