Skip to content

userver: optimize async-db handler#819

Merged
MDA2AV merged 2 commits into
MDA2AV:mainfrom
botanegg:userver-benchmarks
Jun 6, 2026
Merged

userver: optimize async-db handler#819
MDA2AV merged 2 commits into
MDA2AV:mainfrom
botanegg:userver-benchmarks

Conversation

@botanegg
Copy link
Copy Markdown
Contributor

@botanegg botanegg commented Jun 6, 2026

Description


PR Commands — comment on this PR to trigger (requires collaborator approval):

Command Description
/benchmark -f <framework> Run all benchmark tests
/benchmark -f <framework> -t <test> Run a specific test
/benchmark -f <framework> --save Run and save results (updates leaderboard on merge)

Always specify -f <framework>. Results are automatically compared against the current leaderboard.


Run benchmarks locally

You can validate and benchmark your framework locally with the lite script — no CPU pinning, fixed connection counts, all load generators run in Docker.

./scripts/validate.sh <framework>
./scripts/benchmark-lite.sh <framework> baseline
./scripts/benchmark-lite.sh --load-threads 4 <framework>

Requirements: Docker Engine on Linux. Load generators (gcannon, h2load, h2load-h3, wrk, ghz) are built as self-contained Docker images on first run.

@botanegg
Copy link
Copy Markdown
Contributor Author

botanegg commented Jun 6, 2026

/benchmark -f userver -t async-db --save

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

👋 /benchmark request received. A collaborator will review and approve the run.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

⚠️ /benchmark --save cannot start: main has diverged and cannot be auto-merged into this branch. Please merge or rebase main manually, push, and re-run /benchmark --save.

@botanegg botanegg force-pushed the userver-benchmarks branch from c43cddd to 24052d2 Compare June 6, 2026 14:57
@botanegg
Copy link
Copy Markdown
Contributor Author

botanegg commented Jun 6, 2026

/benchmark -f userver -t async-db --save

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

👋 /benchmark request received. A collaborator will review and approve the run.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

Benchmark Results

Framework: userver | Test: async-db

Test Conn RPS CPU Mem Δ RPS Δ Mem
async-db 1024 245,022 5755.4% 343MiB NEW NEW
Full log
[info] available CPUs: 128
[info] framework: userver (userver, C++)
[info] subscribed tests: baseline,pipelined,limited-conn,json,json-comp,upload,api-4,api-16,static,async-db
[info] building image: httparena-userver
#0 building with "default" instance using docker driver

#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 667B done
#1 DONE 0.0s

#2 [internal] load metadata for ghcr.io/userver-framework/ubuntu-24.04-userver:v3.0
#2 DONE 0.6s

#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s

#4 [builder 1/4] FROM ghcr.io/userver-framework/ubuntu-24.04-userver:v3.0@sha256:3477357e5d6b874d69676b38d084dc153097c9d7a85f09fb5b059427dcfee990
#4 resolve ghcr.io/userver-framework/ubuntu-24.04-userver:v3.0@sha256:3477357e5d6b874d69676b38d084dc153097c9d7a85f09fb5b059427dcfee990 0.0s done
#4 DONE 0.0s

#5 [internal] load build context
#5 transferring context: 2.44kB done
#5 DONE 0.0s

#6 [runner 2/4] COPY --from=builder /src/configs/config-vars.httparena.yaml ./configs/config_vars.yaml
#6 CACHED

#7 [builder 4/4] RUN mkdir build && cd build &&     cmake -DCMAKE_BUILD_TYPE=Release           -DCMAKE_CXX_FLAGS="-march=native"           -DCMAKE_C_FLAGS="-march=native" .. &&     cmake --build . -j $(nproc)
#7 CACHED

#8 [runner 3/4] COPY --from=builder /src/configs/static_config.yaml ./configs/
#8 CACHED

#9 [builder 2/4] WORKDIR /src
#9 CACHED

#10 [builder 3/4] COPY userver_benchmark/ ./
#10 CACHED

#11 [runner 1/4] WORKDIR /app
#11 CACHED

#12 [runner 4/4] COPY --from=builder /src/build/userver_httparena ./
#12 CACHED

