The size of the module version hash is currently 7 characters, by base36-encoding the result of fnv132 (as done in ResourceLoader::makeHash).
Contrary to what I thought, this algo usually only needs 6 characters, not 7. As such, for more than half of the modules in production (enwiki/anon/defaults), the base conversion is padding a zero.
let startsWithZero = 0; let startsWithNonZero = 0; mw.loader.getModuleNames().forEach(name => { mw.loader.getVersion(name)[0] === '0' ? (startsWithZero++) : (startsWithNonZero++); }); ({ startsWithZero, startsWithNonZero }) //> { startsWithZero: 637, startsWithNonZero: 595 }
About 52% of module hashes have a zero padded. And 3% even has two zeroes padded.
let startsWithTwoZero = 0; mw.loader.getModuleNames().forEach(name => { mw.loader.getVersion(name)[1] === '0' && (startsWithTwoZero++); }); startsWithTwoZero ///> 34
Figure 1. Zeroes galore |
---|
To do:
- Document what our needs are of the hashing algo.
- Reduce the size from 7 to 5.
- Consider reducing it further.