Skip to content

Slightly faster odin implementation#88

Open
BigBoyBarney wants to merge 1 commit intojabbalaci:masterfrom
BigBoyBarney:main
Open

Slightly faster odin implementation#88
BigBoyBarney wants to merge 1 commit intojabbalaci:masterfrom
BigBoyBarney:main

Conversation

@BigBoyBarney
Copy link

This is a slightly faster Odin implementation, around 3% faster on my machine.

@jabbalaci
Copy link
Owner

Which change caused the speedup in your opinion?

@BigBoyBarney
Copy link
Author

BigBoyBarney commented Dec 8, 2025

It's certainly moving cache: [10]int into global memory, as opposed to the stack.

- main :: proc()
- {
-     // fill cache
-     cache: [10]int
+ cache: [10]int
+ main :: proc() {

Theoretically making the procedure contextless should have yielded some performance increase too, since it would mean that 1 less pointer is passed to the procedure. However, it's likely optimised out here because it's so simple and doesn't make a difference (here).


Edit: I checked the assembly and the pointer is passed in the non-contextless case, but it makes virtually no difference in terms of speed on my machine. Maybe because it's just 1 instruction? Still, most maths functions in Odin's core:math are contextless, so it's good practice to do anyway, since we don't need the context.

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