Repository navigation
various: reduce allocations where available - #22
Merged
Merged
Conversation
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6a2158a305d5f249b52c8b21dc5aaca86a6a6964
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I517d855b14c015569a325deb64948f3b6a6a6964
- Adds proper documentation comments with `# Errors` sections for all functions returning `Result` - `cast_precision_loss` on `u64` -> `f64` for disk sizes is acceptable since disk sizes won't exceed f64's precision limit in practice. Thus, we can suppress those. - `cast_sign_loss` and `cast_possible_truncation` on the percentage calculation is safe since percentages are always 0-100. Once again, it's safe to suppress. Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Id4dd7ebc9674407d2be4f38ff4de24bc6a6a6964
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I367444097eafbd1020c02707c42351bf6a6a6964
Owner
Author
|
Merge on green... |
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.
Small PR that focuses on performance improvements and code simplification for string formatting throughout the codebase. The main changes involve replacing
format!macros and similar formatting methods with manual string construction using pre-allocated buffers and thewrite!macro, which reduces heap allocations and improves runtime efficiency.Reduces heap allocations by a whopping 61% across all system information gathering functions and, consequently, achieves a near 45x speednup for the main I/O bottleneck through optimized buffer management. This is achieved mostly replacing
format!macros with pre-allocated string building to minimize memory overhead.The allocations, according to Hotpath, have gone done from 54 total allocations to 21! That's 33 fewer allocations or a 61% reducation as I've claimed above. The main change is to
release::get_os_pretty_namewhich went from 16 to 2 allocations, which is a 87.5% reduction.Good changes overall, hope nothing changes. I was going to add some in-line assembly but we're in a good spot for now.
Signed-off-by: NotAShelf raf@notashelf.dev
Change-Id: I6a2158a305d5f249b52c8b21dc5aaca86a6a6964