Skip to main content
QUICK REVIEW

[论文解读] Interning Ground Terms in XSB

David S. Warren|arXiv (Cornell University)|Jul 17, 2013
Logic, programming, and type systems参考文献 5被引用 5
一句话总结

本文提出了一种在XSB表格化Prolog系统中对基项进行优化实现的方案,通过使用Trie结构的哈希合并技术,减少了表格化过程中的空间和时间开销。在表格化谓词执行过程中对基项(尤其是大列表)进行interning,该方法将50万元素列表查找的cputime从7秒以上降低至0.265秒,同时减少了冗余的项复制并改善了缓存行为。

ABSTRACT

This paper presents an implementation of interning of ground terms in the XSB Tabled Prolog system. This is related to the idea of hash-consing. I describe the concept of interning atoms and discuss the issues around interning ground structured terms, motivating why tabling Prolog systems may change the cost-benefit tradeoffs from those of traditional Prolog systems. I describe the details of the implementation of interning ground terms in the XSB Tabled Prolog System and show some of its performance properties. This implementation achieves the effects of that of Zhou and Have but is tuned for XSB's representations and is arguably simpler.

研究动机与目标

  • 减少由于将基项反复复制到表格和从表格中复制而出而导致的表格化Prolog执行的时间和空间开销。
  • 探究尽管存在哈希计算开销,是否对基项(而不仅仅是原子项)进行interning仍能提升表格化Prolog系统的性能。
  • 设计一种比以往工作更简单、更通用且正交的interning机制,尤其避免对特定表格化实现的依赖。
  • 通过修改项表示和统一算法以支持interned引用,实现在XSB中对基项进行高效的表示共享。
  • 支持未来扩展,如interned项的垃圾回收以及对特定参数的有选择性interning,以在索引和共享之间取得平衡。

提出的方法

  • 使用基于Trie的哈希表来存储基项的唯一表示形式,按其结构和内容进行索引。
  • 修改XSB的项表示方式,将标记指针解释为对interned项的引用,从而通过指针比较实现常数时间的相等性检查。
  • 通过在表格化调用和答案存储过程中自动interning项,将interning机制集成到表格化Prolog机制中,特别针对使用了'as intern'指令的谓词(如split_sorted/4)。
  • 采用自底向上的项构造策略,使用类似WAM的指令,在构建和intern新基项之前检查其子项是否可intern。
  • 对统一算法进行最小改动以处理interned项引用,确保正确性的同时保持性能。
  • 支持intern表的动态扩容,并计划实现interned项的垃圾回收以管理内存增长。

实验结果

研究问题

  • RQ1在表格化Prolog系统中对基项进行interning,是否能相比朴素地复制子目标和答案,同时降低时间复杂度和空间复杂度?
  • RQ2对基项进行interning如何影响表格化Prolog执行中的缓存行为和引用局部性?
  • RQ3在Prolog中对基项进行interning的性能权衡是什么,特别是考虑到纯代码中项创建频率极高?
  • RQ4能否设计一种更简单、更通用的interning机制,使其与表格化正交,并可在不同Prolog系统中复用?
  • RQ5在何种条件下可以安全地应用interning而不损害索引或归结优化?

主要发现

  • 该实现将50万元素列表查找的cputime从7秒以上降低至0.265秒,展示了26倍的性能提升。
  • 该方法仅使用111,464,680字节存储interned项,表格空间仅466,608字节,避免了重复项复制带来的二次方开销。
  • 通过在表格化谓词执行期间interning项,系统避免了对相同基项(如大型列表)的冗余构造和存储。
  • 与Zhou和Have的先前工作相比,该方法更简单、更通用,使用Trie而非哈希表,并避免了复杂的记忆化优化。
  • 该实现支持未来扩展,如interned项的垃圾回收以及对特定参数的选择性interning,以保留索引能力。
  • 通过仅interning基项并确保指针相等性蕴含结构相等性,该方法保持了正确性和高效性。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。