[GH-ISSUE #4490] [Engine] conversation-cache stats: unlocked log scraping, park/restore ms never recorded, nothing in Prometheus #2013

Closed
opened 2026-11-04 01:55:58 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @coryjett on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4490

Area

Engine

Desktop app, Terminal or source?

Terminal (Linux release 0.2.7, Control 0.1.52); the same code is on main at 46c152a1.

What happened

Conversation-cache statistics are scraped from the engine log without a lock, lose events, and never reach Prometheus.

serve/server.py ConvCacheLog (~764-818): park and restore counts come from re-reading the engine log, and only when /metrics or /v1/telemetry is called (poll() ~781, called from metrics() ~4776). The server is a ThreadingHTTPServer (~7913) and poll() takes no lock, so two concurrent scrapes (Grafana plus the Monitor tab) can read the same span of the log and count the same parks twice (unconfirmed static analysis: the race is read from the code, not observed). READ_MAX is 1 MiB (~771): when the log grows more than that between scrapes, events are skipped. The EVENT regex captures tokens, parked count and bytes but not the milliseconds the engine prints ("parked 68955 tokens in 4027.6 ms"), so park and restore time is never recorded; "skipped" events are matched but not counted (~811). serve/prometheus.py exports none of conversation_cache (0 occurrences), although docs/DETAILS.md (~30) says the strata: metrics are named after their JSON keys.

For an agent workload (three agents on one slot, 56 parks / 102 s in 3 hours) the park and restore time is the number that matters, and it is only in the log.

Suggested: count events in the server as they are logged (or lock poll()), add park_ms_total, restore_ms_total, skipped and superseded, and export them as strata:conversation_cache_*. Happy to send a PR.

Smallest steps or command that reproduce it

Scrape /metrics from two clients at once while agents park and restore; compare conversation_cache.parks against grep -c "conversation cache: parked" <engine log>.

Reproduction status

Reproduced by reading the code; the missing milliseconds and the missing Prometheus export are visible in any /metrics output.

Strata version

0.2.7 (engine 0.1.52, Control 0.1.52); code checked on main 46c152a1.

Graphics card, memory and system

2x RTX 3090 24 GB (PCIe 3.0 x16, one per socket), 2x Xeon E5-2620 v3, 256 GB, Ubuntu 26.10.

Model, size and settings

Flash-Next IQ3_S, layer split 25 with --trim-stage-weights, conversation cache 40 GiB / 16 slots; the full profile is in #4468.

Logs

Engine log lines as quoted above.

Originally created by @coryjett on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4490 ### Area Engine ### Desktop app, Terminal or source? Terminal (Linux release 0.2.7, Control 0.1.52); the same code is on `main` at 46c152a1. ### What happened Conversation-cache statistics are scraped from the engine log without a lock, lose events, and never reach Prometheus. `serve/server.py` `ConvCacheLog` (~764-818): park and restore counts come from re-reading the engine log, and only when `/metrics` or `/v1/telemetry` is called (`poll()` ~781, called from `metrics()` ~4776). The server is a `ThreadingHTTPServer` (~7913) and `poll()` takes no lock, so two concurrent scrapes (Grafana plus the Monitor tab) can read the same span of the log and count the same parks twice (unconfirmed static analysis: the race is read from the code, not observed). `READ_MAX` is 1 MiB (~771): when the log grows more than that between scrapes, events are skipped. The `EVENT` regex captures tokens, parked count and bytes but not the milliseconds the engine prints ("parked 68955 tokens in 4027.6 ms"), so park and restore time is never recorded; "skipped" events are matched but not counted (~811). `serve/prometheus.py` exports none of `conversation_cache` (0 occurrences), although docs/DETAILS.md (~30) says the `strata:` metrics are named after their JSON keys. For an agent workload (three agents on one slot, 56 parks / 102 s in 3 hours) the park and restore time is the number that matters, and it is only in the log. Suggested: count events in the server as they are logged (or lock `poll()`), add `park_ms_total`, `restore_ms_total`, `skipped` and `superseded`, and export them as `strata:conversation_cache_*`. Happy to send a PR. ### Smallest steps or command that reproduce it Scrape `/metrics` from two clients at once while agents park and restore; compare `conversation_cache.parks` against `grep -c "conversation cache: parked" <engine log>`. ### Reproduction status Reproduced by reading the code; the missing milliseconds and the missing Prometheus export are visible in any `/metrics` output. ### Strata version 0.2.7 (engine 0.1.52, Control 0.1.52); code checked on `main` 46c152a1. ### Graphics card, memory and system 2x RTX 3090 24 GB (PCIe 3.0 x16, one per socket), 2x Xeon E5-2620 v3, 256 GB, Ubuntu 26.10. ### Model, size and settings Flash-Next IQ3_S, layer split 25 with --trim-stage-weights, conversation cache 40 GiB / 16 slots; the full profile is in #4468. ### Logs Engine log lines as quoted above.
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Thanks for taking the time to report this.

Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.11. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6660529381 --> @Niko1221 commented on GitHub (Nov 5, 2026): Thanks for taking the time to report this. Strata has changed a lot since this was opened, and 0.2.11 is out now, so many older reports no longer apply. We're closing issues older than a week that have had no new reports in the last week. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.11. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2013
No description provided.