Repository navigation
Greatly improve BigInt decimal formatting and parsing performance - #6137
Merged
Merged
Conversation
Both remain quadratic, but with a much smaller constant. Formatting is 2.5x to 3.9x faster and parsing up to 3.5x faster. Improve tests for decimal parsing and formatting.
This improves many uses of this function, for example division of a BigInt by a word is up to 1.4x faster, ct_divide and ct_modulo up to 1.25x, and decimal formatting of large values 1.3x. FrodoKEM, which uses ::is_lt in its sampling loop, is 3% to 16% faster. Checked with valgrind on x86-64 (Clang and GCC), and also checked Clang's codegen across 17 target architectures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Parsing large decimal strings (>2048 bits) is 3x faster, and reaches almost 4x faster for 4 million bits.
Decimal formatting gets a more or less uniform speedup of 3.5x-4x
The second commit, optimizing the constant time comparison mask generation, also improves other unrelated algorithms including the generic division algorithm and FrodoKEM.