Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: d95d6a80355e27cd4091e806e21019e4bc557a1e https://github.com/WebKit/WebKit/commit/d95d6a80355e27cd4091e806e21019e4bc557a1e Author: Keita Nonaka <ikonnyak...@gmail.com> Date: 2025-06-12 (Thu, 12 Jun 2025)
Changed paths: M JSTests/stress/math-sum-precise.js M Source/JavaScriptCore/runtime/MathObject.cpp M Source/WTF/wtf/PreciseSum.cpp M Source/WTF/wtf/PreciseSum.h Log Message: ----------- [JSC] Improve Performance of `Math.sumPrecise` for Large Inputs https://bugs.webkit.org/show_bug.cgi?id=293866 Reviewed by Yusuke Suzuki. Math.sumPrecise may be used in scientific calculations, charting, and statistical analysis, where it is crucial to handle large inputs precisely and efficiently. This patch improves performance for large inputs by implementing Radford M. Neal's xsum algorithm using the large superaccumulator[1]. The large superaccumulator is used when the input is an array and its size exceeds PRECISE_SUM_THRESHOLD (1,000); otherwise, the small superaccumulator is used. The original implementation of xsum large superaccumulator is in C [2]; a C++ translation by Keita Nonaka was referenced for integration [3]. This patch also refactors the previous implementation[4] of xsum using the small superaccumulator to align with the xsum large superaccumulator design. TipOfTree Patched Ratio math-sumPrecise-10 2.6139+-0.1125 2.6545+-0.1376 0.0152x slower math-sumPrecise-100 17.9892+-0.0930 18.0620+-0.1747 0.0040x slower math-sumPrecise-1000 172.3968+-1.8629 155.9089+-1.3315 1.1057x faster math-sumPrecise-10000 1709.5876+-4.2845 1530.4218+-5.2034 1.1170x faster [1]: https://arxiv.org/abs/1505.05571 [2]: https://gitlab.com/radfordneal/xsum [3]: https://github.com/Gumichocopengin8/xsum.cpp [4]: https://github.com/WebKit/WebKit/commit/2682d2ab17a40851f7e6bcff35126e810b0646fd * JSTests/stress/math-sum-precise.js: * Source/JavaScriptCore/runtime/MathObject.cpp: (JSC::JSC_DEFINE_HOST_FUNCTION): * Source/WTF/wtf/PreciseSum.cpp: (WTF::Xsum::SmallAccumulator::SmallAccumulator): (WTF::Xsum::SmallAccumulator::addInfNan): (WTF::Xsum::SmallAccumulator::carryPropagate): (WTF::Xsum::SmallAccumulator::add1NoCarry): (WTF::Xsum::SmallAccumulator::incrementWhenValueAdded): (WTF::Xsum::LargeAccumulator::LargeAccumulator): (WTF::Xsum::LargeAccumulator::addLchunkToSmall): (WTF::Xsum::LargeAccumulator::largeAddValueInfNan): (WTF::Xsum::LargeAccumulator::transferToSmall): (WTF::Xsum::XsumSmall::XsumSmall): (WTF::Xsum::XsumSmall::addList): (WTF::Xsum::XsumSmall::add): (WTF::Xsum::XsumSmall::compute): (WTF::Xsum::XsumLarge::XsumLarge): (WTF::Xsum::XsumLarge::addList): (WTF::Xsum::XsumLarge::add): (WTF::Xsum::XsumLarge::compute): (WTF::PreciseSum::PreciseSum): Deleted. (WTF::PreciseSum::addList): Deleted. (WTF::PreciseSum::add): Deleted. (WTF::PreciseSum::compute): Deleted. (WTF::PreciseSum::xsumSmallAddInfNan): Deleted. (WTF::PreciseSum::xsumAdd1NoCarry): Deleted. (WTF::PreciseSum::xsumCarryPropagate): Deleted. (WTF::PreciseSum::incrementWhenValueAdded): Deleted. * Source/WTF/wtf/PreciseSum.h: Canonical link: https://commits.webkit.org/296157@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes