As a quick sidenode, the performance of this script is atrocious:
time -p ./scripts/arabic.roc
real 56.32
user 55.45
sys 0.49
Compiling and running together is only 6 seconds:
real 6.15
user 6.30
sys 0.33
running (0.03 seconds)
So there's a difference in wall time when running using #! compared to building and running using roc cli?
Luke Boswell said:
So there's a difference in wall time when running using #! compared to building and running using roc cli?
Yes, this is 6 seconds:
roc build --output=./main scripts/arabic.roc --opt=speed --no-cache
./main
these are both around 60 seconds:
roc run scripts/arabic.roc
./scripts/arabic.roc
For a simple script, this is a bit slow, idk why it is so slow tho.
Can you share the code in a gist, I am having trouble downloading that file in zulip for some reason
On my machine there using the 18-11 nightly I cant get any scripts that take more than 1s to build and run in various permutations, but I thats just using a roc test platform.
I am thinking maybe there is something going on here with the platform, or maybe a bug in the dev backend
Also what OS/arch are you running?
The main different between the two commands you shared is the first uses the LLVM backend, the second uses the dev backend, the other is the first uses LSS or specializes the second is using boxy or basically --specialize=no
Platform: https://codeberg.org/removewingman/restricted-roc (no releases yet, I changed git repo)
OS: Alpine Linux (musl), x86_64, x64v1musl
this is only 6 seconds, so it is because of the backend, good to know:
time -p roc run --opt=speed scripts/arabic.roc
real 5.41
user 5.22
sys 0.29
I can't repro on my machine, it takes 60ms to run using --opt=dev for me using your code ported to the echo platform; if I port your restricted platform to macos I get no more than 400ms to build and run in any configuration.
I'll switch over to my linux machine to investigate there too
I found the issue I think. I suspect your restriced-roc platform's allocator is unwinding the stack from Zig's SafeAllocator, in dev mode Roc's allocator caller is in shared-memory mapped outside Zig's known ELF modules so apparently this causes Zig to clear the cache and rescan modules. This script is allocating and freeing many heap allocated strings so this stacks up exponentially.
If I build the host in Debug mode I see 99.9% of the cycles in SafeAllocator.captureStackTrace
Building the host in ReleaseFast drops it from 11,600ms down to 120ms
@removewingman curious if that helped or resolved your issue or maybe we keep looking?
This resolves it, thank you.
Steve Howell has marked this topic as resolved.
Last updated: Nov 26 2026 at 20:35 UTC