perf(logger/sink): drop per-log String clone (#189)#241
Closed
SAY-5 wants to merge 2 commits intoTrueNine:devfrom
Closed
perf(logger/sink): drop per-log String clone (#189)#241SAY-5 wants to merge 2 commits intoTrueNine:devfrom
SAY-5 wants to merge 2 commits intoTrueNine:devfrom
Conversation
Fix two CI failures from previous merge
Closes TrueNine#189. `send_output` cloned the formatted string for the channel send and kept the original around only for the rare sink-thread-dead fallback. On the hot path (sink alive), every `write_event` / `write_span_*` paid a `String::clone` for nothing. Move the `String` straight into the channel. `mpsc::SendError` already hands the unsent value back on the disconnect path, so we can pull it out via `if let Err(SendError(OutputCommand::Write { output, .. }))` and borrow it directly into `write_direct`. No allocation on the happy path; the cold path is unchanged. `cargo build --manifest-path sdk/Cargo.toml` clean. The 16 logger unit tests pass, including `test_thread_safety`. `cargo clippy --lib` shows no new warnings against `sink.rs` (the existing warnings on other modules are unchanged).
Owner
|
Merged into dev via cherry-pick. The PR base was changed from main to dev, which caused conflicts because dev had diverged significantly. All commits have been cherry-picked onto dev and pushed. Thanks for the contributions! |
Owner
|
Thank you for the contribution! All commits have been cherry-picked and merged into the dev branch. 🙏 |
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.
Closes #189.
send_outputcloned the formatted string for the channel send and kept the original around only for the rare sink-thread-dead fallback. On the hot path (sink alive), everywrite_event/write_span_*paid aString::clonefor nothing.Move the
Stringstraight into the channel.mpsc::SendErroralready hands the unsent value back on the disconnect path, so we can pull it out viaif let Err(SendError(OutputCommand::Write { output, .. }))and borrow it directly intowrite_direct. No allocation on the happy path; the cold path is unchanged.Test plan
cargo build --manifest-path sdk/Cargo.toml— cleancargo test --manifest-path sdk/Cargo.toml --lib infra::logger— 16/16 pass (includingtest_thread_safety)cargo clippy --manifest-path sdk/Cargo.toml --lib— no new warnings onsink.rs(pre-existing warnings on other modules unchanged)