refactor(logger): scope rolling buffer display behind provider - #506
refactor(logger): scope rolling buffer display behind provider #506GuillaumeLagrange wants to merge 1 commit into
Conversation
…uard The rolling buffer was activated from the executor layer through paired activate/deactivate calls and three cross-referenced globals, ignoring which logger the run environment provider had installed. Make the display a provider decision instead: - RunEnvironmentProvider::start_command_display(label) returns an optional RollingBufferGuard; the default keeps CI job output verbatim and only LocalProvider activates the rolling buffer, falling back to plain output when stderr is not an interactive terminal - the guard owns the tick thread and finalizes the frame on drop, so error paths can no longer leak an active frame - log_tee routes display writes through local_logger::write_command_output; the raw output still always reaches the runner.log file via the executor trace records - RollingBuffer internals (struct, statics, render/finish) are now private to the rolling_buffer module The final frame title now reflects the run result: finish_with(success) renders a red cross instead of a checkmark when the benchmark command fails. Co-Authored-By: Claude <noreply@anthropic.com>
Greptile SummaryThe PR scopes the rolling command-output display through
Confidence Score: 4/5The PR should not merge until finalization can no longer strand concurrently emitted log records after the last deferred-log flush. The new split active-state tracking leaves a race during final-frame rendering in which concurrent records are deferred after the only remaining drain and never printed. Files Needing Attention: src/local_logger/rolling_buffer/mod.rs, src/local_logger/mod.rs
|
| Filename | Overview |
|---|---|
| src/local_logger/rolling_buffer/mod.rs | Introduces the provider-scoped display guard and final result rendering, but finalization permits records to be deferred after the last flush. |
| src/local_logger/mod.rs | Centralizes command-output routing and replaces mutex-derived display state with an atomic flag that participates in the finalization race. |
| src/executor/mod.rs | Scopes the provider display guard around executor execution and reports the returned result to it. |
| src/run_environment/provider.rs | Adds an object-safe default display hook that keeps CI providers on verbatim output. |
| src/run_environment/local/provider.rs | Enables rolling command display specifically for local terminal runs. |
| src/executor/helpers/run_command_with_log_pipe.rs | Delegates command-output routing to the local logger without otherwise changing pipe processing. |
| src/executor/orchestrator.rs | Renames the optional rolling-buffer label to the provider-neutral display label. |
Sequence Diagram
sequenceDiagram
participant O as Orchestrator
participant P as RunEnvironmentProvider
participant G as RollingBufferGuard
participant E as Executor
participant L as LocalLogger
O->>P: start_command_display(label)
alt Local TTY
P-->>O: RollingBufferGuard
O->>E: run()
E->>L: command output and log records
L->>G: buffer output / defer logs
O->>G: finish_with(result)
G->>L: flush deferred logs and draw final frame
else CI or non-TTY
P-->>O: None
O->>E: run()
E->>L: verbatim output
end
Prompt To Fix All With AI
### Issue 1
src/local_logger/rolling_buffer/mod.rs:372-378
**Finalization strands deferred logs**
If another executor, FIFO, or profiler thread logs while `finalize` draws the finished frame, `LocalLogger` queues the record because the active flag remains set after the final deferred-log flush. No subsequent frame drains that record, causing diagnostic output from the completed run to disappear.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "refactor(logger): scope rolling buffer d..." | Re-trigger Greptile
| if let Ok(mut guard) = ACTIVE_BUFFER.lock() { | ||
| if let Some(rb) = guard.as_mut() { | ||
| rb.finish(success); | ||
| } | ||
| *guard = None; | ||
| } | ||
| *guard = None; | ||
| super::set_rolling_buffer_active(false); |
There was a problem hiding this comment.
Finalization strands deferred logs
If another executor, FIFO, or profiler thread logs while finalize draws the finished frame, LocalLogger queues the record because the active flag remains set after the final deferred-log flush. No subsequent frame drains that record, causing diagnostic output from the completed run to disappear.
Knowledge Base Used: App core: entrypoint, config, API client, and shared infra
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/local_logger/rolling_buffer/mod.rs
Line: 372-378
Comment:
**Finalization strands deferred logs**
If another executor, FIFO, or profiler thread logs while `finalize` draws the finished frame, `LocalLogger` queues the record because the active flag remains set after the final deferred-log flush. No subsequent frame drains that record, causing diagnostic output from the completed run to disappear.
**Knowledge Base Used:** [App core: entrypoint, config, API client, and shared infra](https://app.greptile.com/codspeed/-/custom-context/knowledge-base/codspeedhq/codspeed/-/docs/app-core.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Merging this PR will not alter performance
|
|
@GuillaumeLagrange now that the CircleCI stuff is released, you can rebase |
Gets rid of the ugly unconditionnal bypass that relies on *IS_TTY
@fargito FYI, I will only merge this once you're done with the circle ci changes, I'll handle the conflicts, it's a cleaner solution to what we discussed this morning