Skip to content

perf: cache validated struct constructors - #145

Open
ShadowSpatula wants to merge 1 commit into
estevaofon:mainfrom
ShadowSpatula:perf/issue-100-struct-constructor-cache
Open

perf: cache validated struct constructors#145
ShadowSpatula wants to merge 1 commit into
estevaofon:mainfrom
ShadowSpatula:perf/issue-100-struct-constructor-cache

Conversation

@ShadowSpatula

Copy link
Copy Markdown

Summary

  • cache validated struct-constructor metadata on the immutable struct definition
  • reuse precomputed parameter modes and type names on repeated construction
  • preserve cold- and warm-cache error behavior with regression coverage
  • record an 11-run interleaved benchmark against develop

This adapts the constructor-cache approach from PR #70 to the current runtime, alongside the newer field-index cache.

Results

bench_struct_records.nx improved from a 107.9 ms median to 51.7 ms (-52.1%) across 11 interleaved runs. Baseline and candidate checksums matched.

Verification

  • go build ./...
  • go vet ./...
  • go test ./internal/... -count=1
  • go run ./cmd/noxy --sync --locked
  • go run ./cmd/noxy noxy_examples/run_all_tests_concurrent.nx — 185/185 passed
  • go test -race ./internal/vm -run TestStructConstructor -count=1 — passed on Linux
  • full Linux race suite produced the same five sys.exec harness failures on this branch and untouched develop, with no race report

Risk

Only successful constructor-schema validation is cached. The cache is atomic for concurrent task reads and is ignored if ConstructorType no longer matches the cached schema.

AI assistance was used to research the historical patch, adapt it to the current tree, and run verification. I reviewed the resulting code, tests, and benchmark evidence.

Fixes #100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: cache do construtor de struct (PR #70) nunca chegou a develop — validateStructConstructorArguments é 46 % de bench_struct_records

1 participant