Skip to content

lind-perf: automated microbenchmarking library#812

Open
stupendoussuperpowers wants to merge 14 commits intomainfrom
lind-perf-suite
Open

lind-perf: automated microbenchmarking library#812
stupendoussuperpowers wants to merge 14 commits intomainfrom
lind-perf-suite

Conversation

@stupendoussuperpowers
Copy link
Contributor

@stupendoussuperpowers stupendoussuperpowers commented Feb 23, 2026

Notes on how to review this PR:

  • Start with lind-perf related changes and README. These contain the core logic of how we ensure low-overhead timers.
  • Move to lind-boot/src/perf.rs and lind-boot/src/main.rs since these contain the plumbing required to run and report the benchmarks.
  • RawPOSIX and glibc contain two new benchmark-specific syscalls.
  • QOL changes: benchmarks added in tests/, run_micorbenchmarks.sh added to scripts, make lind-boot-perf added to Makefile
  • Most of the other code changes are just adding in a scoped timer in places we want to

BEFORE MERGE:

  • Needs more testing to ensure the new lind_perf feature does not break existing things.
  • We should likely wait for optimization improvement to be merged into main before merging this to avoid confusing diffs.

Build:

make lind-boot-perf

Run microbenchmarks:

./scripts/run_microbench.sh

Sample output:

--------------------------------------------LIND-BOOT--------------------------------------------
name                                                              calls        total          avg
-------------------------------------------------------------------------------------------------
lind_boot::load_main_module                                           1    111.482ms    111.482ms
lind_boot::invoke_func                                                1    111.282ms    111.282ms


-------------------------------------------LIND-COMMON-------------------------------------------
name                                                              calls        total          avg
-------------------------------------------------------------------------------------------------
lind_common::add_to_linker::make-syscall                        1000000     94.274ms     94.000ns


---------------------------------------------THREE-I---------------------------------------------
name                                                              calls        total          avg
-------------------------------------------------------------------------------------------------
threei::make_syscall                                            1000000     90.815ms     90.000ns


--------------------------------------------RAWPOSIX---------------------------------------------
name                                                              calls        total          avg
-------------------------------------------------------------------------------------------------
rawposix::close_syscall                                         1000000     21.255ms     21.000ns


--------------------------------------------FDTABLES---------------------------------------------
name                                                              calls        total          avg
-------------------------------------------------------------------------------------------------
fdtables::close_virtualfd                                       1000000     14.372ms     14.000ns

@stupendoussuperpowers stupendoussuperpowers changed the title Init: lind-perf lind-perf: automated microbenchmarking library Feb 23, 2026
@stupendoussuperpowers stupendoussuperpowers marked this pull request as ready for review February 23, 2026 18:31
// ---------------------------------------------------------------------------------------------------------------------

// Wrapper for LIBC_SYSCALL which is used to benchmark calls that end up calling the Linux kernel.
int libc_syscall() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also mention in comment about scenarios it might be used?

Comment on lines +29 to 71
// Entry point for a lind_perf enabled build.
//
// When run with --perf flags, it performs the required setup and teardown, along with running
// the inputted wasm benchmark multiple times (once per counter).
#[cfg(feature = "lind_perf")]
{
// Determine which timer to use. --perftsc => Rdtsc, --perf => Clock
let kind = if lindboot_cli.perftsc {
Some(TimerKind::Rdtsc)
} else if lindboot_cli.perf {
Some(TimerKind::Clock)
} else {
None
};

match kind {
Some(k) => {
// Initiate all counters
perf::enabled::init(k);

// Iterate over all counters, enable one at a time, run the wasm module.
for name in perf::enabled::all_counter_names() {
perf::enabled::enable_one(name);

rawposix_start(0);

let _ = execute_wasmtime(lindboot_cli.clone());

rawposix_shutdown();
}

// Print the final report.
perf::enabled::report();

return Ok(());
}
// In case neither --perf flag is set, fall back to default lind-boot behaviour.
None => {}
};
}

// AOT-compile only �~@~T no runtime needed
if lindboot_cli.precompile {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm wrong. My understanding is that performance execution will be different from normal execution in order to enable benchmarking. Is this what those code wants to achieve?

int geteuid_grate(uint64_t);

int geteuid_grate(uint64_t cageid) {
return 10;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this constant? Is it just an arbitrary value?

@stupendoussuperpowers
Copy link
Contributor Author

After the discussion in the meeting today, want to ask about whether I should break this into the following PRs so that this is easier to review:

  1. Adding lind-perf and basic lind-boot plumbing.
  2. Separate PRs for adding benchmark sites for each individual component (i.e. fdtables, rawposix, etc)
  3. Adding tests/scripts

@rennergade
Copy link
Contributor

rennergade commented Feb 23, 2026

A few things

  • dont commit cargo files
  • need to merge main? I think this gets rid of some of the recent changes like SIGPIPE ( I think this may have been already resolved)
  • also removes precompile option?

@rennergade
Copy link
Contributor

Also imports should be feature gated so they dont give more warnings at least

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.

4 participants