Patch & Discussion: Use 64-bit FNV-1a hash + proper hash-round concat + clipping

Sven Göthel sgothel at jausoft.com
Mon Aug 17 23:38:01 UTC 2026


I have added the cgit-reaper here
 - repo <https://jausoft.com/cgit/cgit-reaper.git/about/>
 - backup <https://github.com/sgothel/cgit-reaper>
and well described it in its README.

Main objective for this file reaper is to allow cgit to use the full range of 64-bit FNV-1a value
to reduce collisions but limiting the maximum number of cache files to a considerably lower number.

This works w/ my cgit patches using the 64-bit FNV-1a value and a bit more
- my branch <https://jausoft.com/cgit/cgit.git/log/>
- backup <https://github.com/sgothel/cgit/commits/master>

cgitrc config example:

# new cgit-reaper config (defaults)
pid-parent-dir=/var/run
cache-max-files=1048576
cache-min-ttl=1
cache-max-ttl=525600

# shared cgit/cgit-reaper config (best)
cache-size=18446744073709551615

+++

Merging welcome, as well as to take over the cgit-reaper
to your cgit repo of course.
However, it is coded in C++20 and uses my jaulib submodule
<https://jausoft.com/cgit/jaulib.git/about/>.

+++

This whole analysis started when the server I maintain
started to be 'under attack' (DoS) a while ago.
Today, every now and then they are run over still,
but I managed to fine tune resources including cgit
with my patches.

Cheers,

~Sven

On 7/23/26 4:27 PM, Sven Göthel wrote:
> As described:
> <https://jausoft.com/cgit/cgit.git/commit/?id=4d8f593faf93b1043309e987823220a70f70a701>
> 
> Or find it in <https://jausoft.com/cgit/cgit.git/log/>,
> if I must revise it (bugs).
> 
> Will post the patch if interested.
> 
> I get good collision-free hashes w/ 
> e.g. 16M cache-size (16777215), see table below
> with added used hex-nibbles.
> 
> Maximum would be full 64-bit values,
> however .. this is surely not desired :)
> (On a ZFS fs this would not be an issue though)
> 
> The FNV-1a 64bit hash is the clipped
> to the desired size w/ shift-xor and masking.
> 
> The project hash is also better concatenated,
> passing the previous round to the hash-algo.
> 
> When updating or changing the cache-size,
> one better temporarily removes the binary
> and re-creates the cache/cgit folder.
> See <https://jausoft.com/cgit/cgit.git/tree/scripts/clean-cgit-cache.sh?h=jau_config&id=7a24e791c9273bdd57b492c0272663e39596b37e>
> 
> Comments and ideas are welcome.
> 
> Cheers,
> 
> ~Sven
> 
> # FFFFFFFF 4294M (full 32-bit)
> # cache-size=4294967295
> #  FFFFFFF  268M
> # cache-size=268435455
> #   FFFFFF   16M
> cache-size=16777215
> #    FFFFF    1M
> # cache-size=1048575
> 
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20260818/6c400293/attachment.sig>


More information about the CGit mailing list