Repository navigation
Conversation
|
Thanks for the pull request, @Max17190. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify review 
5 possible issues to check · High impact
graphify query --snapshot can build and reuse a SQLite projection of the graph for query search and traversal.
5 possible issues we couldn't confirm
- Snapshot write after the answer can crash the query and skip its exit code ·
graphify/cli.py:2338 - resolve_seed and resolve_reference_forms now require a QueryGraph but still use networkx-style graph calls ·
graphify/affected.py:207 - edge_datas returns one merged entry instead of one per parallel edge when given a query snapshot, because it only recognises networkx graphs ·
graphify/build.py:1234 - +2 more in Graphify
They don't change the score.
What this review covered
- We didn't review 1 file that isn't source code, such as docs, config, images, or generated or third-party code.
- Some lookups asked for files or lines that do not exist; the review was told and carried on.
- 6 of 6 changed files inspected. This is scope, not a correctness guarantee.
Code graph · 2985 functions depend on this change
- 8 functions became more coupled. Largest:
main()(131 callers),_query_graph_text()(57 callers),dispatch_command()(8 callers). - 629 of 629 test files are affected by this change.
- Gate, test list and every flagged function: in the Graphify check.
Reviewed 56699ad · 14 earlier findings not re-checked
Max17190
force-pushed
the
perf/query-snapshot
branch
from
November 24, 2026 23:29
b360500 to
38e6946
Compare
Fresh CLI queries rebuild the search index and hydrate the full graph. An opt-in snapshot preserves query behavior while reading candidates and neighborhoods on demand. Refs Graphify-Labs#1297 Co-Authored-By: OpenAI Codex <[email protected]>
Keep serving JSON results when the optional cache directory cannot be resolved or an unrelated graph row cannot be indexed. Verify recovery by corrupting exactly the active generation in the CLI test. Refs Graphify-Labs#1297 Co-Authored-By: OpenAI Codex <[email protected]>
Use the JSON query path for inputs the snapshot cannot represent. Reject unreadable snapshot metadata and key the projection by Unicode data version so an interpreter upgrade cannot reuse stale search text. Refs Graphify-Labs#1297
Fall back to the JSON query when a cached payload exceeds the decoder recursion limit. Let one process publish a snapshot while other cold queries keep their JSON result. Refs Graphify-Labs#1297
Carry the learning overlay into filtered JSON graphs and filtered snapshots. Verify that both paths render the same annotations, including on a warm cache hit. Refs Graphify-Labs#1297
graphify.build and graphify.affected imported the snapshot module only for a type annotation, so every build or affected run loaded it and SQLite even though snapshots are opt-in. Describe what edge_datas reads with a small protocol in build.py, which keeps its annotations resolvable at runtime, and import the alias in affected.py for type checking only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`graphify query --snapshot` built the cache before printing, so an error outside the handled set, or an interrupt during a slow first build, lost an answer that was already computed. Print and flush the answer first, and never let the optional build change the exit status. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A `Type.Member` or `file.ext` query first checks whether the text names a source file, which decoded every node row of a warm snapshot. Store the distinct source files in the snapshot and check those instead. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hots Compare warm snapshot answers with the JSON path for the qualified-name tier, source path queries, explicit file seeds, and walks that stop at a high-degree hub, with and without context filters. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A builder killed before its cleanup ran left its partial database in the cache directory for good. Builders hold the build lock, so the next one can safely remove any build file it finds there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Max17190
force-pushed
the
perf/query-snapshot
branch
from
November 25, 2026 19:38
38e6946 to
56699ad
Compare
This branch has not been deployed
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.
Why
A fresh
graphify queryprocess loads the full graph fromgraph.json. Keyword queries also rebuild the search index. A Guava query that returned two nodes took 3.37 s and peaked at 388 MiB.Summary
Add
graphify query --snapshot. The first invocation builds a local SQLite cache for that generation ofgraph.json. Later invocations read candidate nodes and the edges they traverse, then use the existing scorer and renderer.The baseline includes the betweenness and path-rebasing changes from #5303 and #5322. #5382 reduces work during clustering. This change targets the cost of querying an existing graph.
Related to #1297. #3271 persists trigram postings. The snapshot also serves node and adjacency reads from disk.
Type of change
Verification & Invariants
The snapshot preserves stdout, stderr, and exit status. It supports undirected simple graphs with normalized labels. The JSON path handles unsupported graph types, nonnormalized labels, arguments SQLite cannot encode, and cache read or build failures. Context-filtered queries retain learning annotations on both the JSON and snapshot paths.
The cache is specific to the graph generation and the interpreter's Unicode data version. Invalid metadata and corrupt payloads fall back to JSON. The next successful build replaces the invalid cache. One process builds at a time and concurrent queries return their JSON answer without waiting. The README documents invalidation and disk usage.
Benchmarks
Fresh CLI processes on an Apple M5 with CPython 3.13. Each pair ran against
v8atb582ad40and this PR at29635a75. The snapshot runs reused an existing cache. All 28 pairs matched stdout, stderr, and exit status. The composite combines Graphify, Django, and two namespaced copies of Guava. Peak RSS is the median per-process high-water mark.Guava's first request took 7.16 s including cache construction. Its 149 MB graph produced a 260 MB cache. The composite took 21.49 s on the first request and produced a 736 MB cache. The flag is opt-in.
Changes after rebasing onto v8
v8now caches per-node query fields, degrees, and traversal indexes for the whole graph. For a snapshot, those caches fill lazily as the query reaches each node, so snapshot scoring and traversal run the samev8code without loading every row. Against Graphify's own graph (26,369 nodes), 32 queries covering BFS, DFS, context filters, depth, budget, seeds, short terms, and dotted names matched stdout and exit status with and without--snapshot. None fell back to JSON. Warm snapshot queries ran 3.9× to 7.0× faster, best of five. The first query, which builds the cache, took 1.9 s against 0.95 s.graphify.buildandgraphify.affectedno longer import the snapshot module.Type.Membercheck a table of source files instead of reading every node row. The cache format moves to version 3, so existing caches rebuild.--context.Known limitation: a
--seedgiven as a label or path goes through the shared seed resolver, which reads every row. Seeds given as node IDs are unaffected.Test Plan
Passed 357 focused tests. Regression coverage includes deeply nested cache corruption, concurrent cold queries, and context-filtered learning annotations. The annotation test verifies that a warm snapshot and the JSON path render identical output. The concurrent test keeps one builder open while a separate CLI process returns its JSON answer. In a separate run against Graphify's own graph, four cold CLI processes returned identical output and built one snapshot. The snapshot tests passed on CPython 3.11 through 3.14. A separate CLI run warmed the cache on Python 3.13 and verified on Python 3.14 that both the first and subsequent snapshot queries matched the JSON path for a case mapping added in Unicode 16.
Ruff and the generated skill check passed. Pyright produced the same diagnostics as before the follow-up.
After the rebase, 627 focused tests passed across the snapshot, query, serve, affected, and build suites, and ruff passed.
Before this follow-up, all four Python versions passed on the same Git tree across two CI runs. The second Python 3.12 job hit a timing-sensitive watch test. I reproduced its stale-graph failure on unmodified
v8by delaying a Git subprocess after it closed its output pipes. The test replaces the process-widetime.sleep. Isolating that patch to the watcher made all six watch cases pass with the delay in place. Earlier matrix · Python 3.12 pass on the same tree.CI matrix for the current commit.
Graphify-specific checklist