Repository navigation
Print the newest log entries by default and re-read less while following - #11
Merged
Merged
Conversation
A one-shot logs query read its whole range oldest first, a page of 100 at a time, so --since 3d on a busy group was tens of thousands of sequential requests before the newest line printed. --limit (default 1000, 0 for all) now reads the range newest first through the API's sort_order desc, stops one entry past the limit, and prints what it kept oldest first, with a note: line on stderr in every mode (and a hint in table mode) when it left older entries out. --limit 0 keeps the old oldest-first stream. --follow re-read two minutes behind the newest entry it had seen on every 5s poll, about 25 times the new data, so a busy group kept it reading back to back and minutes behind, and a fast node clock pulled its windows forward. Its windows are now measured from this machine's clock: each poll reads from 10s before the previous poll up to the moment it starts, polls start every 10s start to start (--poll-interval, 5s at least), and once a minute a settle scan reads, once, the minute that has just aged past --lookback, so an entry up to --lookback late still prints. When a poll runs longer than the interval the settle scan is skipped with one warning, so the polls keep up. The -f backlog takes the newest --limit entries the same way, and --limit no longer conflicts with --follow. Against a group logging 45 lines/s, polls ran every 16-25s (55-129s before), the backlog took 11 requests instead of about 400, and a full read of the same range found no entry missed or printed twice; at a low rate, polls ran every 10s and settle scans read consecutive minutes. docs/notes.md records the throughput a single reader gets (about 100 entries per request, a second or more each). The live suite checks --limit against the same range read whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
When someone asks for a busy container group's logs over a long time range, the CLI reads them oldest first, 100 lines per request, so a few days of a chatty group meant tens of thousands of requests before the newest line appeared.
--followhad the opposite problem: to catch lines that reach the log store late, every poll re-read the last two minutes, about 25 times more than was new, so on a busy group it read nonstop and fell minutes behind. Queries now print the newest 1000 lines by default, read newest first in about ten requests, and say so when older lines were left out.--follownow re-reads only the 10 seconds before each poll, plus each minute once more after it is two minutes old, and drops that second pass with a warning when it can't keep up.What changed
logs/container-groups logsone-shot--limit(default 1000,0for all) keeps the newest entries in the range. It reads newest first (sort_order: desc), stops one entry past the limit, and prints oldest first.logsq.FetchNewestmirrorsFetchWindow's millisecond-boundary dedup downward.note:line goes to stderr in every output mode (scripts need to know), plus ahint:in table mode.--limit 0is the old oldest-first stream.--sincestill defaults to 15m and--page-sizestill caps at 100, the public spec's limit.--follow--poll-interval, minimum now 5s). Each poll reads[previous poll − 10s, now).--lookback(default 2m), so an entry up to--lookbacklate still prints.-fbacklog takes the newest--limitentries the same way (11 requests instead of about 400 on the test group).Docs:
commands.md, the guide's Logs section, andnotes.md(follow behavior, plus the single-reader throughput: about 100 entries per request at a second or more each). The validation table updates the--poll-intervalminimum. No CHANGELOG entry, since nothing has been released yet.Testing
just cipasses. New unit tests:sort_orderandpage_sizejust test-livewithSALAD_CLI_TEST_REQUIRE_SSH=1passed on the first version of this branch; the follow rework only touches--follow. A new live check compares--limit 3with--limit 0over the same fixed range.Not covered
page_sizecap from 100 would lift that about tenfold.Checklist
just cipasses (formatting, lint, and the offline tests)docs/reflects the change (CHANGELOG deliberately not updated before the first release)🤖 Generated with Claude Code