Commit Graph

2 Commits

Author SHA1 Message Date
shanglei
2098c3c412 perf(registry): drop embedded meta_data.json and the larkmeta build tag
The startup baseline now comes solely from the generated static Go registry
(metastatic.Registry), wired into the stub-declared Registry via a package-level
var plus an init() struct-header copy. No build tag, no committed generated
file, and zero startup allocation is preserved.

- gen.go emits a tag-free `var registryData` + `func init()` instead of a
  //go:build larkmeta top-level `var Registry`; stub.go declares Registry
  unconditionally so the package always compiles
- fetch_meta.py regenerates the static registry after fetching, so every build
  and CI step that fetches also produces it (no separate gen step, no CI change)
- remove the //go:embed meta_data.json baseline and the JSON parse fallback;
  meta_data.json is now only the build-time input to the generator
- EmbeddedSpec/EmbeddedServiceNames read the static baseline; drop the schema
  key-order machinery so envelope field order is alphabetical (JSON Schema
  property order is not semantic; parameterOrder for positional args is intact)
- drop -tags larkmeta from Makefile, .goreleaser.yml, and build-pkg-pr-new.sh

Command tree is byte-identical (8092 lines). registry/schema/cmd unit tests,
the zero-alloc bench, and the e2e dry-run suite all pass.
2026-06-09 18:36:58 +08:00
shanglei
4215ad9908 feat(registry): build command tree from static typed meta (larkmeta)
Migrate the startup command-tree build path to read compile-time static
Go structs (metastatic.Registry, behind -tags larkmeta) instead of parsing
the 1.9MB meta_data.json into map[string]interface{} (~170K heap objects)
on every invocation.

- typed.go: typed baseline + remote-overlay layer. Reads static data under
  -tags larkmeta (zero parse / zero alloc); falls back to parsing the
  embedded meta_data.json once for builds without the tag (dev/test). A lazy
  typed->map shim (ServiceToMap/MethodToMap) keeps execution-path consumers
  working unchanged.
- service.go: registration chain and NewCmdServiceMethod read typed structs
  directly; map wrappers convert via MapToService/MapToMethod for existing
  tests; method RunE materializes opts.Spec/opts.Method lazily, never at
  startup.
- loader.go/remote.go: baseline and cached remote overlay decode into the
  typed shape; runtime refresh preserved.
- build pipeline: Makefile, goreleaser and pkg-pr-new run the generator and
  build with -tags larkmeta so shipped binaries carry the static data.

Reading the full static registry is 0 B/op, 0 allocs/op; the built command
tree is byte-identical to the JSON-parsed tree (verified via a canonical
tree dump in both modes).
2026-06-09 16:49:40 +08:00