Deduplicator: xxh32 digest can collide on large ZIMs

未关闭
#426 3 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@i-varunsharma 已经在做这个了。

开始于 2026年12月4日。

评估

这个 Issue 还没有评估数据。

描述

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.

主要语言
Python
星标
33
派生
36
平均合并
1 天 10 小时
30 天内合并 PR
19

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

openzim/python-scraperlib 的其他 Issue

查看 openzim/python-scraperlib 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。