sonic-cpp icon indicating copy to clipboard operation
sonic-cpp copied to clipboard

sonic-cpp的SIMD加速不一定比架构设计、算法优化和微观调优的性能高,可以和LJSON性能对比

Open lengjingzju opened this issue 2 months ago • 2 comments

sonic-cpp解析和序列化干不赢yyjson,大概率也干不赢 LJSON 的复用模式(模式3)

  • LJSON使用复用模式生成可编辑DOM,速度可比yyjson快约100%,内存占用只有yyjson的约50%
  • LJSON的文件流模式支持真流式解析和序列化(边读文件边解析,边序列化边写文件)
  • LJSON使用C99,没有使用手动SIMD等依赖具体CPU架构的优化,Linux-GCC/CLANG 和 Windows-MSVC编译都能支持(最初还运行在平头哥的CSKY-ECOS上)

以下是 Intel i7-1260P& OS: Ubuntu 20.04 (VMWare) 测试结果(第一个测试1000x表示放大1000倍(测试1次), 第2个测试的参数1000表示重复测试1000次),LJSON复用模式解析达到了2.5GB/s的解析速度。

Image

Image

LJSON使用自研数值和字符串转换引擎

  • 浮点 ↔ 字符串转换性能远超标准库算法和小超主流算法(sprintf、grisu2、dragonbox)
  • float64精度设定为16位十进制数字,边界处理追求最短表示而非机械的偶数舍入
Image

lengjingzju avatar Oct 16 '25 01:10 lengjingzju

有时间我们测试学习一下

liuq19 avatar Oct 16 '25 02:10 liuq19

I have a faster floating-point number printing algorithm. It has the same output result as algorithms such as ryu, dragonbox, and schubfach. demo link: https://onlinegdb.com/OPKdOpikG

xjb714 avatar Oct 25 '25 20:10 xjb714