Skip to content

Conversation

@niaow
Copy link
Member

@niaow niaow commented Nov 29, 2025

This fixes a bug where runtime.alloc would not clear the padding from rounding the allocation up to a multiple of the block size. The GC still has to scan this, and this could result in permanent false positives (and therefore memory leaks).

It also handles overflow in the size calculation.

This fixes a bug where runtime.alloc would not clear the padding from rounding the allocation up to a multiple of the block size.
The GC still has to scan this, and this could result in permanent false positives (and therefore memory leaks).

It also handles overflow in the size calculation.
@niaow niaow requested a review from deadprogram November 29, 2025 23:11
@niaow
Copy link
Member Author

niaow commented Nov 29, 2025

Performance impact on the go/format benchmark that was struggling earlier:

                    │  precise.txt  │          precise-fixed.txt           │              boehm.txt              │
                    │    sec/op     │    sec/op     vs base                │   sec/op     vs base                │
Format/array1-10000   44.57m ± 158%   27.77m ± 20%  -37.68% (p=0.000 n=10)   21.01m ± 8%  -52.85% (p=0.000 n=10)

                    │  precise.txt  │           precise-fixed.txt           │               boehm.txt               │
                    │      B/s      │      B/s       vs base                │     B/s       vs base                 │
Format/array1-10000   1.392Mi ± 62%   2.227Mi ± 17%  +59.93% (p=0.000 n=10)   2.942Mi ± 9%  +111.30% (p=0.000 n=10)

Copy link
Member

@deadprogram deadprogram left a comment

Choose a reason for hiding this comment

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

That is one very subtle and difficult bug @niaow great working finding and fixing it! Now merging.

@deadprogram deadprogram merged commit 20e22d4 into tinygo-org:dev Nov 30, 2025
19 checks passed
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.

2 participants