SortMergeJoinExec double counts join key columns in the buffered batch reservation
Mantenedores costumam responder em até 1 dia
Avaliação
Esta issue ainda não foi avaliada.
Descrição
Describe the bug
SortMergeJoinExec charges a buffered batch twice for each join key that is a plain column. BufferedBatch::try_new adds batch.get_array_memory_size() and the size of each evaluated join key array. When the key is a column reference, the key array shares its buffers with the batch. The reservation then counts that column two times.
The effect is that a join on a wide string key reserves about twice the memory it holds. This makes the join spill or fail under a memory limit earlier than it should.
To Reproduce
Run this in datafusion-cli (commit 34eb6dc5b on main). Both queries buffer the same data. Only the join key differs.
SET datafusion.execution.target_partitions = 2;
SET datafusion.optimizer.prefer_hash_join = false;
CREATE TABLE l AS SELECT value AS id, repeat('x', 1000) || value AS s FROM generate_series(1, 20000);
CREATE TABLE r AS SELECT value AS id, repeat('x', 1000) || value AS s FROM generate_series(1, 20000);
-- join on the wide string column
EXPLAIN ANALYZE SELECT max(l.id), max(r.id), max(l.s), max(r.s) FROM l JOIN r ON l.s = r.s;
-- join on the integer column, same columns kept
EXPLAIN ANALYZE SELECT max(l.id), max(r.id), max(l.s), max(r.s) FROM l JOIN r ON l.id = r.id;
Observed SortMergeJoinExec metrics:
| join key | peak_mem_used |
|---|---|
l.s = r.s |
38.8 MB |
l.id = r.id |
19.7 MB |
Expected behavior
Both queries should report about the same peak_mem_used, because the buffered batches are the same. A key array that is a column of the batch should not be charged again.
Additional context
A possible fix is to charge only the key arrays that do not share buffers with the batch (for example, skip Column keys, or count buffers by pointer once per batch).
Related: https://github.com/apache/datafusion/issues/16841 and https://github.com/apache/datafusion/issues/22758.
- Linguagem predominante
- Rust
- Estrelas
- 9.6k
- Forks
- 2.6k
- Merge médio
- 3d 4h
- PRs com merge (30d)
- 345
Preparar o ambiente
Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de apache/datafusion
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
apache/datafusion#27315 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
apache/datafusion#27094 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Substrait consumer doesn't recognise `shift_left` / `shift_right` from functions_arithmetic.yamlTalvez já em andamento @jonasHanhan assumiu há 9 dias. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
apache/datafusion#27059 ·
Mantenedores costumam responder em até 1 dia
-
`ProjectionExprs::project_statistics` computes approximate `Statistics::total_byte_size` ignoring column statsTalvez já em andamento @joseph-isaacs assumiu há 10 dias. Abertabug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
apache/datafusion#27050 ·
Mantenedores costumam responder em até 1 dia
-
physical-plan: decoding an Unnest or Explain node with an unset field panicsTalvez já em andamento @geoHeil assumiu há 8 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
apache/datafusion#26999 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de apache/datafusion
Issues semelhantes
-
P3
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
HerringtonDarkholme/hd-lang#1770 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
jonathanong/no-mistakes#3332 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
swc-project/swc-next-issues#310 ·
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
swc-project/swc-ai-issues#653 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
lbjlaq/Antigravity-Manager#3937 ·
Mantenedores costumam responder em até 1 dia