Skip to content

Conversation

@ltratt
Copy link
Contributor

@ltratt ltratt commented Aug 24, 2025

There are few, if any, GC functions that we want to trace directly but at the moment, SWT inserts tracing blocks which (a) slows these functions down in all cases (b) particularly slows them down if tracing is active.

At first I started going through these individually, seeing which end up being outlined before realising that really what I want to do is say "all of the functions in this file should be outlined". I don't believe there's a way to attach such an attribute to a file in LLVM -- or, at least, we don't have the right hooks for it in ykllvm right now -- so this commit simply marks every function in this file as yk_outline. It wouldn't surprise me if, in the future, we come back and unmark one or two functions, but I doubt we'll need or want to do that soon.

Across our benchmark suite this leads to a sizeable performance increase, with many benchmarks improving by around 8-9%.

There are few, if any, GC functions that we want to trace directly but
at the moment, SWT inserts tracing blocks which (a) slows these
functions down in all cases (b) particularly slows them down if tracing
is active.

At first I started going through these individually, seeing which end up
being outlined before realising that really what I want to do is say
"all of the functions in this file should be outlined". I don't believe
there's a way to attach such an attribute to a file in LLVM -- or, at
least, we don't have the right hooks for it in ykllvm right now -- so
this commit simply marks every function in this file as `yk_outline`.
It wouldn't surprise me if, in the future, we come back and unmark one
or two functions, but I doubt we'll need or want to do that soon.

Across our benchmark suite this leads to a sizeable performance
increase, with many benchmarks improving by around 8-9%.
@vext01 vext01 added this pull request to the merge queue Aug 24, 2025
Merged via the queue into ykjit:main with commit e4d4e8b Aug 24, 2025
2 checks passed
@ltratt ltratt deleted the outline_gc branch December 2, 2025 20:12
ltratt added a commit to ltratt/yklua that referenced this pull request Dec 13, 2025
In ykjit#131 I added `yk_outline` to nearly every GC function and got an 8-9%
speedup. Much has changed since then in how we optimise programs, so I
decided to revisit this.

First, as I noted in ykjit#131, I was sloppy and added `yk_outline` to
functions with loops in (i.e. those that could never be inlined). Those
are easily removed. Indeed, _most_ of the static functions in this file
can't be reached (even indirectly) from the outside world, so most of
those can also have `yk_outline` removed.

Really what we have to think about are the `luaC_*` functions. A quick
bit of experimentation suggests that, at least for now, they're best
left outlined.

Overall, this commit has no meaningful performance change that I can
measure.
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.

3 participants