← Back to Pull requests

bench(perf-matrix): FlatGeobuf and GeoPackage writes against GDAL #1435

Open
unknown opened this pull request with 554 lines diff across 6 files
View on GitHub
unknown unknown commented on Nov 30, 2026 15:10 UTC
Author

The performance matrix (scripts/perf_matrix.py) now compares terrio's FlatGeobuf and GeoPackage writes with GDAL's: two formats, flatgeobuf-write and geopackage-write, write the GeoParquet fixtures (400,000 polygons or lines, 2,000,000 points) with terrio.write_vector and with GDAL 3.13.3, and compare every output with GDAL's feature by feature. /perf-matrix flatgeobuf-write and /perf-matrix geopackage-write run them on a pull request; like geoparquet-write, the default /perf-matrix leaves them out.

Part of #1274 (Writes: "FlatGeobuf, GeoPackage").

What was added

  • FlatGeobufWrite and GeoPackageWrite, subclasses of GeoParquetWrite, whose methods now take the driver, output extension, creation options and comparison from the class (DRIVER, GDAL_FORMAT, OUT, LCO, compare). GeoParquet writes are unchanged.

  • terrio's writers take no options and write a spatial index (FlatGeobuf: packed Hilbert R-tree, node size 16; GeoPackage: R-tree, geometry column geom), so GDAL is given SPATIAL_INDEX=YES, and GEOMETRY_NAME=geom for GeoPackage. Timing is the write call's, from the source loaded in memory beforehand (terrio.open_vector, a GDAL MEM copy), as for GeoParquet writes.

  • After each terrio sample, the output is compared with GDAL's reference: field names and types, CRS, every feature's attributes and GEOS-normalized geometry in any order (benchmark_validation.compare_vectors), then whether both outputs have a spatial index (OLCFastSpatialFilter). A GeoPackage records its write time (gpkg_contents.last_change), so its outputs never share bytes and every sample is compared.

  • PATHS entries for both, perf-matrix.yml accepts both by name, docs/benchmarks.md describes them; a test checks the comparison (equal files, a changed attribute, an output without the index GDAL writes).
  • Results

    --samples 3 on an i9-14900K (32 CPUs, 61 GB, Linux), terrio 0.10.0 (release wheel of main at 9192c841), GDAL 3.13.3, 4 threads. The machine was shared with other work (/proc/loadavg 25–31), so time ratios are provisional; output equality is not.

    All 6 cases are exact: every feature, field and CRS equal to GDAL's output, both with a spatial index.

    | Case | terrio ms | GDAL ms | terrio/GDAL | Output KiB t/G | Peak RSS MB t/G |
    |---|---:|---:|---:|---:|---:|
    | FlatGeobuf polygon | 662 | 754 | 0.88 | 147,458 / 147,459 | 1,266 / 773 |
    | FlatGeobuf point | 3,179 | 3,911 | 0.81 | 299,847 / 299,848 | 1,948 / 1,156 |
    | FlatGeobuf line | 717 | 713 | 1.01 | 141,208 / 141,209 | 1,205 / 695 |
    | GeoPackage polygon | 788 | 663 | 1.19 | 149,244 / 157,420 | 1,781 / 666 |
    | GeoPackage point | 1,741 | 2,536 | 0.69 | 197,192 / 237,580 | 2,714 / 1,017 |
    | GeoPackage line | 648 | 639 | 1.01 | 140,736 / 148,908 | 1,713 / 585 |

    Geometric mean terrio/GDAL: FlatGeobuf 0.90, GeoPackage 0.94. Peak RSS includes the source held in memory, which is larger as a terrio layer than as GDAL's MEM dataset: terrio peaks at 1.6–2.9x GDAL's memory.

    Limitations

  • One layout per format: terrio's writers have no options (no unindexed FlatGeobuf, no GeoPackage without R-tree), so other layouts are not measured. The tracker item stays partial on that account, as GeoParquet writes did.

  • /perf-matrix runs with the base branch's harness, so it measures these formats on pull requests after this one is merged.

  • The workflow line that lists formats is also edited by the other perf-matrix pull requests; whichever merges later needs a trivial conflict resolution.
  • Validation

  • pytest scripts/tests/test_perf_matrix.py (GDAL 3.13.3 environment): 112 passed.

  • Local reviews (CI review prompt, correctness review, standards/spec review); findings fixed or answered.
  • 🤖 Generated with Claude Code

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    New Features
    Performance benchmarks now cover writing FlatGeobuf and GeoPackage files, including spatial-index checks and comparisons with GDAL.
    The /perf-matrix command accepts FlatGeobuf and GeoPackage write formats by name. Default runs continue to exclude vector writes.
    Documentation
    * Updated benchmark guidance with instructions and details on timing and comparing the new write formats.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 554 lines (+415 / -139) across 6 files Reviewer: coderabbitai[bot] Review duration: 7m
    All Vouch review confidence checks passed
    Residual risk 0.33 = Change Risk (0.48) × (1 − Review Confidence (0.31)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 554 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 56% · Reviewer familiarity: 35%
    31%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.378
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #1435"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 31.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.1% (MEDIUM) · Higher = larger blast radius
    48.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 31.3% · Lower = rushed or shallow review
    31.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 33% · Safe to merge
    33%