Documentation
¶
Overview ¶
Package sessionscale writes synthetic long-lived Pi session files and the agent directory that resumes them, so the memory and per-prompt cost of a resumed session can be measured on Pi and PiG with the same bytes.
The default shape is the one reported for a five-day session (owner, 2026-10-10): 299 MB, 46,100 entries, of which 25,171 tool results (130 MB) and 20,138 assistant messages (166 MB), 700 user messages, 63 compactions, 17 leaves and a longest line of 1.06 MB. Only those shape statistics are used; the content is pseudo-random prose, code and base64 from a fixed seed, so a shape and seed always produce the same bytes.
Tokens are estimated as Pi's compaction.ts estimateTokens does: a quarter of the characters of message text, thinking, tool-call names and JSON arguments, and tool-result text, rounded up. Signatures and tool-result details are on disk but not in the estimate.
Index ¶
Constants ¶
const ( OwnerBytes = 299 << 20 OwnerEntries = 46100 OwnerToolResults = 25171 OwnerToolResultBytes = 130 << 20 OwnerAssistants = 20138 OwnerAssistantBytes = 166 << 20 OwnerUsers = 700 OwnerCompactions = 63 OwnerLeaves = 17 OwnerMaxLine = 1_060_000 )
Owner shape statistics (2026-10-10 report). Only counts and sizes; no content.
const ( P1Bytes = 314_175_691 P1Users = 706 P1Assistants = 20_305 P1ToolResults = 25_339 P1Systems = 2 P1Compactions = 63 // P1CompactionBytes is the size of the profiled compaction records. P1CompactionBytes = 13 << 20 P1ModelChanges = 19 P1CustomMessages = 3 P1ThinkingLevels = 2 P1BranchPoints = 15 // P1TreeRows is the default-filter /tree row count; the assistant messages that are not rows carry no text. P1TreeRows = 28_442 // P1MissEvery is one prompt-cache miss per this many assistant responses. P1MissEvery = 40 )
Real-session profile statistics (handoffs/P1-real-session.md, 2026-10-11): the owner's session as profiled for open and /tree. Only counts; no content.
const ( Provider = "sessionscale" Model = "scripted" // ModelB is the second model a ProfileP1 session switches to; its cache-read price differs from Model's. ModelB = "scripted-b" )
Provider and Model name the scripted model the agent directory declares and the assistant messages carry.
const ProfileP1 = "p1"
ProfileP1 selects the real-session profile.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Meta ¶
type Meta struct {
Shape Shape `json:"shape"`
Bytes int64 `json:"bytes"`
Entries int `json:"entries"`
ByType map[string]int `json:"byType"`
BytesByType map[string]int64 `json:"bytesByType"`
MaxLine int `json:"maxLine"`
Compactions int `json:"compactions"`
Leaves int `json:"leaves"`
PathEntries int `json:"pathEntries"`
ContextEntries int `json:"contextEntries"`
ContextTokens int `json:"contextTokens"`
ContextBytes int64 `json:"contextBytes"`
Window int `json:"window"`
SHA256 string `json:"sha256"`
Session string `json:"session,omitempty"`
AgentDir string `json:"agentDir,omitempty"`
LeafID string `json:"leafId"`
LastCompactionID string `json:"lastCompactionId"`
}
Meta describes a written fixture.
type Shape ¶
type Shape struct {
// Bytes is the file size to reach. Generation stops at the first turn boundary at or above it, then writes the active tail.
Bytes int64
// Compactions and Leaves are the counts for the whole file. Zero scales the owner's counts by Bytes.
Compactions int
Leaves int
// ContextTokens is the estimated size of the active context the file resumes to: the last compaction's summary, its kept messages and everything after it. Zero means 150,000.
ContextTokens int
// KeepRecentTokens is how much each compaction keeps (Pi's compaction.keepRecentTokens default, 20,000, when zero).
KeepRecentTokens int
// Window is the scripted model's context window. Zero means the smallest of 272,000 and ContextTokens*100/85 rounded up to a multiple of 1,000 that is at least ContextTokens + 32,768.
Window int
// Seed selects the content.
Seed uint64
// Cwd is the header's working directory.
Cwd string
// Profile "" is the 2026-10-10 report's shape. ProfileP1 is the real-session profile: its entry mix, model changes, priced
// prompt caching with misses, system and custom messages, and assistant messages without text that the /tree default filter hides.
Profile string
}
Shape selects a fixture.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
pigprobe
command
Command pigprobe is cmd/pig with two additions for measurement: SIGUSR1 writes a heap profile (after a collection) to $SESSIONSCALE_HEAP_DIR/heap-<n>.pprof, then an empty heap-<n>.pprof.done marker; SIGUSR2 starts a CPU profile to $SESSIONSCALE_HEAP_DIR/cpu-<n>.pprof and the next SIGUSR2 stops it (then cpu-<n>.pprof.done).
|
Command pigprobe is cmd/pig with two additions for measurement: SIGUSR1 writes a heap profile (after a collection) to $SESSIONSCALE_HEAP_DIR/heap-<n>.pprof, then an empty heap-<n>.pprof.done marker; SIGUSR2 starts a CPU profile to $SESSIONSCALE_HEAP_DIR/cpu-<n>.pprof and the next SIGUSR2 stops it (then cpu-<n>.pprof.done). |
|
sessionscale
command
Command sessionscale writes and measures long-lived session fixtures (see package sessionscale).
|
Command sessionscale writes and measures long-lived session fixtures (see package sessionscale). |