Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

Conversation

@steeve
Copy link
Contributor

@steeve steeve commented Nov 20, 2025

In our case (lots of C headers), codegen went from ~90s to less than 1s.

@Vexu
Copy link
Member

Vexu commented Nov 20, 2025

Is SmpAllocator suitable for a single threaded application? In Aro we link libc and use raw_c_allocator in release mode.

@steeve
Copy link
Contributor Author

steeve commented Nov 20, 2025

My understanding was that it seeks to replace std.heap.GeneralPurposeAllocator but also happens to be somewhat faster than std.heap.c_allocator, without the need for libc, too.

According to https://ziglang.org/documentation/0.15.2/#toc-Choosing-an-Allocator

If you are compiling in ReleaseFast mode, std.heap.smp_allocator is a solid choice for a general purpose allocator.

See also: ziglang/zig#22808

@steeve steeve force-pushed the steeve/smp_allocator branch 2 times, most recently from 128ad0d to 82ecab6 Compare November 20, 2025 20:17
@Vexu
Copy link
Member

Vexu commented Nov 20, 2025

Yes but it also explicitly asserts that it is not used in single threaded mode. I think it would be stick to the C allocator for now.

@steeve
Copy link
Contributor Author

steeve commented Nov 21, 2025

@Vexu so force linking with -lc for the translate-c binary ? i'm good with that if you are

also, does translate-c have to be built in single threaded mode ?

@Vexu
Copy link
Member

Vexu commented Nov 21, 2025

so force linking with -lc for the translate-c binary ? i'm good with that if you are

No need to force it, just link libc in release mode and use raw_c_allocator if libc is linked.

also, does translate-c have to be built in single threaded mode ?

It doesn't have to but it should since it is single threaded.

@steeve steeve force-pushed the steeve/smp_allocator branch from 82ecab6 to df54a68 Compare November 22, 2025 21:07
@steeve steeve changed the title Use SmpAllocator when not in Debug Use raw_c_allocator when not in Debug Nov 22, 2025
In our case (lots of C headers), codegen went from ~90s to less than 1s.
@steeve steeve force-pushed the steeve/smp_allocator branch from df54a68 to 78f4666 Compare November 22, 2025 21:08
@Vexu Vexu enabled auto-merge (squash) November 22, 2025 23:35
@Vexu Vexu merged commit 5fde64e into ziglang:main Nov 23, 2025
3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants