Lune

PLDI2026顶会

Persistent Iterators with Value Semantics

Yihe Li, Gregory J. Duck

摘要

Iterators are a fundamental programming abstraction for traversing and modifying elements in containers in mainstream imperative languages such as C++. Iterators provide a uniform access mechanism that hides low-level implementation details of the underlying data structure. However, iterators over mutable containers suffer from well-known hazards including invalidation, aliasing, data races, and subtle side effects. Immutable data structures, as used in functional programming languages, avoid the pitfalls of mutation but rely on a very different programming model based on recursion and higher-order combinators (map, foldl, traverse, etc.) rather than iteration. However, these combinators are not always well-suited to expressing certain algorithms, and recursion can expose implementation details of the underlying data structure. In this paper, we propose persistent iterators-a new abstraction that reconciles the familiar iterator-based programming style of imperative languages with the semantics of persistent data structures. A persistent iterator snapshots the version of its underlying container at creation, ensuring safety against invalidation and aliasing. Iterator operations (++, erase, etc.) operate on the iterator-local copy of the container, giving true value semantics: variables can be rebound to new persistent values while previous versions remain accessible. We implement our approach in the form of LibFpp-a C++ container library providing persistent vectors, maps, sets, strings, and other abstractions as persistent counterparts to the Standard Template Library (STL). Our evaluation shows that LibFpp retains the expressiveness of iterator-based programming, eliminates iterator-invalidation, and achieves asymptotic complexities comparable to STL implementations-albeit with the higher constant-factor overheads of persistence. Our design targets use cases where persistence and safety are desired, while allowing developers to retain familiar iterator-based programming patterns.

问 Lune

几分钟读透这篇 Paper,不用再花一下午。

Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。

可以从这些问题问起

Lune 可以查阅

全文 · 相关的 Paper

获取答案

免费开始,无需绑卡

相关 Paper

  1. FliT: a library for simple and efficient persistent algorithmsYuanhao Wei, Naama Ben-David, Michal Friedman, Guy E. Blelloch 等PPoPP 2022 · 19 次引用
  2. Concurrent deferred reference counting with constant-time overheadDaniel Anderson, Guy E. Blelloch, Yuanhao WeiPLDI 2021 · 26 次引用
  3. Pronto: Easy and Fast Persistence for Volatile Data StructuresAmir Saman Memaripour, Joseph Izraelevitz, Steven SwansonASPLOS 2020 · 55 次引用
  4. Compositionality and Observational Refinement for Linearizability with CrashesArthur Oliveira Vale, Zhongye Wang, Yixuan Chen, Peixin You 等OOPSLA 2024 · 1 次引用
  5. The Path to Durable LinearizabilityEmanuele D'Osualdo, Azalea Raad, Viktor VafeiadisPOPL 2023 · 6 次引用
黄昏的海面,两侧是细线勾勒的悬崖