Skip to content

CLI: write the run log file synchronously - #135

Merged
rquidute merged 1 commit into
project-chip:v2.16-cli-developfrom
rquidute:fix/cli-log-file-sink-sync
Oct 26, 2026
Merged

rquidute merged 1 commit into
project-chip:v2.16-cli-developfrom
rquidute:fix/cli-log-file-sink-sync

Conversation

@rquidute

Copy link
Copy Markdown
Contributor

What

configure_logger_for_run() now adds the run log file sink with enqueue=False (was True), plus a unit test that checks the flag. Nothing else changes: same format, same level, same file.

Why

With enqueue=True every log line is pickled onto a queue and handed to a worker thread. On a 712k-line run this limits how fast the CLI drains the log records, and the CLI finished about 30 s after the backend.

Evidence

Raspberry Pi 5 / 8 GB, backend 41f91e7 (v2.16-develop), TC-ACE-2.1 with real-time logs ON, one run per row:

CLI time real
before 458.9 s
this PR 420.5 s

About 38 s (8%) less, in line with the lag it removes. Batch mode on the same test took 449.9 s with this PR. Short runs (TC-ACE-1.3, ~53k lines) show no difference (44.7 s against 45.5 s, within the ~7 s noise), as expected.

Risk

A slow disk would block the log write instead of filling a queue; the file is local to the machine running the CLI. The large-run gain is from a single run per row.

Tests

Added test_log_file_sink_is_not_enqueued. Not run locally; CI runs the suite.

Closes #1185
Part of #1119

… enqueue queue

enqueue=True pickles every line onto a multiprocessing queue and hands it
to a worker thread. On a 200k-line microbenchmark that is ~46 us/line vs
~14 us/line for a direct write, and per-line cost is what bounds how fast
the CLI drains a large run's log records.
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e060ea85-0d64-4e56-ba9e-2b7c781a3a51
Commits

Reviewing files that changed from the base of the PR and between f972da2 and d892548.

Files selected for processing: 2
  • tests/test_run/test_logging.py
  • th_cli/test_run/logging.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The run-log file sink in configure_logger_for_run now uses enqueue=False, so it writes log records synchronously. The streaming sink remains asynchronous. A test checks that the logger receives the returned file path and enqueue=False.

Possibly related issues

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to d8925

No actionable merge risk remains; the intentional local-disk blocking trade-off is documented.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: writing the CLI run log file synchronously.
Description check Passed The description directly explains the logging change, its rationale, measured performance impact, risk, testing, and linked issues.
Linked Issues check Passed Direct issue [#1185] requires synchronous writes for the CLI run log and unchanged log content and level. configure_logger_for_run() adds the file sink with enqueue=False while retaining the confi…
Out of Scope Changes check Passed The reported changes are limited to the run-log sink configuration, explanatory comments, and a unit test for the linked performance objective. The asynchronous streaming sink is not changed in behavi…
Full details: Linked Issues check

Explanation

Direct issue [#1185] requires synchronous writes for the CLI run log and unchanged log content and level. configure_logger_for_run() adds the file sink with enqueue=False while retaining the configured format and existing file path. The streaming sink remains asynchronous. test_log_file_sink_is_not_enqueued verifies the required flag.

Full details: Out of Scope Changes check

Explanation

The reported changes are limited to the run-log sink configuration, explanatory comments, and a unit test for the linked performance objective. The asynchronous streaming sink is not changed in behavior. No unrelated change is demonstrated.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mergify

mergify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@rquidute rquidute self-assigned this Oct 26, 2026
@rquidute
rquidute requested a review from antonio-amjr October 26, 2026 17:39

@greens greens left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is essentially mirroring in the CLI what you did in project-chip/certification-tool-backend#403, right?

Definitely a top priority for me for the next release to iron out our logging story.

@rquidute

Copy link
Copy Markdown
Contributor Author

This is essentially mirroring in the CLI what you did in project-chip/certification-tool-backend#403, right?

Definitely a top priority for me for the next release to iron out our logging story.

Yes @greens

@rquidute
rquidute merged commit f6fbc34 into project-chip:v2.16-cli-develop Oct 26, 2026
6 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.

2 participants