Add upstream-shaped scoped introspection plugin - #1763
Draft
Zetazzz wants to merge 11 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is an upstream-shaped, opt-in alternative to #1719. It copies the exact Crystal release sources pinned by CNC (
pg-introspection@1.0.1,graphile-build-pg@5.1.3) and keeps the upstream package boundaries while adding a scoped query and replacement introspection plugin.Unset/
falseuses untouched upstream stock introspection.GRAPHILE_SCOPED_INTROSPECTION=truedynamically installsScopedIntrospectionPreset;GRAPHILE_SCOPED_INTROSPECTION_JITindependently controls the introspection session JIT setting and defaults tofalse.Architecture and isolation
pg-introspection: parameterized recursive schema/dependency-closure query,all/dependency-closurecatalog type policy, extension capability retention.graphile-build-pg: complete CNC-ownedPgScopedIntrospectionPlugin, upstream lifecycle/watch/entity behavior, namespace and missing-type fail-closed guards, pinned upstream contract sentinel.ConstructivePresetremains unchanged.PgIntrospectionPlugin/stock query versusScopedIntrospectionPreset/scoped query. They do not loadConstructivePreset, retirement/disposers, governor/cache limits, routing, or admission plugins.Correctness coverage
The real PostgreSQL dependency-closure fixture now covers cross-schema enum/domain/composite/range/multirange types, function signatures, ordinary and
pg_trgmindexes, extension metadata, a cross-schema foreign key, and inheritance direction. It proves the required dependency parent is retained while a reverse parent-to-child relationship does not pull an unrelated child into the closure. No production query-algorithm change was needed.Catalog benchmark
The scoped-only benchmark reuses the generic fresh-process runner/protocol/report. It adds:
packages/perf-harness/artifacts/directory.Environment: macOS arm64, Node v22.22.0, PostgreSQL 18.4 in a dedicated local container. PostgreSQL catalog cache is labeled
shared-server-not-reset; this is not a pristine-cache cold-start claim. Every arm has 10 fresh-process samples. All 240 worker PIDs were unique.JIT off (primary)
Negative percentages mean scoped reduced the metric.
JIT on (diagnostic)
This diagnostic shows why JIT must be controlled: compilation cost dominates the recursive scoped query at small/medium scale. The primary comparison uses identical JIT-off sessions, matching scoped introspection's default.
Schema/runtime results
Both JIT matrices produced one stock/scoped-equivalent schema hash per size, and every runtime query passed:
d31e8b1c2d9cab3d1e67dcbc734e5addd237637028089221cf5f014b9ede4aa58c4e2e03008c98295978712461b799d23957ae89071326a16421ac4a7d0b199641c6ed8feb087766680ab1dc4d833e5082dbf69322b5fb2a118515e7c7ff9db0Scoped reports retained exactly the root/dependency namespaces and excluded noise. Observed build/query session JIT values matched the requested value in every run.
Raw report SHA-256
d5624f57a72262993edf3f9b6168f7440d9ed80d1df7d00c5f550f571a810d42; query-off2601f884973b0f7fd0f70efa412e1aca60159134b9358e35c4de9427dca59eb5; build-on9d4d50aeca03d494cacd8d227ee78621f54c0925586f8137666a5dfea12efd44; query-ondf314c4bb77945ff569af5fde2a2aeef8e0190765ab042c244de3db9c6f78315db25c445975caf5e24674629edc5756aec500f0a5bbe4faf95334f42d2874c0b; query-off0419dbd965a51b2168e424f8a908ecd2c8fdbc661747e45eabf88caa4a64da25; build-on4b83fce4ee842ef5c9335d5fe9228c5583cd77e2a7a233f98f5019111281b518; query-on252184ba8473e4ee7ff1506f74fcf0cfeeb378fbb933e4c6a59a08dd0735103fa0a3249247c4dbefb35311ddac6df0e1fc81aed247f0af0523532022cc6b78bf; query-offaf0ce62200a661b9514e1372adfa824ccecf02e75ff86acc53441e63e7fe393c; build-on066b556726fc521974e8971f074ae42dd962d7fe47cfd9ee9a3cd586da2ce5d9; query-one3a332da4d3dfdd5d0a30c4f60f496c384415c8d0882edcfa47062da19ddf103Reproduction
Build the package, prepare each unique fixture outside measurement, then run it:
Run small before adding medium noise and medium before adding large noise when using one dedicated PostgreSQL server. Fixture preparation never replaces or drops schemas. The large synthetic result demonstrates scale behavior; it is not a claim about typical production gains.
The old cperf tenant-density server, HTTP/open-loop load, p99 qualification, heap ramps, governor/cache/retirement arms, and soak tests were intentionally not migrated.
Validation
Passing:
graphile-scoped-introspection: 32 tests / 8 suites, including 6 real PostgreSQL dependency-closure casespnpm install --frozen-lockfilegit diff --checkNo database URL or password appears in the JSON artifacts.