#13 exporting to image
#13 exporting layers done
#13 exporting manifest sha256:54cc2b1e4698ee2ba1fed59b6f02b0d8f9ad16423dab22480ad10174775ed3dc done
#13 exporting config sha256:7e2bc76f6e34733390b2f6e1d170d011b0af004ec155c698bca8430f2b90d6b5 done
#13 exporting attestation manifest sha256:89ece6c65f3b9f570d1f839ab1fa741d0afd096fbc1e96b23dd669f8aac495d6 0.0s done
#13 exporting manifest list sha256:3f8fdd5f8d11686fe2b61effdcd6522f7472b5338a169d83f250b5e05d63f54b
#13 exporting manifest list sha256:3f8fdd5f8d11686fe2b61effdcd6522f7472b5338a169d83f250b5e05d63f54b 0.0s done
#13 naming to docker.io/library/httparena-userver:latest done
#13 unpacking to docker.io/library/httparena-userver:latest 0.0s done
#13 DONE 0.2s

 �[33m1 warning found (use docker --debug to expand):
�[0m - JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals (line 19)
[info] tuning host for benchmark runs
[info] CPU governor → performance
[info] setting kernel socket limits
[info] setting UDP buffer sizes for QUIC
[info] setting loopback MTU to 1500 (realistic Ethernet)
[info] restarting docker daemon
[info] dropping kernel caches
[info] starting postgres sidecar
[info] postgres ready (seeded)

==============================================
=== userver / async-db / 1024c (tool=gcannon) ===
==============================================
[info] waiting for server...
[info] server ready

[run 1/3]
gcannon v0.5.3
  Target:    localhost:8080/
  Threads:   64
  Conns:     1024 (16/thread)
  Pipeline:  1
  Req/conn:  25
  Templates: 5
  Expected:  200
  Duration:  10s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency   2.11ms    778us   2.61ms   34.80ms   79.80ms

  4478985 requests in 10.00s, 4478989 responses
  Throughput: 447.82K req/s
  Bandwidth:  545.37MB/s
  Status codes: 2xx=1275326, 3xx=0, 4xx=0, 5xx=3203663
  Latency samples: 4478979 / 4478989 responses (100.0%)
  Reconnects: 178950
  Per-template: 894910,895993,896284,896534,895258
  Per-template-ok: 254271,255339,255011,255309,255395

  WARNING: 3203663/4478989 responses (71.5%) had unexpected status (expected 2xx)
[info] CPU 6319.4% | Mem 379MiB

[run 2/3]
gcannon v0.5.3
  Target:    localhost:8080/
  Threads:   64
  Conns:     1024 (16/thread)
  Pipeline:  1
  Req/conn:  25
  Templates: 5
  Expected:  200
  Duration:  10s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency   3.63ms   3.06ms   6.29ms   11.50ms   17.30ms

  2426930 requests in 10.00s, 2426932 responses
  Throughput: 242.64K req/s
  Bandwidth:  935.27MB/s
  Status codes: 2xx=2426583, 3xx=0, 4xx=0, 5xx=349
  Latency samples: 2426932 / 2426932 responses (100.0%)
  Reconnects: 97008
  Per-template: 484004,485595,486662,486274,484397
  Per-template-ok: 483939,485530,486592,486189,484333

  WARNING: 349/2426932 responses (0.0%) had unexpected status (expected 2xx)
[info] CPU 5756.6% | Mem 346MiB

[run 3/3]
gcannon v0.5.3
  Target:    localhost:8080/
  Threads:   64
  Conns:     1024 (16/thread)
  Pipeline:  1
  Req/conn:  25
  Templates: 5
  Expected:  200
  Duration:  10s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency   3.52ms   3.02ms   5.99ms   10.90ms   16.70ms

  2450452 requests in 10.00s, 2450452 responses
  Throughput: 244.99K req/s
  Bandwidth:  944.63MB/s
  Status codes: 2xx=2450224, 3xx=0, 4xx=0, 5xx=228
  Latency samples: 2450447 / 2450452 responses (100.0%)
  Reconnects: 97915
  Per-template: 488532,490022,491309,491330,489254
  Per-template-ok: 488484,489974,491262,491284,489215

  WARNING: 228/2450452 responses (0.0%) had unexpected status (expected 2xx)
[info] CPU 5755.4% | Mem 343MiB

=== Best: 245022 req/s (CPU: 5755.4%, Mem: 343MiB) ===
[info] input BW: 16.36MB/s (avg template: 70 bytes)
[info] saved results/async-db/1024/userver.json
httparena-bench-userver
httparena-bench-userver
[info] rebuilding site/data/*.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/frameworks.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/async-db-1024.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/current.json
[info] done
httparena-postgres
[info] restoring loopback MTU to 65536

@botanegg botanegg force-pushed the userver-benchmarks branch from 24052d2 to bbc2c92 Compare June 6, 2026 16:56
@botanegg
Copy link
Copy Markdown
Contributor Author

botanegg commented Jun 6, 2026

/benchmark -f userver --save

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

👋 /benchmark request received. A collaborator will review and approve the run.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

⚠️ /benchmark --save cannot start: main has diverged and cannot be auto-merged into this branch. Please merge or rebase main manually, push, and re-run /benchmark --save.

@botanegg botanegg force-pushed the userver-benchmarks branch from bbc2c92 to 8921c07 Compare June 6, 2026 17:12
@botanegg
Copy link
Copy Markdown
Contributor Author

botanegg commented Jun 6, 2026

/benchmark -f userver --save

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

👋 /benchmark request received. A collaborator will review and approve the run.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 6, 2026

Benchmark Results

Framework: userver | Test: all tests

Test Conn RPS CPU Mem Δ RPS Δ Mem
baseline 512 882,230 6417.0% 220MiB +46.4% +10.6%
baseline 4096 1,053,894 6401.3% 411MiB +7.7% -7.6%
pipelined 512 1,401,012 6699.8% 264MiB -3.4% +1.1%
pipelined 4096 1,340,775 6741.3% 879MiB ~0% -2.1%
limited-conn 512 736,506 6086.3% 246MiB +5.0% +2.5%
limited-conn 4096 886,892 6261.2% 603MiB +4.3% +4.3%
json 4096 824,264 6336.2% 532MiB NEW NEW
json-comp 512 495,502 6541.9% 248MiB NEW NEW
json-comp 4096 495,304 6370.6% 556MiB NEW NEW
json-comp 16384 485,067 6493.6% 1.5GiB NEW NEW
upload 32 704 3222.5% 1.1GiB NEW NEW
upload 256 638 6507.4% 3.9GiB NEW NEW
api-4 256 59,270 403.6% 203MiB NEW NEW
api-16 1024 137,828 1779.9% 373MiB NEW NEW
static 1024 162,632 6483.9% 432MiB -1.6% -1.4%
static 4096 184,559 6428.2% 930MiB -2.1% -0.1%
static 6800 195,761 6559.4% 1.4GiB +0.8% +7.7%
async-db 1024 236,485 5559.7% 300MiB NEW NEW
Full log
[info] CPU 6428.2% | Mem 930MiB

[run 2/3]
Running 5s test @ http://localhost:8080
  64 threads and 4096 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    22.30ms   10.11ms  95.29ms   67.60%
    Req/Sec     2.89k   388.47    15.07k    97.55%
  938303 requests in 5.10s, 55.74GB read
Requests/sec: 183933.41
Transfer/sec:     10.93GB
[info] CPU 6533.1% | Mem 942MiB

[run 3/3]
Running 5s test @ http://localhost:8080
  64 threads and 4096 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    22.39ms   10.68ms 136.89ms   69.90%
    Req/Sec     2.90k   371.59    15.98k    97.39%
  939536 requests in 5.10s, 55.81GB read
Requests/sec: 184219.86
Transfer/sec:     10.94GB
[info] CPU 6444.0% | Mem 945MiB

=== Best: 184559 req/s (CPU: 6428.2%, Mem: 930MiB) ===
[info] saved results/static/4096/userver.json
httparena-bench-userver
httparena-bench-userver

==============================================
=== userver / static / 6800c (tool=wrk) ===
==============================================
[info] waiting for server...
[info] server ready

[run 1/3]
Running 5s test @ http://localhost:8080
  64 threads and 6800 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    36.06ms   21.38ms 279.19ms   75.41%
    Req/Sec     3.07k   327.59     8.90k    94.72%
  993702 requests in 5.10s, 59.04GB read
Requests/sec: 194853.08
Transfer/sec:     11.58GB
[info] CPU 6452.1% | Mem 1.5GiB

[run 2/3]
Running 5s test @ http://localhost:8080
  64 threads and 6800 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    35.83ms   21.28ms 253.97ms   74.94%
    Req/Sec     3.08k   435.56    11.56k    97.08%
  998477 requests in 5.10s, 59.31GB read
Requests/sec: 195761.42
Transfer/sec:     11.63GB
[info] CPU 6559.4% | Mem 1.4GiB

[run 3/3]
Running 5s test @ http://localhost:8080
  64 threads and 6800 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    36.42ms   22.53ms 248.77ms   75.61%
    Req/Sec     3.06k   389.44    12.13k    96.47%
  991702 requests in 5.10s, 58.91GB read
Requests/sec: 194450.80
Transfer/sec:     11.55GB
[info] CPU 6463.2% | Mem 1.5GiB

=== Best: 195761 req/s (CPU: 6559.4%, Mem: 1.4GiB) ===
[info] saved results/static/6800/userver.json
httparena-bench-userver
httparena-bench-userver

==============================================
=== userver / async-db / 1024c (tool=gcannon) ===
==============================================
[info] waiting for server...
[info] server ready

[run 1/3]
gcannon v0.5.3
  Target:    localhost:8080/
  Threads:   64
  Conns:     1024 (16/thread)
  Pipeline:  1
  Req/conn:  25
  Templates: 5
  Expected:  200
  Duration:  10s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency   4.03ms   3.56ms   6.76ms   11.50ms   16.90ms

  2213832 requests in 10.00s, 2213834 responses
  Throughput: 221.33K req/s
  Bandwidth:  853.71MB/s
  Status codes: 2xx=2213834, 3xx=0, 4xx=0, 5xx=0
  Latency samples: 2213834 / 2213834 responses (100.0%)
  Reconnects: 88183
  Per-template: 441338,442428,443684,444142,442242
  Per-template-ok: 441338,442428,443684,444142,442242
[info] CPU 4956.1% | Mem 305MiB

[run 2/3]
gcannon v0.5.3
  Target:    localhost:8080/
  Threads:   64
  Conns:     1024 (16/thread)
  Pipeline:  1
  Req/conn:  25
  Templates: 5
  Expected:  200
  Duration:  10s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency   3.69ms   3.23ms   6.21ms   10.80ms   15.80ms

  2363522 requests in 10.00s, 2362584 responses
  Throughput: 236.20K req/s
  Bandwidth:  910.91MB/s
  Status codes: 2xx=2362584, 3xx=0, 4xx=0, 5xx=0
  Latency samples: 2362578 / 2362584 responses (100.0%)
  Reconnects: 94478
  Per-template: 470873,472338,473857,473792,471718
  Per-template-ok: 470873,472338,473856,473792,471718
[info] CPU 5482.2% | Mem 301MiB

[run 3/3]
gcannon v0.5.3
  Target:    localhost:8080/
  Threads:   64
  Conns:     1024 (16/thread)
  Pipeline:  1
  Req/conn:  25
  Templates: 5
  Expected:  200
  Duration:  10s


  Thread Stats   Avg      p50      p90      p99    p99.9
    Latency   3.75ms   3.27ms   6.33ms   11.00ms   16.20ms

  2364851 requests in 10.00s, 2364854 responses
  Throughput: 236.43K req/s
  Bandwidth:  912.03MB/s
  Status codes: 2xx=2364854, 3xx=0, 4xx=0, 5xx=0
  Latency samples: 2364846 / 2364854 responses (100.0%)
  Reconnects: 94584
  Per-template: 471735,472378,473715,474301,472717
  Per-template-ok: 471735,472378,473715,474301,472717
[info] CPU 5559.7% | Mem 300MiB

=== Best: 236485 req/s (CPU: 5559.7%, Mem: 300MiB) ===
[info] input BW: 15.79MB/s (avg template: 70 bytes)
[info] saved results/async-db/1024/userver.json
httparena-bench-userver
httparena-bench-userver
[info] skip: userver does not subscribe to crud
[info] skip: userver does not subscribe to fortunes
[info] skip: userver does not subscribe to baseline-h2
[info] skip: userver does not subscribe to static-h2
[info] skip: userver does not subscribe to baseline-h2c
[info] skip: userver does not subscribe to json-h2c
[info] skip: userver does not subscribe to baseline-h3
[info] skip: userver does not subscribe to static-h3
[info] skip: userver does not subscribe to gateway-64
[info] skip: userver does not subscribe to gateway-h3
[info] skip: userver does not subscribe to production-stack
[info] skip: userver does not subscribe to unary-grpc
[info] skip: userver does not subscribe to unary-grpc-tls
[info] skip: userver does not subscribe to stream-grpc
[info] skip: userver does not subscribe to stream-grpc-tls
[info] skip: userver does not subscribe to echo-ws
[info] skip: userver does not subscribe to echo-ws-pipeline
[info] rebuilding site/data/*.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/frameworks.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/api-16-1024.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/api-4-256.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/async-db-1024.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/baseline-4096.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/baseline-512.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/json-4096.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/json-comp-16384.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/json-comp-4096.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/json-comp-512.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/limited-conn-4096.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/limited-conn-512.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/pipelined-4096.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/pipelined-512.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/static-1024.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/static-4096.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/static-6800.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/upload-256.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/upload-32.json
[updated] /home/diogo/actions-runner/_work/HttpArena/HttpArena/site/data/current.json
[info] done
httparena-postgres
[info] restoring loopback MTU to 65536

@MDA2AV MDA2AV merged commit 894bb23 into MDA2AV:main Jun 6, 2026
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.

2 participants