OpenGWASDB vs besdq — Performance Comparison

chr1 × 100 UKB analyses · dense observed-only store

Published

August 23, 2026

ImportantMeasured at format_version 0.1, not re-run for the z or eaf encodings

Every figure below was measured against stores whose z plane is float16 and which carry no eaf at all. Two changes have landed since, both of which move stored size and add a decode step to every read: issue #114 (ADR 0037 §1) made z int16 fixed point with an exact overflow table, and issue #116 (ADR 0037 §2, §4) made eaf a per-variant baseline plus an int8 logit residual and moved format_version to 2.0. The sizes and timings here describe neither. They are re-measured against rebuilt stores in #117, before the version that ships the encodings is cut (CONTRIBUTING.md, “Benchmarks are measurements, not prose”).

Overview

This document compares query and storage performance between OpenGWASDB (this project) and besdq (the prototype it is intended to replace) on the same source dataset: 100 UKB GWAS-VCF analyses covering chromosome 1 (~762 K variants, hg38).

Both systems store float16 z-scores and betas in zarr arrays with zstd+bitshuffle compression. Key architectural differences are noted where they affect comparability.


Dataset

Property OpenGWASDB besdq
Source 100 × UKB GWAS-VCF (hg19) same VCFs
Reference assembly GRCh38 (hg38) GRCh38 (hg38)
Variants retained 762,080 762,488
Variant difference −408 (liftover failures, 0.05%) —
Analyses 100 100

Build

Property OpenGWASDB besdq
Build time not measured not measured
VCF reader bcftools (subprocess) cyvcf2
Liftover hg19→hg38 inline (pyliftover) pre-lifted source
Build strategy two-pass (variant union then fill) one-pass

OpenGWASDB’s build time includes the hg19→hg38 liftover pass on all 100 VCFs and writes a tabix-indexed variant axis alongside the zarr arrays. besdq assumes pre-lifted input and does not write a tabix index.


Storage

Store Size Arrays stored Chunk shape dtype
OpenGWASDB 309 MB z, se, top-hit index, ALID index (n_analyses, 1000) float16
besdq zstd+bitshuffle 233 MB beta, zscore, sig indices (1000, n_analyses) float16
besdq raw float16 310 MB same (1000, n_analyses) float16

OpenGWASDB stores two effect arrays (z and se) plus a pre-computed top-hit sparse index and an mmap’d ALID search index. besdq stores beta and zscore plus pre-computed significance offset arrays. Chunk shape is clipped to actual array dimensions at build time (ADR-0021), so both stores have effective chunks of (1000, 100) for this dataset.


Query timings

All OpenGWASDB timings are median over 10 repetitions after one warm-up call. besdq timings are from ukb-chr1_zarr_benchmark.json (same methodology). Times in milliseconds.

Current (post-optimisation)

Fixes applied: zarr chunk shape clipping (ADR-0021), range_indices() (issue 028), mmap’d ALID sidecar (issues 029–030).

Pattern OpenGWASDB besdq zstd besdq raw ODB / besdq
regional 16.01 ms 4.99 ms 2.72 ms 3.21×
phewas 1.82 ms 0.91 ms 0.33 ms 2.01×
tophits 1.44 ms 0.69 ms 0.70 ms 2.10×
bulk 854.42 ms 490.52 ms 251.37 ms 1.74×
random_lookup 126.32 ms 30.42 ms 7.27 ms 4.15×

Before optimisations (baseline)

Pattern OpenGWASDB (pre-fix) besdq zstd ODB / besdq
regional 97.61 ms 4.99 ms 19.57×
phewas 2.65 ms 0.91 ms 2.92×
tophits 1.30 ms 0.69 ms 1.89×
bulk 1764.18 ms 490.52 ms 3.60×
random_lookup 224.24 ms 30.42 ms 7.37×

Improvement from optimisations

Pattern Before After Speedup
regional 97.61 ms 16.01 ms 6.1×
phewas 2.65 ms 1.82 ms 1.5×
tophits 1.30 ms 1.44 ms 0.9×
bulk 1764.18 ms 854.42 ms 2.1×
random_lookup 224.24 ms 126.32 ms 1.8×

Query pattern definitions

Pattern What it reads Result contract
regional All finite associations in a 1 Mb genomic window, all analyses sparse dict
phewas One variant × all 100 analyses sparse dict
tophits All GW-significant (p < 5×10⁻⁸) associations for one analysis sparse dict
bulk All finite associations for one analysis (~762 K variants) sparse dict
random_lookup 100 random variants × 10 random analyses sparse dict

Comparability notes

(a) Regional — same window, different variant counts. Both benchmarks use chr1:100–101 Mb. OpenGWASDB’s store has fewer variants in this window due to hg19→hg38 liftover losses (0.05% of variants fail liftover). besdq’s store was built from pre-lifted hg38 input so retains more variants.

OpenGWASDB window: ~1,546 variants (~154,615 finite cells); besdq window: ~2,751 variants. The remaining gap reflects the sparse result construction (isfinite mask + dict allocation) vs besdq’s dense summary return.

(b) Bulk — both systems read two arrays. besdq’s query_bulk reads beta + zscore (2 zarr columns); OpenGWASDB reads z + se (2 zarr columns) and applies an np.isfinite mask. The gap is not explained by array count; it likely reflects I/O timing variance between benchmark runs.

(c) Random lookup — inherent two-array cost. besdq’s query_random_lookup reads one array (beta); OpenGWASDB reads two (z and se) per the sparse array contract (ADR-0020). A ~2× gap is therefore expected. The mmap’d ALID index eliminates sequential tabix fetch overhead (~15 ms previously).


Root-cause summary

Pattern Before vs besdq (before) After vs besdq (after) Change
regional 97.61 ms 19.57× 16.01 ms 3.21× 6.1× faster
phewas 2.65 ms 2.92× 1.82 ms 2.01× 1.5× faster
tophits 1.30 ms 1.89× 1.44 ms 2.10× —
bulk 1764.18 ms 3.60× 854.42 ms 1.74× 2.1× faster
random_lookup 224.24 ms 7.37× 126.32 ms 4.15× 1.8× faster

What OpenGWASDB adds beyond besdq

Feature OpenGWASDB besdq
Reference assembly liftover hg19→hg38 inline at build time requires pre-lifted input
Variant axis tabix-indexed TSV (range queries, rsid aliases) numpy key array (position lookup only)
ALID index mmap’d sorted binary search, O(log n), ~0 startup in-memory dict, O(1), ~1.5 GB at 12 M variants
Effect statistics z + se (both stored and returned) beta + zscore (both stored)
Query result contract sparse dict[str, np.ndarray] (finite cells only) dense numpy arrays (NaN for absent)
Top-hit index pre-computed, threshold-parameterised, includes se pre-computed z/beta, no se
Store validation full format check at open time none
CLI yes no

Scalability: 128 → 1000 analyses

Same variants (762,080) and the same chr1 source manifest; 1000 analyses is 7.8× the 128-analysis subset. Measures how build time, storage, and query latency scale with analysis count.

128-analysis benchmark JSON not found — run uv run python benchmarks/benchmark_vcf_ukb_chr1_1000_dense.py --analysis-count 128 --rebuild --reps 10.

Build time and store size should scale sub-linearly because the variant axis, tabix index, and ALID index are fixed overhead paid once and amortised across additional analysis columns. Query time generally scales with result set size: regional and bulk read more cells so scale closer to linearly; phewas and tophits scale better because the zarr read per row is amortised across more columns per chunk.


Provenance

  • OpenGWASDB post-fix timings: opengwasdb_vcf_ukb_chr1_benchmark.json (built existing store, 762,080 variants × 100 analyses)
  • OpenGWASDB 1000-analysis timings: opengwasdb_vcf_ukb_chr1_1000_benchmark.json (built 4821s, 762,080 variants × 1000 analyses)
  • OpenGWASDB pre-fix timings: opengwasdb_vcf_ukb_chr1_array_benchmark.json
  • besdq timings: besdq_ukb_chr1_benchmark.json (copied from besdq repo by benchmarks/README.md step)
  • besdq store: ukb-chr1-zstd.besdz (zstd+bitshuffle), ukb-chr1.besdz (raw float16)