Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
llvm-project
The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
In Java, many number-to-string implementations use NumberFormat. This is abysmally slow if the problem domain doesn't require internationalization, which is the case for machine-readable file formats, such as SVG. When I performance tested JMathTeX for rendering TeX, the bottleneck for converting TeX into SVG elements was JFreeSVG's use of NumberFormat[0]. Replacing NumberFormat with RyuDouble doubled the throughput[1]. (Reusing a StringBuilder for to concatenate strings yielded another doubling.)
For KeenType[2], a fork of the New Typesetting System (and more complete TeX implementation than JMathTeX), I added an SVG generator that converts numbers to string using a StackOverflow answer[3], instead of using Ryu[4]. The performance was even better and the algorithm vastly simpler.
Knuth was right: measure, then optimize.
[0]: https://github.com/jfree/jfreesvg
[1]: https://github.com/jfree/jfreesvg/pull/30
[2]: https://github.com/DaveJarvis/KeenType
[3]: https://stackoverflow.com/a/10554128/59087
[4]: https://github.com/DaveJarvis/KeenType/blob/fef005579021f394...
In Java, many number-to-string implementations use NumberFormat. This is abysmally slow if the problem domain doesn't require internationalization, which is the case for machine-readable file formats, such as SVG. When I performance tested JMathTeX for rendering TeX, the bottleneck for converting TeX into SVG elements was JFreeSVG's use of NumberFormat[0]. Replacing NumberFormat with RyuDouble doubled the throughput[1]. (Reusing a StringBuilder for to concatenate strings yielded another doubling.)
For KeenType[2], a fork of the New Typesetting System (and more complete TeX implementation than JMathTeX), I added an SVG generator that converts numbers to string using a StackOverflow answer[3], instead of using Ryu[4]. The performance was even better and the algorithm vastly simpler.
Knuth was right: measure, then optimize.
[0]: https://github.com/jfree/jfreesvg
[1]: https://github.com/jfree/jfreesvg/pull/30
[2]: https://github.com/DaveJarvis/KeenType
[3]: https://stackoverflow.com/a/10554128/59087
[4]: https://github.com/DaveJarvis/KeenType/blob/fef005579021f394...
LLVM libc's decimal float conversion is based on Ulf Adams' Ryu Printf algorithm (one of the algorithms mentioned in the article). If you're interested in this area, you can look at the code, https://github.com/llvm/llvm-project/blob/main/libc/src/__su... and patches are always welcome :-)
Initial commit, https://reviews.llvm.org/D131023