Skip to content

sort: Replace malloc and 0 fill with huge reserve & min 0 fill#10975

Open
oech3 wants to merge 1 commit intouutils:mainfrom
oech3:sort-malloc0
Open

sort: Replace malloc and 0 fill with huge reserve & min 0 fill#10975
oech3 wants to merge 1 commit intouutils:mainfrom
oech3:sort-malloc0

Conversation

@oech3
Copy link
Contributor

@oech3 oech3 commented Feb 16, 2026

Found at #10954

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 16, 2026

Merging this PR will not alter performance

✅ 14 untouched benchmarks
⏩ 312 skipped benchmarks1


Comparing oech3:sort-malloc0 (3be05e9) with main (e416bd5)2

Open in CodSpeed

Footnotes

  1. 312 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (298e147) during the generation of this report, so e416bd5 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@oech3 oech3 marked this pull request as ready for review February 16, 2026 12:20
} else if estimated == 1 {
const LINE_LEN_HINT: usize = 32;
estimated = (read.len() / LINE_LEN_HINT).max(1);
const LINE_LEN_HINT: usize = 128;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattsu2020 how did you decide to use 32 for LINE_LEN_HINT in the existing code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can define const MAYBE_LN_CACHE_SIZE: usize for everywhere.

@oech3 oech3 marked this pull request as draft February 16, 2026 13:49
@oech3 oech3 force-pushed the sort-malloc0 branch 4 times, most recently from e875422 to 204214a Compare February 16, 2026 14:37
@oech3
Copy link
Contributor Author

oech3 commented Feb 16, 2026

I think mimalloc benchmark is useful to investigate malloc cost even if we decided to not adopt it.

@github-actions
Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)
Note: The gnu test tests/pr/bounded-memory is now being skipped but was previously passing.

@oech3 oech3 marked this pull request as ready for review February 16, 2026 15:17
if buffer.len() < carry_over.len() {
buffer.resize(carry_over.len() + 10 * 1024, 0);
buffer.resize(carry_over.len(), 0);
let new_len = (carry_over.len() * 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a comment explaining why

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

GeneralBigDecimalParseResult, GlobalSettings, Line, SortMode, numeric_str_cmp::NumInfo,
};

const MAYBE_LN_CACHE_SIZE: usize = 64 * 1024;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does the variable name MAYBE_LN_CACHE_SIZE mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpu's L1 cache size

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

@oech3 oech3 force-pushed the sort-malloc0 branch 3 times, most recently from 3be05e9 to 635e73f Compare February 17, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants