-
Notifications
You must be signed in to change notification settings - Fork 4
fix(FIR-50188): memory leak in streaming #148
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
Merged
Merged
Conversation
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
dd90aee to
6922e13
Compare
edbe6c7 to
91b3e62
Compare
fb48d23 to
131b8c8
Compare
131b8c8 to
a499607
Compare
|
bogdantruta-firebolt
approved these changes
Nov 18, 2025
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.



This pull request significantly improves the streaming query result processing pipeline for large datasets, focusing on efficient memory usage, proper backpressure handling, and robust performance. It also introduces comprehensive integration and performance tests to benchmark and validate the new streaming behavior against traditional result fetching.
Streaming and Backpressure Improvements:
Refactored the
ServerSideStreamclass insrc/statement/stream/serverSideStream.tsto implement a pending rows buffer, limit memory usage with amaxPendingRowsthreshold, and properly pause/resume the streaming interface to handle backpressure. The stream now pushes data downstream as consumers are ready, preventing memory buildup and ensuring efficient processing. Also, improved error handling and resource cleanup during stream destruction.Optimized the
normalizeResponseRowStreamingfunction insrc/statement/normalizeResponse.tsfor performance by replacingArray.mapwith a manual for-loop and pre-allocated result array, reducing overhead for large datasets.Testing and Validation:
test/integration/v2/performance.test.tsto compare performance and correctness between normal (fetchResult) and streaming (streamResult) executions across various dataset sizes, including pipeline processing scenarios. The tests ensure that streaming is not more than 10% slower than normal execution and that both methods yield identical results.Before (testing 1000000 rows with different data types):

After (memory now is stable over a long time with no large spikes):
