Skip to content

Conversation

@scottmarchant
Copy link
Collaborator

@scottmarchant scottmarchant commented Dec 4, 2025

Summary

Ports some benchmarks from NIOPosix to NIOAsyncRuntime to compare performance.

Results

Summary

Jump to EL and back using actor with EL executor: NIOAsyncRuntime About 1.4x slower than NIOPosix
Jump to EL and back using execute and unsafecontinuation: About 1.3x slower
MTELG.scheduleCallback(in::): About 11x slower
MTELG.scheduleTask(in:
:): About 4x slower
MTELG.immediateTasksThroughput: About 5x slower

Note that we expect NIOPosix to be faster due to usage of higher-level constructs

Full Results

==================
NIOPosixBenchmarks
==================

Jump to EL and back using actor with EL executor
╒══════════════════════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╕
│ Metric                   │        p0 │       p25 │       p50 │       p75 │       p90 │       p99 │      p100 │   Samples │
╞══════════════════════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╡
│ Context switches         │      1995 │      1999 │      2000 │      2002 │      2003 │      2014 │      2019 │       164 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Malloc (total) *         │         0 │         0 │         0 │         0 │         0 │         0 │         0 │       164 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Time (wall clock) (ns) * │      4257 │      5833 │      6029 │      6169 │      6279 │      6390 │      6743 │       164 │
╘══════════════════════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╛

Jump to EL and back using execute and unsafecontinuation
╒══════════════════════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╕
│ Metric                   │        p0 │       p25 │       p50 │       p75 │       p90 │       p99 │      p100 │   Samples │
╞══════════════════════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╡
│ Context switches         │      1995 │      1998 │      1999 │      2001 │      2002 │      2006 │      2009 │       166 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Malloc (total) *         │         1 │         1 │         1 │         1 │         1 │         1 │         1 │       166 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Time (wall clock) (ns) * │      4741 │      5784 │      5935 │      6033 │      6148 │      6615 │      6628 │       166 │
╘══════════════════════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╛

MTELG.scheduleCallback(in:_:)
╒══════════════════════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╕
│ Metric                   │        p0 │       p25 │       p50 │       p75 │       p90 │       p99 │      p100 │   Samples │
╞══════════════════════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╡
│ Context switches (K)     │        68 │        70 │        70 │        72 │        73 │        73 │        73 │         5 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Malloc (total) *         │         0 │         0 │         0 │         0 │         0 │         0 │         0 │         5 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Time (wall clock) (ns) * │       296 │       299 │       308 │       320 │       344 │       344 │       344 │         5 │
╘══════════════════════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╛

MTELG.scheduleTask(in:_:)
╒══════════════════════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╕
│ Metric                   │        p0 │       p25 │       p50 │       p75 │       p90 │       p99 │      p100 │   Samples │
╞══════════════════════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╡
│ Context switches (K)     │       163 │       164 │       164 │       177 │       177 │       177 │       177 │         5 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Malloc (total) *         │         4 │         4 │         4 │         4 │         4 │         4 │         4 │         5 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Time (wall clock) (ns) * │       602 │       623 │       628 │       653 │       695 │       695 │       695 │         5 │

MTELG.immediateTasksThroughput
╒══════════════════════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╕
│ Metric                   │        p0 │       p25 │       p50 │       p75 │       p90 │       p99 │      p100 │   Samples │
╞══════════════════════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╡
│ Context switches (K)     │        16 │        17 │        18 │        18 │        20 │        20 │        20 │         5 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Malloc (total) *         │         0 │         0 │         0 │         0 │         0 │         0 │         0 │         5 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Time (wall clock) (ns) * │       104 │       107 │       108 │       108 │       112 │       112 │       112 │         5 │
╘══════════════════════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╛

=========================
NIOAsyncRuntimeBenchmarks
=========================

Jump to EL and back using actor with EL executor
╒══════════════════════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╕
│ Metric                   │        p0 │       p25 │       p50 │       p75 │       p90 │       p99 │      p100 │   Samples │
╞══════════════════════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╡
│ Context switches         │      1076 │      1373 │      1482 │      1521 │      1546 │      1584 │      1610 │       137 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Malloc (total) *         │        26 │        33 │        35 │        37 │        39 │        44 │        44 │       137 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Time (wall clock) (ns) * │      6142 │      7037 │      7270 │      7406 │      7528 │      8937 │     10218 │       137 │
╘══════════════════════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╛

Jump to EL and back using execute and unsafecontinuation
╒══════════════════════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╕
│ Metric                   │        p0 │       p25 │       p50 │       p75 │       p90 │       p99 │      p100 │   Samples │
╞══════════════════════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╡
│ Context switches         │      1107 │      1337 │      1456 │      1512 │      1540 │      1569 │      1627 │       139 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Malloc (total) *         │        25 │        32 │        34 │        36 │        38 │        42 │        44 │       139 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Time (wall clock) (ns) * │      6209 │      6906 │      7098 │      7262 │      7406 │      8131 │      8800 │       139 │
╘══════════════════════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╛

MTELG.scheduleCallback(in:_:)
╒══════════════════════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╕
│ Metric                   │        p0 │       p25 │       p50 │       p75 │       p90 │       p99 │      p100 │   Samples │
╞══════════════════════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╡
│ Context switches (K)     │       443 │       476 │       493 │       505 │       521 │       521 │       521 │         5 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Malloc (total) *         │        30 │        30 │        31 │        31 │        31 │        31 │        31 │         5 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Time (wall clock) (ns) * │      3467 │      3620 │      3704 │      3781 │      3884 │      3884 │      3884 │         5 │
╘══════════════════════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╛

MTELG.scheduleTask(in:_:)
╒══════════════════════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╕
│ Metric                   │        p0 │       p25 │       p50 │       p75 │       p90 │       p99 │      p100 │   Samples │
╞══════════════════════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╡
│ Context switches (K)     │       347 │       371 │       374 │       393 │       412 │       412 │       412 │         5 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Malloc (total) *         │        21 │        21 │        21 │        21 │        21 │        21 │        21 │         5 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Time (wall clock) (ns) * │      2445 │      2506 │      2590 │      2628 │      2672 │      2672 │      2672 │         5 │
╘══════════════════════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╛

MTELG.immediateTasksThroughput
╒══════════════════════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╕
│ Metric                   │        p0 │       p25 │       p50 │       p75 │       p90 │       p99 │      p100 │   Samples │
╞══════════════════════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╡
│ Context switches (K)     │         6 │        28 │        34 │        41 │        45 │        45 │        45 │         5 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Malloc (total) *         │         5 │         5 │         5 │         5 │         7 │         7 │         7 │         5 │
├──────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Time (wall clock) (ns) * │       512 │       543 │       549 │       574 │       574 │       574 │       574 │         5 │
╘══════════════════════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╛

@scottmarchant scottmarchant force-pushed the test/swiftBenchmarks branch 2 times, most recently from eb680ac to 548a561 Compare December 5, 2025 00:19
@scottmarchant scottmarchant self-assigned this Dec 5, 2025
@scottmarchant scottmarchant marked this pull request as ready for review December 5, 2025 01:38
@scottmarchant scottmarchant merged commit cc18bbf into main Dec 5, 2025
23 checks passed
@scottmarchant scottmarchant deleted the test/swiftBenchmarks branch December 5, 2025 16:55
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