Skip to content

dtoa.c: Use an on-stack buffer for small bigints - #13234

Open
jhawthorn wants to merge 11 commits into
ruby:masterfrom
jhawthorn:dtoa_stack
Open

jhawthorn wants to merge 11 commits into
ruby:masterfrom
jhawthorn:dtoa_stack

Conversation

@jhawthorn

@jhawthorn jhawthorn commented May 1, 2025 •

Copy link
Copy Markdown
Member

In #12991 I replaced a spinlock with malloc, which is about the same performance.

I think malloc implementations have gotten better since 1990 when dtoa.c was written, but this can still be a bit of a bottleneck. We seem to mostly be allocating a few small bigints (k <= 2) at a time, so this PR adds a small on-stack buffer we can allocate from without synchronization.

I need to test this a bit more before merging.

Comment thread missing/dtoa.c
}
p5s = &p5s_static[0];
for (;;) {
assert(p5s < &p5s_static[MAX_P5]);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

FIXME: Ran a fuzzer against this and we definitely sometimes exceed MAX_P5

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.

1 participant