Deduplicator: xxh32 digest can collide on large ZIMs

Offen
#426 3 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@i-varunsharma arbeitet bereits daran.

Seit 04.12.2026.

Bewertung

Dieses Issue wurde noch nicht bewertet.

Beschreibung

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.

Vorherrschende Sprache
Python
Sterne
33
Forks
36
Ø Merge
1 T. 10 Std.
Gemergte PRs (30 T.)
19

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus openzim/python-scraperlib

Alle Issues in openzim/python-scraperlib

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.