Skip to content

perf: skip transaction for retry requeue and tune slow benchmarks#79

Merged
deepjoy merged 1 commit into
mainfrom
tag-query-perf
Mar 23, 2026
Merged

perf: skip transaction for retry requeue and tune slow benchmarks#79
deepjoy merged 1 commit into
mainfrom
tag-query-perf

Conversation

@deepjoy

@deepjoy deepjoy commented Mar 23, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add requeue_for_retry to TaskStore that executes a bare UPDATE on the pool instead of BEGIN IMMEDIATEUPDATECOMMIT, cutting connection hold time by 2/3 for the retry path. With open_memory()'s single-connection pool, this lets pop_next_batch dispatch interleave sooner with concurrent failure writes.
  • Split handle_failure into a fast path (requeue_for_retry for will-retry) and the existing transactional fail_with_record for terminal failures that require multi-statement atomicity (INSERT history + DELETE task).
  • Tune criterion config on query_by_tags and retryable_dead_letter benchmark groups (sample_size(10), warm_up_time(1s), measurement_time(3s)) to reduce wall-clock time ~50%.

Benchmark results

retryable_dead_letter throughput improved ~2.5x across all four backoff strategies:

Strategy Before After Change
constant ~900 elem/s 2,305 elem/s +154%
linear ~900 elem/s 2,325 elem/s +167%
exponential ~900 elem/s 2,316 elem/s +162%
exponential_jitter ~900 elem/s 2,320 elem/s +154%

Add `requeue_for_retry` that executes a bare UPDATE on the pool instead
of BEGIN IMMEDIATE + UPDATE + COMMIT. With max_connections(1) this cuts
connection hold time by 2/3 for retries, letting dispatch interleave
sooner. Measured 2.5x throughput improvement on retryable_dead_letter.

Reduce sample_size/warm_up/measurement_time on query_by_tags and
retryable_dead_letter benchmark groups to cut wall-clock time ~50%.
@deepjoy deepjoy enabled auto-merge (squash) March 23, 2026 15:51
@deepjoy deepjoy merged commit bac4602 into main Mar 23, 2026
2 checks passed
@github-actions github-actions Bot mentioned this pull request Mar 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Comparison

