Deduplicator: xxh32 digest can collide on large ZIMs

Aperta
#426 3 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@i-varunsharma ci sta già lavorando.

Dal 4/12/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

Follow-up from openzim/ifixit#165, as suggested by @benoit74.

Deduplicator keys items by an xxh32 digest only (zim/dedup.py), which is 32-bit. With n deduplicated items the expected number of collisions is about n²/2³³, so roughly 1 around 100k items and ~30 around 500k. A full iFixit ZIM has a lot of images, so two different images could end up with the same digest, and the second one would silently become an alias to the wrong image.

A few options:

  • also store the content size with the digest and compare both, as benoit74 suggested. Cheap, but it only lowers the odds
  • switch to a 128 bit hash (xxhash has xxh3_128), which is about as fast and makes collisions practically impossible
  • both

My suggestion would be xxh3_128 + size as the key. I can open a PR once we agree on the approach.

Lingua principale
Python
Stelle
33
Fork
36
Merge medio
1g 10h
PR unite (30g)
19

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 openzim/python-scraperlib

Tutte le issue di openzim/python-scraperlib

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.