Skip to content
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

stable_log performance improvements #3522

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

wkennedy
Copy link

@wkennedy wkennedy commented Nov 7, 2024

Problem

Improve the performance of stable_log.

Summary of Changes

In stable_log, format! is replaced by manual string concatenation using .join on arrays of string slices (e.g., &["Program ", &program_id.to_string(), ...].join("")). This approach reduces temporary string allocations and slightly improves performance.

The program_data function now preallocates a string with an estimated capacity (String::with_capacity(estimated_capacity)). This helps avoid multiple reallocations as data is appended. Use BASE64_STANDARD.encode_string to encode data directly into the preallocated string buffer instead of creating intermediate strings for each piece of encoded data, enhancing memory efficiency.

Added tests to validate logging behavior under different conditions (e.g., testing logging functions without a collector, handling empty messages, checking success and failure paths, and concurrent collector handling).

program_data_criterion

Updated logging functions for better readability and efficiency by using `join("")` instead of `concat()`. Added extensive tests for multiple logging scenarios and edge cases. Improved benchmarks to compare new and old logging methods across different data sizes and conditions.
Deleted the obsolete `stable_log_old.rs` file previously used for benchmarking improvements. Updated the benchmark references and removed old benchmarks involving the deleted file to streamline the codebase.
@mergify mergify bot requested a review from a team November 7, 2024 16:38
@wkennedy wkennedy marked this pull request as ready for review November 8, 2024 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant