[opt](expr) Speed up double serialization for CSV output - #65943
Draft
Mryange wants to merge 1 commit into
Draft
Conversation
### What problem does this PR solve? Issue Number: close apache#27329 Problem Summary: CSV OUTFILE spends substantial CPU time converting floating-point values to strings. The serialization path also creates a temporary std::string for every FLOAT and DOUBLE value. Use fmt shortest-roundtrip formatting and write the formatted value directly to BufferWritable to reduce conversion and allocation overhead. ### Release note FLOAT and DOUBLE string serialization now uses the shortest round-trip representation. ### Check List (For Author) - Test: Manual test - RELEASE benchmark build and focused FmtDoubleToString benchmark - 1 million row CSV OUTFILE comparison - Behavior changed: Yes. Finite FLOAT and DOUBLE values use shortest round-trip string formatting; NaN and Infinity spelling is unchanged. - Does this need documentation: No.
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
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.
What problem does this PR solve?
CSV OUTFILE spends substantial CPU time converting FLOAT and DOUBLE values to strings.
Root cause: the CSV serialization path creates a temporary
std::stringfor every floating-point value, while the formatter generates a fixed number of significant digits instead of using fmt's faster shortest-roundtrip path.This change writes formatted values directly to
BufferWritableand uses shortest-roundtrip formatting for finite FLOAT and DOUBLE values. In the 1 million row CSV test, the average export time decreased from 14.155 seconds to 8.951 seconds. The focused DOUBLE formatting benchmark improved from 91.656 ns/value to 37.827 ns/value.Release note
FLOAT and DOUBLE string serialization now uses the shortest round-trip representation. NaN and Infinity spelling is unchanged.
Check List (For Author)
Test
Behavior changed:
Does this need documentation?
Check List (For Reviewer who merge this PR)