Performance optimization opportunity: combinator.c file I/O bottleneck

Aperta
#97 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
42/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
c
Ambito
performance

Direzione di ricerca

The hot spot is the loop in combinator.c where rewind(fd2) runs for each line of file1 (around line 217), so file2 is re-read on every outer iteration. Build the tool and time it on a generated 10,000 × 1,000 line input to reproduce the slowdown. Done means file2 is read once into memory and the output is byte-identical to the current version on the same inputs. The proposed combinator_optimized.c is not in this repo, so check the thread for its status before reusing it.

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

Descrizione

The current combinator.c implementation has an O(n*m) file I/O bottleneck:

  • File2 is completely re-read for every line in file1 (line 217: rewind(fd2))
  • For a 10,000 × 1,000 line combination, this results in 10 million file reads instead of 1
  • Performance degrades exponentially as file1 size increases

Performance Impact

Stress Test Results (10,000 × 1,000 lines = 10M combinations):

  • Current implementation: Timeout (>60 seconds)
  • Optimized implementation: <1 second
  • Speedup: >60x improvement

Memory usage remains similar (~33MB for both versions)

Proposed Solution

I've created combinator_optimized.c that implements:

  1. File2 Memory Caching: Load entire file2 once into memory, eliminating all rewind operations
  2. Enhanced Error Handling: Added malloc() null pointer checks to prevent segfaults
  3. Combined Line Processing: Single-pass carriage return stripping
  4. Improved Buffer Management: More efficient I/O batching
Lingua principale
C
Stelle
1.6k
Fork
421
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 hashcat/hashcat-utils

Tutte le issue di hashcat/hashcat-utils

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.