paperbot · PL 论文追踪

全部论文 待读 收藏

P2 TwinString: Preserving String Semantics with Off-Heap Data on the JVM

TwinString:在 JVM 上用堆外数据保持字符串语义
OOPSLA 10(OOPSLA2)2026匹配度 1/10 · 该论文研究 JVM 堆外字符串表示与内存管理,属于运行时系统方向,与用户关注的静态分析、LLM/Agent 改进程序分析、浮点程序分析及贝叶斯程序分析均无直接关联。引用 0 inbox
Júnior Löff, Daniele Bonetta, Walter Binder
crossref: 2026-10-02

AI 速览

一句话:提出 TwinString,将字符串数据置于堆外,同时保持 java.lang.String 语义与 API 兼容。

Java 应用需从文件、数据库、网络等大量摄入文本。现有方案要么物化为堆上 String,带来分配、拷贝、编码和 GC 开销;要么使用低层外部内存 API,需非标准字符串接口并手动管理内存与生命周期。TwinString 将字符串语义与物理存储解耦:数据置于 Java 堆外,但保持标准 String 类型与行为,由 VM 控制并经 GC 管理生命周期,无需自定义字符串类型。作者在 GraalVM Native Image 中实现,并用微基准、真实文本处理及 JDBC、SQLite 负载评估。结果显示其显著降低分配开销,兼容原 String API,并在真实库与 JDBC 负载中将 P99.9 尾延迟最多降低 42.2%。

问题
Java 数据密集型应用在摄入外部文本时,面临堆上 String 的高分配、拷贝与 GC 开销,以及外部内存 API 不安全、需非标准字符串接口和手动生命周期管理之间的取舍。
方法
TwinString 将 String 语义与数据物理位置解耦,把内容存放在 Java 堆外,同时保留 java.lang.String 的类型、行为和 API;其生命周期由 VM 与 GC 管理,并在 GraalVM Native Image 中实现。
评估
在微基准、真实文本处理数据集以及 JDBC/SQLite 数据密集型负载上评估;结果显示其降低分配开销,保持 String API 兼容,并在真实库与 JDBC 负载中把 P99.9 尾延迟最多降低 42.2%。
原文摘要(Abstract)

Strings are the primary mechanism through which Java applications ingest external textual data, including data read from files, databases, network interfaces, and native libraries. In data-intensive applications, such data must either be materialized as heap-allocated java.lang.String objects, incurring allocation, copying, encoding, and garbage-collection costs, or accessed through low-level and unsafe foreign-memory mechanisms that require non-standard string APIs and explicit reasoning about memory management and object lifetimes. Neither option is well suited to high-volume ingestion workloads that require both efficiency and seamless integration with existing Java code. We present TwinString, an alternative representation of java.lang.String that decouples string semantics from the physical placement of its contents. A TwinString stores its data outside the regular Java heap while preserving the standard String type and behavior expected by Java programs and libraries. VM support controls this data and manages its lifetime with garbage collection, allowing foreign textual data to be exposed as ordinary strings without introducing additional custom string types. We implement TwinStrings in GraalVM Native Image and evaluate them across several workloads, including microbenchmarks, text-processing applications over real-world datasets, and data-heavy applications using JDBC and SQLite. The results show that TwinStrings significantly reduce allocation overhead while remaining compatible with the original String API, and reduce P99.9 tail latency by up to 42.2% in realistic library and JDBC workloads by alleviating heap allocation and garbage-collection pressure.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot12135,
  title = {TwinString: Preserving String Semantics with Off-Heap Data on the JVM},
  author = {Júnior Löff and Daniele Bonetta and Walter Binder},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {10},
  number = {OOPSLA2},
  year = {2026},
  doi = {10.1145/3839503}
}