Click to expand
group                                       main                                    pr
-----                                       ----                                    --
backoff_delay/constant                      1.05     49.0±0.66ns 389.4 MElem/sec    1.00     46.8±2.09ns 407.7 MElem/sec
backoff_delay/exponential                   1.03    187.7±0.53ns 101.6 MElem/sec    1.00    181.9±0.40ns 104.9 MElem/sec
backoff_delay/exponential_jitter            1.01    269.1±1.33ns 70.9 MElem/sec     1.00    267.2±0.96ns 71.4 MElem/sec
backoff_delay/linear                        1.00     81.0±0.51ns 235.4 MElem/sec    1.01     81.9±0.20ns 233.0 MElem/sec
batch_submit/1000                           1.01     33.3±2.56ms 29.3 KElem/sec     1.00     32.9±2.16ms 29.7 KElem/sec
byte_progress/byte_reporting_500            1.03    246.3±5.73ms  2030 Elem/sec     1.00    239.1±5.06ms  2.0 KElem/sec
byte_progress/noop_500                      1.02    243.8±5.37ms  2.0 KElem/sec     1.00    239.6±3.54ms  2.0 KElem/sec
byte_progress_snapshot/100_tasks            1.03     82.0±2.42ms  1219 Elem/sec     1.00     79.4±2.16ms  1259 Elem/sec
concurrency_scaling/1                       1.01    375.8±4.38ms  1330 Elem/sec     1.00    371.9±3.49ms  1344 Elem/sec
concurrency_scaling/2                       1.01    312.4±4.66ms  1600 Elem/sec     1.00    309.3±3.80ms  1616 Elem/sec
concurrency_scaling/4                       1.02    268.8±5.06ms  1860 Elem/sec     1.00    264.3±5.01ms  1891 Elem/sec
concurrency_scaling/8                       1.01    243.0±4.80ms  2.0 KElem/sec     1.00    240.6±4.32ms  2.0 KElem/sec
count_by_tags/100                           1.01    130.8±3.17µs  7.5 KElem/sec     1.00    129.3±3.14µs  7.6 KElem/sec
count_by_tags/1000                          1.02    219.6±4.12µs  4.4 KElem/sec     1.00    216.1±4.80µs  4.5 KElem/sec
count_by_tags/5000                          1.00    602.7±6.50µs  1659 Elem/sec     1.01    608.3±4.54µs  1643 Elem/sec
dep_chain_dispatch/10                       1.02     10.9±0.17ms   913 Elem/sec     1.00     10.7±0.10ms   932 Elem/sec
dep_chain_dispatch/25                       1.06     27.2±0.78ms   919 Elem/sec     1.00     25.7±0.29ms   972 Elem/sec
dep_chain_dispatch/50                       1.03     53.3±1.63ms   937 Elem/sec     1.00     51.6±0.98ms   968 Elem/sec
dep_chain_submit/10                         1.03      3.1±0.15ms  3.1 KElem/sec     1.00      3.0±0.10ms  3.2 KElem/sec
dep_chain_submit/200                        1.00     76.7±3.00ms  2.5 KElem/sec     1.01     77.7±3.74ms  2.5 KElem/sec
dep_chain_submit/50                         1.02     16.9±0.78ms  2.9 KElem/sec     1.00     16.6±0.76ms  2.9 KElem/sec
dep_fan_in_dispatch/10                      1.03      7.1±0.14ms  1550 Elem/sec     1.00      6.9±0.11ms  1599 Elem/sec
dep_fan_in_dispatch/100                     1.03     52.4±1.33ms  1926 Elem/sec     1.00     51.1±0.82ms  1975 Elem/sec
dep_fan_in_dispatch/50                      1.03     27.3±0.72ms  1868 Elem/sec     1.00     26.5±0.49ms  1925 Elem/sec
dispatch_and_complete/1000                  1.02    490.1±9.51ms  2040 Elem/sec     1.00    482.1±6.26ms  2.0 KElem/sec
dispatch_group_scaling/1                    1.00    403.7±5.64ms  1238 Elem/sec     1.01    406.6±5.45ms  1229 Elem/sec
dispatch_group_scaling/10                   1.00    402.8±5.42ms  1241 Elem/sec     1.02    410.9±5.02ms  1216 Elem/sec
dispatch_group_scaling/100                  1.00    412.7±5.60ms  1211 Elem/sec     1.00    413.2±5.70ms  1210 Elem/sec
dispatch_group_scaling/50                   1.00    410.8±8.18ms  1217 Elem/sec     1.01    413.5±5.40ms  1209 Elem/sec
dispatch_no_groups/500                      1.03    246.4±4.71ms  2028 Elem/sec     1.00    239.5±3.65ms  2.0 KElem/sec
dispatch_one_group/500                      1.00    412.2±5.69ms  1213 Elem/sec     1.00    411.8±6.09ms  1214 Elem/sec
dispatch_permanent_failure/500              1.01    362.2±6.36ms  1380 Elem/sec     1.00    359.7±3.99ms  1389 Elem/sec
history_by_type/100                         1.00   890.0±35.01µs  1123 Elem/sec     1.00   890.4±28.73µs  1123 Elem/sec
history_by_type/1000                        1.03   931.5±44.65µs  1073 Elem/sec     1.00   907.0±28.79µs  1102 Elem/sec
history_by_type/5000                        1.00   925.4±23.02µs  1080 Elem/sec     1.02   941.2±15.75µs  1062 Elem/sec
history_query/100                           1.00    531.5±7.69µs  1881 Elem/sec     1.01   538.7±12.23µs  1856 Elem/sec
history_query/1000                          1.00    538.5±6.69µs  1856 Elem/sec     1.01    541.7±7.12µs  1846 Elem/sec
history_query/5000                          1.00    554.4±6.13µs  1803 Elem/sec     1.00    552.3±7.16µs  1810 Elem/sec
history_stats/100                           1.02    151.5±1.34µs  6.4 KElem/sec     1.00    148.3±0.73µs  6.6 KElem/sec
history_stats/1000                          1.00    371.2±2.79µs  2.6 KElem/sec     1.04    384.9±1.59µs  2.5 KElem/sec
history_stats/5000                          1.01   1325.2±3.38µs   754 Elem/sec     1.00   1318.2±5.11µs   758 Elem/sec
mixed_priority_dispatch/500                 1.02    270.0±5.09ms  1851 Elem/sec     1.00    264.9±5.19ms  1887 Elem/sec
peek_next/100                               1.02    121.8±2.89µs  8.0 KElem/sec     1.00    119.1±2.17µs  8.2 KElem/sec
peek_next/1000                              1.03    122.2±2.23µs  8.0 KElem/sec     1.00    119.0±2.98µs  8.2 KElem/sec
peek_next/5000                              1.01    121.0±3.02µs  8.1 KElem/sec     1.00    119.9±2.74µs  8.1 KElem/sec
query_by_tags/100                           1.00  1268.6±139.52µs   788 Elem/sec    1.05  1332.8±155.97µs   750 Elem/sec
query_by_tags/1000                          1.04     10.1±1.37ms    99 Elem/sec     1.00      9.7±0.78ms   102 Elem/sec
query_by_tags/5000                          1.00     49.9±1.79ms    20 Elem/sec     1.07     53.2±1.31ms    18 Elem/sec
retryable_dead_letter/constant              1.14    146.0±1.97ms   684 Elem/sec     1.00    127.8±1.35ms   782 Elem/sec
retryable_dead_letter/exponential           1.14    146.9±2.50ms   680 Elem/sec     1.00    128.8±1.24ms   776 Elem/sec
retryable_dead_letter/exponential_jitter    1.14    146.3±2.09ms   683 Elem/sec     1.00    127.8±0.93ms   782 Elem/sec
retryable_dead_letter/linear                1.14    146.3±2.41ms   683 Elem/sec     1.00    128.4±1.13ms   778 Elem/sec
submit_dedup_hit/1000                       1.01    240.6±8.11ms  4.1 KElem/sec     1.00    239.0±7.35ms  4.1 KElem/sec
submit_tasks/1000                           1.01    182.6±4.42ms  5.3 KElem/sec     1.00    181.4±4.50ms  5.4 KElem/sec
submit_with_tags/0                          1.01     89.6±2.81ms  5.4 KElem/sec     1.00     88.9±2.48ms  5.5 KElem/sec
submit_with_tags/10                         1.03   244.7±11.28ms  2043 Elem/sec     1.00   237.9±10.13ms  2.1 KElem/sec
submit_with_tags/20                         1.03   397.4±15.96ms  1258 Elem/sec     1.00   386.9±16.45ms  1292 Elem/sec
submit_with_tags/5                          1.02    166.6±6.06ms  2.9 KElem/sec     1.00    163.6±6.37ms  3.0 KElem/sec
tag_values/100                              1.05    140.5±3.85µs  7.0 KElem/sec     1.00    133.7±3.31µs  7.3 KElem/sec
tag_values/1000                             1.01    199.1±3.39µs  4.9 KElem/sec     1.00    197.8±3.70µs  4.9 KElem/sec
tag_values/5000                             1.00    456.5±7.39µs  2.1 KElem/sec     1.00    456.3±7.02µs  2.1 KElem/sec

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