-
Notifications
You must be signed in to change notification settings - Fork 536
fix(performance): improve CPU and memory efficiency through several optimizations #3826
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
base: main
Are you sure you want to change the base?
fix(performance): improve CPU and memory efficiency through several optimizations #3826
Conversation
…operations Signed-off-by: Florian Valeye <[email protected]>
Signed-off-by: Florian Valeye <[email protected]>
Signed-off-by: Florian Valeye <[email protected]>
Signed-off-by: Florian Valeye <[email protected]>
Signed-off-by: Florian Valeye <[email protected]>
Signed-off-by: Florian Valeye <[email protected]>
Signed-off-by: Florian Valeye <[email protected]>
Signed-off-by: Florian Valeye <[email protected]>
Signed-off-by: Florian Valeye <[email protected]>
…mize Signed-off-by: Florian Valeye <[email protected]>
Signed-off-by: Florian Valeye <[email protected]>
…dant take() operations Signed-off-by: Florian Valeye <[email protected]>
…le zero-copy buffer sharing Signed-off-by: Florian Valeye <[email protected]>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3826 +/- ##
==========================================
- Coverage 74.40% 74.38% -0.02%
==========================================
Files 147 147
Lines 39544 39565 +21
Branches 39544 39565 +21
==========================================
+ Hits 29421 29431 +10
- Misses 8737 8744 +7
- Partials 1386 1390 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Florian Valeye <[email protected]>
|
I think it would be more practical if we have each section in a separate pr and then some benchmarks of before and after, then it's easier to see the added benefit |
Signed-off-by: Florian Valeye <[email protected]>
f7a67fc to
5440789
Compare
Sure! I’d like to use this PR as an opportunity to discuss. |
|
I do remember that @rtyler recommended a crate/allocator that helps with tracking memory consumption. |
# Description Slight change in the find_files by only cloning the string for the path (from this [PR](#3826)) # Benchmark - Before optimization: Time: 668.73 µs Clones all fields: path, partition_values HashMap, stats strings, etc. - After optimization: Time: 366.62 µs Only clones the path String once Moves the Add struct instead of deep cloning Signed-off-by: Florian Valeye <[email protected]>
|
If you have a moment to resolve the conflicts @fvaleye I am comfortable merging this change as is |
I’m splitting the work into separate PRs to better isolate the performance improvements. |
…wn (#3895) # Description Following [this](#3826), this work implements a first round of preallocating collections when their size is known, to avoid unnecessary reallocations. This applies to `Vec`, `HashMap` (with_capacity), and other dynamically sized collections. Preallocating memory improves efficiency and reduces overhead when the final size is known. Signed-off-by: Florian Valeye <[email protected]>
Description
I spent some time identifying areas where we could reduce memory usage, such as avoiding unnecessary cloning or using pre-allocated memory. I also analyzed CPU-intensive operations to look for potential improvements.
This work is mainly intended to spark discussion on whether small code changes could lead to performance benefits.
1. JSON parsing:
StreamDeserializer2. ShareableBuffer with BytesMut
to_vec()operations)3. Partition processing
slice()instead oftake()per partition4. HashMap pre-allocation
HashMap::with_capacity(estimated_capacity)when known5. String clone reduction
6. Memory take optimization
std::mem::take()to move files instead of cloning