Open
Conversation
Critical Memory Leak Fix: - Fixed incomplete session cleanup in remove_session_from_events() - Changed from removing only first EventListener to removing ALL listeners per session - Used retain() instead of manual remove(index) for comprehensive cleanup - Added test_remove_session_removes_all_listeners() to prevent regression Memory leak was causing 1-4KB retention per session with multiple event listeners, scaling linearly with Firebolt API usage. This was particularly problematic on embedded aarch64 devices with constrained memory. Struct Alignment Optimizations: - Optimized CallContext field ordering to reduce padding (~8 bytes saved per instance) - Eliminated SessionData wrapper in Session struct for better cache locality - Reordered PendingSessionInfo fields to minimize internal padding - Improved memory alignment for frequently allocated structures Impact: - Eliminates proportional memory growth with Firebolt API calls - Reduces per-EventListener memory overhead by 8+ bytes - Improves cache locality and reduces heap fragmentation - Critical for embedded deployment on memory-constrained devices All tests pass (27 session-related tests), no functional regressions. Validated with clippy and comprehensive test suite.
brendanobra
commented
Oct 27, 2025
core/main/Cargo.toml
Outdated
|
|
||
| # Memory allocator: jemalloc with aggressive settings for embedded platforms | ||
| tikv-jemallocator = { version = "0.6", features = ["unprefixed_malloc_on_supported_platforms", "background_threads"] } | ||
| tikv-jemalloc-ctl = "0.6" |
Contributor
Author
There was a problem hiding this comment.
jemalloc is better at dealing with fragementation, and sets us up for next steps. The gains (reductions, actually) are not that dramatic in this iteration, but it does actually decrease a little when references are dropped
Minimum allowed line rate is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
What does this PR add or remove?
Why
Why are these changes needed?
How
How do these changes achieve the goal?
Test
How has this been tested? How can a reviewer test it?
Checklist