Skip to content

refactor(logger): scope rolling buffer display behind provider - #506

Open
GuillaumeLagrange wants to merge 1 commit into
mainfrom
associate-rolling-buffer-with-logger
Open

refactor(logger): scope rolling buffer display behind provider #506
GuillaumeLagrange wants to merge 1 commit into
mainfrom
associate-rolling-buffer-with-logger

Conversation

@GuillaumeLagrange

Copy link
Copy Markdown
Contributor

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

…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-apps

greptile-apps Bot commented Aug 18, 2026

Copy link
Copy Markdown

Greptile Summary

The PR scopes the rolling command-output display through RunEnvironmentProvider, enabling it only for local runs and adding success/failure result marks.

  • Replaces direct rolling-buffer activation in the executor with a provider-owned display guard.
  • Moves command-output routing behind the local logger and introduces atomic display-state tracking.
  • Leaves CI providers on verbatim output while LocalProvider activates the rolling display.
  • Adds a red failure cross when command execution returns an error.

Confidence Score: 4/5

The 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

Important Files Changed

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
Loading

Fix all with Greploop Fix All in Claude Code Fix All in Codex

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

Comment on lines +372 to +378
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

Fix in Claude Code Fix in Codex

@codspeed-hq

codspeed-hq Bot commented Aug 18, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 17 untouched benchmarks


Comparing associate-rolling-buffer-with-logger (390f016) with main (745dc9a)

Open in CodSpeed

@fargito fargito left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks cleaner indeed

fargito commented Aug 18, 2026

Copy link
Copy Markdown
Member

@GuillaumeLagrange now that the CircleCI stuff is released, you can rebase

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.

2 participants