fitzgen / fitzgen/winliner

Profiling: add a "single-global-per-callsite" mode for even lower overhead

Open
#4 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
29
Forks
2
PR merge metrics
No merged PRs in 30d

Description

It occurred to me that for some use-cases, where callsites are highly monomorphic, and especially use-cases where behavior "stabilizes" after a warmup phase, the heuristic of "last callee before stats snapshot wins" might actually work pretty well. It also has the advantage that the instrumentation overhead is about as low as it could be: a single store to a global, with no conditionals/branches that may be mispredicted. So a

```
call_indirect $sig
```

becomes

```
local.tee $temp
local.get $temp
global.set $__winliner_callsite_42_last_callee ;; because no global.tee inst exists, unfortunately
call_indirect $sig
```

and that's it.

Separately, as a heuristic for what to inline, we might want a separate intrinsic or something -- in principle what we want at least for the IC case is to mark generated code as special, and inline everything there. That removes the need for the "number of calls" and "number of calls to this callee" counters in the three-global design.

Might be worth adding and experimenting with when the time comes!

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the existing profiling approach, including the three-global design, the call_indirect instrumentation, and the proposed intrinsic for generated code. Define how a single-global-per-callsite mode would be selected and evaluated, then experiment with its overhead and inlining behavior after warmup.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
compilers, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.