Documentation
¶
Overview ¶
Package memory provides indexing-time memory budget helpers: auto-tuned concurrency, a soft heap limit on constrained hosts, explicit release between pipeline phases, and peak-heap sampling for tests. Users do not need to set any environment variables — tuning runs once at process start. CODEGRAPH_* env vars exist only as optional overrides for debugging.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyTuning ¶
func ApplyTuning()
ApplyTuning detects the host (WSL, installed RAM) and configures indexing limits. Called automatically at init; safe to call again in tests after changing the env.
func BatchSize ¶
func BatchSize() int
BatchSize is how many files to extract and flush to SQLite per batch.
func Gate ¶
func Gate()
Gate encourages the runtime to return freed pages to the OS between heavy pipeline phases. Indexing spikes (VTA, SCIP) allocate large arenas; without an explicit gate the Go heap stays at the peak for the rest of the process life.
func HostRAMBytes ¶
func HostRAMBytes() uint64
HostRAMBytes reports total installed RAM (Linux /proc/meminfo). Zero when unknown.
func MaxWorkers ¶
func MaxWorkers() int
MaxWorkers caps parallel file extraction during the definitions pass.
func NodeHeapMB ¶
func NodeHeapMB() int
NodeHeapMB returns the --max-old-space-size passed to scip-typescript (MB). Auto-derived from the same host profile as the Go heap budget (WSL, low-RAM).
func PeakHeap ¶
func PeakHeap(fn func()) uint64
PeakHeap runs fn and returns the maximum runtime.MemStats.HeapInuse observed while fn executes (sampled every 5ms). Used by memory simulation tests.
func SkipSimilar ¶
func SkipSimilar() bool
SkipSimilar reports whether the SIMILAR_TO pass should be skipped. Auto-skipped only on hosts with <4 GiB RAM; otherwise always on unless CODEGRAPH_SKIP_SIMILAR is set explicitly.
Types ¶
type Profile ¶
type Profile struct {
MaxWorkers int
BatchSize int
NodeHeapMB int // --max-old-space-size for scip-typescript
SkipSimilar bool
Host string // "wsl", "low-ram", or "default" — for tests/diagnostics
}
Profile is the auto-detected indexing budget for this host.
func ActiveProfile ¶
func ActiveProfile() Profile
ActiveProfile returns the indexing budget in effect (auto-tune + optional env overrides).