Hash-based maps, particularly java.util.HashMap, are pervasive in Java applications and the JVM, making their performance critical. Evaluating optimizations is challenging because performance depends on factors such as operation patterns, key distributions, and resizing behavior. Microbenchmarks are fast and repeatable but often oversimplify workloads, failing to capture the realistic usage patterns. Application benchmarks (e.g., DaCapo, Renaissance) provide realistic usages but are more expensive to run, prone to variability, and dominated by non-HashMap computations, making map-related performance changes difficult to observe. To address this challenge, we propose MapReplay, a benchmarking methodology that combines the realism of application benchmarks with the efficiency of microbenchmarks. MapReplay traces HashMap API usages generating a replay workload that reproduces the same operation sequence while faithfully reconstructing internal map states. This enables realistic and efficient evaluation of alternative implementations under realistic usage patterns. Applying MapReplay to DaCapo-Chopin and Renaissance, the resulting suite, MapReplayBench, reproduces application-level performance trends while reducing experimentation time and revealing insights difficult to obtain from full benchmarks.
翻译:基于哈希的映射结构(尤其是java.util.HashMap)在Java应用程序及JVM中普遍存在,其性能至关重要。评估优化方案具有挑战性,因为性能取决于操作模式、键值分布与扩容行为等多种因素。微基准测试虽快速且可重复,但往往过度简化工作负载,无法捕捉真实使用模式。应用级基准测试(如DaCapo、Renaissance)能提供真实使用场景,但运行成本更高、易受波动影响,且主要受非HashMap计算主导,导致映射结构相关的性能变化难以观测。为应对这一挑战,我们提出MapReplay基准测试方法,该方法融合了应用级基准测试的真实性与微基准测试的高效性。MapReplay通过追踪HashMap API使用情况生成可重放工作负载,在精确重建内部映射状态的同时复现相同的操作序列。这使得在真实使用模式下对替代实现方案进行既真实又高效的评估成为可能。将MapReplay应用于DaCapo-Chopin与Renaissance后,所得测试套件MapReplayBench在复现应用级性能趋势的同时,显著减少了实验耗时,并揭示了从完整基准测试中难以获取的性能洞见。