memprofile

command
v0.0.0-...-85af193 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 22 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

memprofile is a memory profiling harness for the orast parser and printer.

It measures how much heap a single SQL file costs, and writes heap profiles (pprof format) so the allocation sites can be inspected with:

go tool pprof -top -sample_index=inuse_space <bin> <profile>
go tool pprof -top -sample_index=alloc_space <bin> <profile>

Safety model — a pathological file must never exhaust system memory:

  1. Every file is profiled in an ISOLATED CHILD PROCESS, so a runaway allocation or an infinite loop cannot take down the whole batch.
  2. Each child runs under a wall-clock TIMEOUT; on expiry it dumps a heap profile plus a goroutine stack dump, then exits.
  3. Each child runs under a HARD HEAP CEILING enforced by a watchdog that polls runtime.MemStats. When the heap crosses the ceiling the child dumps a heap profile and exits before the OS runs out of memory.
  4. The supervisor holds an outer deadline (timeout + -grace) and kills a child that fails to honour its own timeout.

Usage:

# profile every .sql under a directory, validate mode (no AST built)
go run ./test/cmd/memprofile -dir D:\WORK\DOHERP\dbscript\version00000001 \
    -mode validate -memlimit 1024 -timeout 30s

# full AST parse of the 50 largest files, profiling anything over 256 MiB
go run ./test/cmd/memprofile -dir <dir> -mode parse -largest 50 \
    -profile-above 256 -profile memprof_out

# one file, verbose (runs the child path directly, no supervisor)
go run ./test/cmd/memprofile -single big.sql -mode parse -v

Source Files

  • main.go
  • rss_other.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL