Performance optimization roadmap for large-scale datasets (ERA5-scale)
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
- Type d'issue
- Fonctionnalité
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Domaine
- data, performance
Piste de recherche
This is a parent roadmap; the open items cover LIMIT pushdown, multi-dimensional chunking, and metadata caching, while the listed performance work is marked complete. Read the linked benchmark context in #75 and inspect the relevant scan, partition factory, and partition_metadata entry points. Choose a specific open sub-issue before estimating completion; no tests or acceptance criteria are named here.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Overview
This is a parent tracking issue for all performance optimizations needed to make xarray-sql practical for ERA5-scale datasets (~732,072 partitions, ~38.4M rows/partition, ~250 variables).
Benchmarks and profiling context: see #75 (Rerun perf_tests post DataFusion).
Completed ✅
- Projection pushdown into partition factory — Pass column projection into the partition factory to avoid loading unnecessary variables. For a dataset with 250 variables, a single-column query previously loaded all 250 arrays. (Implemented)
- Precompute coordinate arrays in partition_metadata —
ds.coords[dim].valueswas re-accessed O(N_partitions × N_dims) times (2.9M calls for ERA5). Now extracted once per dimension before the loop. (Implemented)
Open Sub-issues
Memory & Data Path
-
Replace pandas round-trip with direct numpy → Arrow RecordBatch construction (#121-placeholder)
Current path: xarray arrays →
to_dataframe()→ pandas MultiIndex →reset_index()→ flat DataFrame →pa.RecordBatch.from_pandas(). This is a 3-copy chain. For a 38.4M-row, 5-column partition: ~1.5 GB peak to produce ~307 MB output. Direct numpy → Arrow avoids all pandas overhead. This is the primary memory bottleneck per partition. -
Emit multiple small RecordBatches per partition instead of one giant batch
Each factory currently wraps a single 38.4M-row RecordBatch. DataFusion must fully materialize the partition before processing any of it, then re-splits to its 8192-row default — duplicating memory. Emitting batches of ~65,536 rows via a generator allows DataFusion to pipeline filtering/aggregation and reduces peak memory from O(partition_size) to O(batch_size).
-
Avoid materializing all block dicts and factory closures at registration time
read_xarray_table()currently forces all 732,072 partition block dicts, metadata dicts, and closures into memory before any query runs — ~1.7 GB RAM. TheLazyArrowStreamTableconstructor should accept a callable that generates(factory, metadata)pairs on demand, or expose a streaming registration API.
Concurrency
-
Release GIL during partition load to enable DataFusion parallelism
PyArrowStreamPartition::execute()holds the GIL for the entirepivot() + to_dataframe()call — serializing all partition loading through the GIL regardless of DataFusion's thread pool size. Options:tokio::task::spawn_blocking, or restructuring the factory to release the GIL at numpy/Arrow boundaries (many numpy ops release the GIL already).
Additional Pushdown
-
Limit pushdown — avoid loading full partitions for LIMIT queries
SELECT * FROM ds LIMIT 100currently materializes all 38.4M rows of the first matching partition. Thescan()method can pass the limit through the partition stream and the factory can stop early once enough rows are produced.
Chunking & Metadata
-
Document and support multi-dimensional chunking for pruning on non-time dimensions
Currently, filter pushdown only prunes on the chunking dimension. For ERA5 chunked by time,
WHERE lat BETWEEN 30 AND 60reads all 732,072 partitions. Multi-dim chunking (chunks={'time': 1, 'lat': 90, 'lon': 180}) enables lat/lon pruning too.PrunableStreamingTablealready stores multi-dim bounds — this is primarily a documentation, testing, and chunk-size recommendation task. -
Cache/serialize partition metadata across sessions
partition_metadata()recomputes coordinate min/max bounds for all partitions on every session start. For ERA5 over GCS, this adds significant latency from 732,072 coordinate reads with network overhead. Persist bounds to a sidecar file (JSON/Parquet) keyed by dataset path + chunk spec.API sketch:
table = read_xarray_table(ds, chunks={'time': 1}, metadata_cache='./era5_meta.parquet')
Priority Order (suggested)
- Replace pandas round-trip (#13 above) — biggest per-partition memory win
- Emit multiple RecordBatches — enables pipelining
- Release GIL — enables true parallelism
- Lazy partition registration — reduces startup memory
- Limit pushdown — improves interactive queries
- Metadata caching — reduces remote dataset startup latency
- Multi-dim chunking docs — enables spatial/non-time pruning
- Langage dominant
- Python
- Étoiles
- 142
- Forks
- 19
- Merge moyen
- 1 j 9 h
- PR mergées (30 j)
- 9
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de xqlsystems/xarray-sql
-
documentation
Difficulté 1/5 1-3 heures Accessibilité débutants 85/100
xqlsystems/xarray-sql#268 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
xqlsystems/xarray-sql#267 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 74/100
xqlsystems/xarray-sql#243 ·
Les mainteneurs répondent en général sous 1 jour
-
publish.yml: the TestPyPI verification step is unreachable (and installs the wrong package name)Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
xqlsystems/xarray-sql#242 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
xqlsystems/xarray-sql#237 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de xqlsystems/xarray-sql
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
mihai-vlc/sublime-jsfmt#56 ·
-
comp/cli comp/plugins P2 type/bug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
NousResearch/hermes-agent#141917 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Go device SDK: Whisper transcriber keeps buffering and transcribing audio appended after Stop()Peut-être pris @apoorvdarshan l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
BasedHardware/omi#22770 ·
Les mainteneurs répondent en général sous 1 jour
-
bug needs-acceptance wg/router-models-inference-runtime
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
vllm-project/semantic-router#5295 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
huggingface/huggingface_hub#5210 ·
Les mainteneurs répondent en général sous 1 jour