Repository navigation
Conversation
Red: the timestamp cache (time.Time + sync.Once + bool) makes StoreObs 192 bytes. The parse-equivalence and concurrency tests pass today. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KaR4xu8gVykQBkH8yG8m6H
StoreObs cached its parsed timestamp in a time.Time, a sync.Once and a bool: 40 bytes that made it 192 bytes, the 192-byte size class. A week of a busy network holds 400k observations. The cache is now one atomic.Int64: 0 before the first call, the time in UTC nanoseconds after it, or a sentinel for unparseable strings and for times it cannot hold exactly (a non-UTC offset, or out of UnixNano's range), which are parsed again on each call so their location is kept. Concurrent first calls may both parse; they store the same value. StoreObs is 160 bytes, one size class down: 32 bytes x 400k = 12.8MB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KaR4xu8gVykQBkH8yG8m6H
A13xB0
force-pushed
the
perf/obs-timestamp-8-bytes
branch
from
October 13, 2026 03:26
5c54765 to
682c40a
Compare
Owner
Author
|
Rebased onto upstream master and submitted as Kpa-clawbot#2196. |
Owner
Author
|
Merged upstream as Kpa-clawbot#2196; closing. |
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.
Refs Kpa-clawbot#2148.
Problem
StoreObsis the store's most numerous struct: 400k of them on a week of a busy regional network. Its lazy timestamp cache (Kpa-clawbot#1481) is atime.Time, async.Onceand abool, together 40 bytes. On current master that makes the struct 200 bytes, which puts every observation in the 208-byte size class.Change
The cache is now a single
atomic.Int64:0before the first call;UnixNano's range). Those are re-parsed on each call so their location is preserved.Concurrent first calls may both parse; they store the same value.
StoreObsis now 160 bytes, in the 160-byte size class: 48 bytes × 400k observations ≈ 19 MB less heap. The first parse costs the same; cached reads now build thetime.Timefrom an int.Tests
TestStoreObsFitsIn160Bytes: red commit first.TestStoreObsParsedTimeMatchesParse: Z, nanosecond, offset, SQL, empty, garbage and epoch inputs give the same time and location astime.Parse, on the first and the cached call.TestStoreObsParsedTimeConcurrentFill.storeobs_parsedtime_test.gostill passes.go test ./cmd/serverpasses, and-racepasses on the ParsedTime, retransmission and observer analytics tests.This PR or Kpa-clawbot#2149
Kpa-clawbot#2149 fixes Kpa-clawbot#2148 by reordering these same three fields. The two conflict, so here is how they compare. Sizes are
unsafe.Sizeof(StoreObs{})on each branch, with Go's heap size class beside them:Z), so that path is rare. It is tested againsttime.Parseon edge cases, concurrently, and under-race.Options:
No config or UI changes.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KaR4xu8gVykQBkH8yG8m6H