Skip to content

Conversation

@NeedleInAJayStack
Copy link
Member

@NeedleInAJayStack NeedleInAJayStack commented Dec 23, 2025

This introduces benchmarking, and makes significant performance improvements to the package.

Based on the benchmark of a simple, nested Star Wars query, these changes reduce graphql CPU time by nearly 70% (from 1679μs to 510μs).

Benchmark runs

Before:

=====================================================================================================
Baseline 'Current_run'
=====================================================================================================

Host 'JaysLaptop.local' with 11 'arm64' processors with 18 GB memory, running:
Darwin Kernel Version 25.1.0: Mon Oct 20 19:33:36 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6030

==========
Benchmarks
==========

graphql
╒═══════════════════════════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╕
│ Metric                        │        p0 │       p25 │       p50 │       p75 │       p90 │       p99 │      p100 │   Samples │
╞═══════════════════════════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╡
│ Instructions (M) *            │        22 │        22 │        22 │        22 │        22 │        23 │        23 │      1046 │
├───────────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Malloc (total) *              │      1945 │      7135 │      9463 │     12143 │     14671 │     19567 │     22832 │      1046 │
├───────────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Memory (resident peak) (M)    │        20 │        28 │        31 │        33 │        35 │        35 │        35 │      1046 │
├───────────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Throughput (# / s) (#)        │      1399 │      1316 │      1283 │      1235 │      1170 │       968 │       653 │      1046 │
├───────────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Time (total CPU) (μs) *       │      1400 │      1624 │      1679 │      1741 │      1840 │      2345 │      3123 │      1046 │
├───────────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Time (wall clock) (μs) *      │       715 │       760 │       780 │       810 │       855 │      1034 │      1530 │      1046 │
╘═══════════════════════════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╛

After:

Host 'JaysLaptop.local' with 11 'arm64' processors with 18 GB memory, running:
Darwin Kernel Version 25.1.0: Mon Oct 20 19:33:36 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6030

==========
Benchmarks
==========

graphql
╒═══════════════════════════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╤═══════════╕
│ Metric                        │        p0 │       p25 │       p50 │       p75 │       p90 │       p99 │      p100 │   Samples │
╞═══════════════════════════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╪═══════════╡
│ Instructions (K) *            │      5531 │      5636 │      5673 │      5710 │      5747 │      5874 │      7432 │      2455 │
├───────────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Malloc (total) *              │       246 │      1108 │      1480 │      2153 │      2941 │      4379 │      5846 │      2455 │
├───────────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Memory (resident peak) (M)    │        18 │        31 │        35 │        39 │        42 │        44 │        44 │      2455 │
├───────────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Throughput (# / s) (#)        │      4507 │      4119 │      3915 │      3705 │      3461 │      2777 │      1495 │      2455 │
├───────────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Time (total CPU) (μs) *       │       425 │       480 │       510 │       535 │       564 │       784 │      1539 │      2455 │
├───────────────────────────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────┤
│ Time (wall clock) (μs) *      │       222 │       243 │       256 │       270 │       289 │       360 │       669 │      2455 │
╘═══════════════════════════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╧═══════════╛

@NeedleInAJayStack NeedleInAJayStack self-assigned this Dec 23, 2025
This reduces the benchmark `graphql` time by 51%, and malloc calls by 77%
Reduces benchmark `graphql` request time by 5%, and `validateRequest` time by 13%
This improves benchmarked `graphql` time by 5%
Improves benchmarked `graphql` time by 22%
Reduces benchmark `graphql` time by 4%
@NeedleInAJayStack
Copy link
Member Author

Waiting on #172, which should fix the tests

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.

1 participant