AI 中文总结
该研究推出SciGMark 1.5基准,对比Rust等语言的泛型与专用实现,扩展了符号计算相关测试,揭示泛型编程成本与类型解析时机等因素相关,为泛型性能优化提供依据。
AI 中文摘要
原始SciGMark基准测试对SciMark数值套件进行了调整,以衡量科学计算中泛型编程的成本。在过去的二十年里,泛型已成为主流语言的常规特性,但其实现策略却变得多样化。本文报告了SciGMark 1.5,这是一项针对现代语言中专用和泛型实现的基准研究。该研究有三个目标:第一,考察当前广泛使用的语言中各种泛型实现策略带来的影响;第二,通过添加有限域线性代数、有限域快速傅里叶变换(FFT)以及朴素格罗比纳基(Gröbner basis)计算,将基准测试扩展到符号计算领域;第三,探究原始浮点科学内核在新语言环境中的表现。测量覆盖了Rust、Java、Go和TypeScript的主套件,还针对格罗比纳基基准测试补充了C++和Julia的测量结果。该研究同时记录了代表性的输出工件大小,因为代码生成和运行时打包是泛型编程成本模型的组成部分。结果证实,泛型编程的成本并非抽象本身所固有,而是在很大程度上取决于类型信息的解析时机、算术值的表示方式,以及编译器或运行时能否在内部循环中恢复特定操作。提前特化(monomorphization)通常会使泛型代码在数值测试中接近专用代码;擦除或基于对象的泛型算术可能会带来显著开销,尤其是在算术和分配密集型代码中;运行时特化则处于中间位置,当类型推断和表示选择有利时,它能提供灵活性和良好的稳态性能。
英文摘要
The original SciGMark benchmark adapted the SciMark numerical suite to measure the cost of generic programming in scientific computing. In the twenty years since, generics have become ordinary features of mainstream languages, but their implementation strategies have diversified. This paper reports SciGMark 1.5, a benchmark study of specialized and generic implementations in modern languages. The study has three aims. First, it examines the consequences of the wide variety of generic-realization strategies used in current widely used languages. Second, it extends the benchmark toward symbolic computation by adding finite-field linear algebra, finite-field FFT, and a naïve Gröbner basis computation. Third, it asks how the original floating-point scientific kernels behave in the new language settings. The measurements cover Rust, Java, Go, and TypeScript for the main suite, with additional C++ and Julia measurements for the Gröbner basis benchmark. The study also records representative output artifact sizes, since code generation and runtime packaging are part of the cost model of generic programming. The results confirm that the cost of generic programming is not inherent in abstraction itself, but depends strongly on when type information is resolved, how arithmetic values are represented, and whether the compiler or runtime can recover specific operations in the inner loops. Ahead-of-time monomorphization usually makes generic code close to specialized code in the numerical tests. Erased or objectbased generic arithmetic can introduce substantial overhead, especially in arithmetic- and allocation-intensive code. Runtime specialization occupies an intermediate position, offering flexibility and good steady-state performance when type inference and representation choices are favourable.