Codename One Fixes Severe HashMap Miss Performance Bug With Perturbed Probing

Developers working on Codename One, an open-source cross-platform Java/Kotlin framework, discovered a critical performance flaw in ParparVM's HashMap where lookups for absent keys were dramatically slower than for present ones. Benchmarks revealed that three million containsKey calls for missing keys took 32.7 seconds, while probes per miss reached over 222,000 for tables with one million entries. The root cause was that integer keys clustered in adjacent slots, causing linear probing to walk long uninterrupted runs before finding an empty slot. The team resolved this by adopting a CPython-inspired perturbed probing recurrence, reducing mean probes per miss to under two across all tested table sizes. Additional improvements included using cached hash codes to short-circuit unequal string comparisons and routing compatible UTF-16 string comparisons through native memcmp for faster vector-level processing.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in