Skip to content

Conversation

@NotAShelf
Copy link
Owner

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 the write! 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 replacingformat! 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_name which 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 [email protected]
Change-Id: I6a2158a305d5f249b52c8b21dc5aaca86a6a6964

Signed-off-by: NotAShelf <[email protected]>
Change-Id: I6a2158a305d5f249b52c8b21dc5aaca86a6a6964
Signed-off-by: NotAShelf <[email protected]>
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 <[email protected]>
Change-Id: Id4dd7ebc9674407d2be4f38ff4de24bc6a6a6964
Signed-off-by: NotAShelf <[email protected]>
Change-Id: I367444097eafbd1020c02707c42351bf6a6a6964
@NotAShelf
Copy link
Owner Author

Merge on green...

@NotAShelf NotAShelf merged commit 11a7264 into main Nov 17, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant