Tagging of generic dynamic values is important in symbolic-computation and dynamic-language systems, but the trade-offs change as machine architectures and workloads evolve. In particular, old folklore about boxed values, immediate values, and type tags must be recalibrated from time to time. We revisit the performance of badged object headers, low-bit tagging, and two NaN-boxing layouts on a range of platforms in use today, including AArch64 and x86-64 architectures from different manufacturers. The experiments isolate two distinct effects: the cost avoided by not heap-allocating common scalar values, and the cost avoided by obtaining tag information from the value word rather than by performing a heap read. The results show that several local bit operations are often cheaper than opening a heap object to obtain a tag or small value. Low-bit tagging remains the simplest and usually fastest choice for mostly symbolic workloads, while NaN-boxing is close in access cost and avoids the time and space of heap allocation for ordinary floating-point values.
翻译:对泛型动态值进行标记在符号计算和动态语言系统中至关重要,但随着机器架构和工作负载的演进,其间的权衡也在不断变化。特别是关于装箱值、立即值和类型标签的旧有经验法则需要时常重新校准。我们重新审视了带标签对象头、低位标记以及两种NaN-boxing布局在不同制造商当前使用的AArch64和x86-64等平台上的性能表现。实验隔离了两种不同效应:避免堆分配常见标量值所节省的成本,以及通过值字获取标签信息而非执行堆读取所节省的成本。结果表明,多次局部位操作的代价通常低于打开堆对象以获取标签或小值的代价。低位标记在符号计算密集型工作负载中仍是最简单且通常最快的选择,而NaN-boxing在访问成本上与之接近,且避免了普通浮点值的堆分配时间和空间开销。