Repository navigation
Benchmark harness and batch insert optimization - #8
Merged
Merged
Conversation
Replace single-row INSERT loops with UNNEST-based batch inserts in all Rust derive write paths (highway_edges, exit_corridors, corridors, corridor_exits, reference_routes, reference_route_anchors). This reduces 100k+ individual queries to ~20 batched queries per table, eliminating per-row round-trip overhead. Also adds: - bin/benchmark-pipeline: Karpathy autoresearch-style harness for measuring per-stage wall-clock times using Rhode Island PBF - ANALYZE exits/pois in derive.sql before the spatial join so the query planner uses fresh statistics Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move docker run out of bash -c subshell so DB_CONTAINER variable is visible to the cleanup trap - Add double-check wait: pg_isready inside container + real SQL query from the runner network before proceeding - Support OI_REPO_ROOT env var for running from outside the repo - Remove bind-mounted data dir (use ephemeral container storage) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Deferred indexes (derive.sql): Drop GiST indexes on exits/pois before bulk loading, rebuild in a single pass before the spatial join. Drop exit_poi_candidates index before its bulk insert, rebuild after directional pruning. Avoids per-row GiST maintenance during inserts. Connection pool (main.rs): Reduce max_connections from 20 to 4. The derive pipeline runs all operations sequentially within transactions, so 20 connections were wasted overhead. Benchmark harness: Pre-build the Rust binary before the benchmark loop and invoke it directly instead of via cargo run. Eliminates ~1.4s of cargo bookkeeping overhead per run. RI benchmark results (median of 3 warm runs): Baseline (main): 5,983ms total + UNNEST batching: 5,215ms (-13%) + Deferred indexes: 4,541ms (-24%) + Direct binary: 3,200ms (-47%) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
bin/benchmark-pipelineharness for systematic A/B testing (RI PBF, fresh PostGIS per run, per-stage timing to JSONL)Expected impact
Test plan
bin/benchmark-pipeline --runs 3 --label baselineon RI PBF🤖 Generated with Claude Code