[C++] GZipCodec::Init does deflateInit and immediately throws it away

Aperta Adatta ai principianti
#51,308 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
performance

Direzione di ricerca

Iniziate in cpp/src/arrow/util/compression_zlib.cc alle righe 497-501 e seguite GZipCodec::InitCompressor, InitDecompressor e EndCompressor. Confrontate la sequenza di inizializzazione attuale con la correzione proposta a cui si fa riferimento, quindi verificate che la validazione del livello di compressione rimanga intatta, mentre l’allocazione e il rilascio ridondanti del compressore siano stati rimossi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Component: C++ Type: bug
Describe the bug, including details regarding any error messages, version, and platform.

Performance issue in GZipCodec, no crashes/wrong results/..., but I still think it's a bug.

https://github.com/apache/arrow/blob/cd304b22da0ca1dc92edf86e6476d733f5ea5b05/cpp/src/arrow/util/compression_zlib.cc#L497-L501

This is wasteful: InitCompressor on line 497 calls deflateInit2, which at windowBits=15 and memLevel=8 allocates roughly 256 KB. InitDecompressor on line 501 calls EndCompressor which does deflateEnd and frees it again. It's pure waste. The only thing it gives us is some validation on the compression level.

The current code leaves the GZipCodec with a valid decompressor (which also allocates, but less) which is fine for the case where the caller wants to use the codec to do decompression, but is extra-wasteful for the case where the caller wants to compress: it allocates a compressor, frees it, allocates a decompressor, frees it, then allocates a compressor again.

I think the correct fix is https://github.com/firebolt-db/arrow/pull/47, I'm happy to file it as a PR here as well.

Component(s)

C++

Lingua principale
C++
Stelle
17.1k
Fork
4.3k
Merge medio
3g 13h
PR unite (30g)
93

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/arrow

Tutte le issue di apache/arrow

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.