Stream: show and tell

Topic: ✔ thoughts on roc for scripting


view this post on Zulip removewingman (Nov 19 2026 at 22:46):

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)

arabic.roc

view this post on Zulip Luke Boswell (Nov 19 2026 at 22:57):

So there's a difference in wall time when running using #! compared to building and running using roc cli?

view this post on Zulip removewingman (Nov 19 2026 at 23:11):

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.

view this post on Zulip Luke Boswell (Nov 19 2026 at 23:12):

Can you share the code in a gist, I am having trouble downloading that file in zulip for some reason

view this post on Zulip Luke Boswell (Nov 19 2026 at 23:12):

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.

view this post on Zulip Luke Boswell (Nov 19 2026 at 23:13):

I am thinking maybe there is something going on here with the platform, or maybe a bug in the dev backend

view this post on Zulip Luke Boswell (Nov 19 2026 at 23:13):

Also what OS/arch are you running?

view this post on Zulip Luke Boswell (Nov 19 2026 at 23:15):

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

view this post on Zulip removewingman (Nov 19 2026 at 23:20):

https://zigbin.io/3785b1

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

view this post on Zulip Luke Boswell (Nov 20 2026 at 00:32):

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.

view this post on Zulip Luke Boswell (Nov 20 2026 at 00:33):

I'll switch over to my linux machine to investigate there too

view this post on Zulip Luke Boswell (Nov 20 2026 at 00:53):

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

view this post on Zulip Luke Boswell (Nov 20 2026 at 00:54):

Building the host in ReleaseFast drops it from 11,600ms down to 120ms

view this post on Zulip Luke Boswell (Nov 20 2026 at 10:28):

@removewingman curious if that helped or resolved your issue or maybe we keep looking?

view this post on Zulip removewingman (Nov 20 2026 at 11:47):

This resolves it, thank you.

view this post on Zulip Notification Bot (Nov 20 2026 at 12:07):

Steve Howell has marked this topic as resolved.


Last updated: Nov 26 2026 at 20:35 UTC