Skip to content

chore(engine): add more spans inside try-assign-batch + disable JIT on a few queries - #4947

Merged
mrkaye97 merged 13 commits into
mainfrom
mk/try-assign-spans
Sep 21, 2026
Merged

mrkaye97 merged 13 commits into
mainfrom
mk/try-assign-spans

Conversation

@mrkaye97

@mrkaye97 mrkaye97 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

For more visibility in here to help debugging, and also disabling the JIT on PG on a few queries

Type of change

  • Chore (changes which are not directly related to any business logic)

Checklist

Changes have been:

  • Documented (where applicable)
  • Added to CHANGELOG (where applicable) -- see Keep a Changelog

🤖 AI Disclosure
  • I acknowledge that an LLM was used in the creation of this Pull Request, in accordance with Hatchet's AI_POLICY.md.
  • Details: Fable

@vercel

vercel Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hatchet-docs Ready Ready Preview Sep 21, 2026 8:32pm UTC

Request Review

@github-actions github-actions Bot added the engine Related to the core Hatchet engine label Sep 10, 2026
@greptile-apps

greptile-apps Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

The behavioral changes appear sound, but the exported transaction helper must be documented to satisfy the repository’s explicit code-comment requirement before merging.

Summary

This PR adds more detailed scheduler assignment tracing, introduces a transaction helper that disables PostgreSQL JIT for selected matching and concurrency queries, and updates release-tagging tasks.

  • Adds nested spans and outcome attributes around batch assignment, queue waiting, worker ranking, and rate-limit release.
  • Disables JIT locally within selected repository transactions.
  • Adds stable and alpha tag lookup tasks and updates patch, minor, and alpha release calculations.
  • Updates scheduler tests for the new context-aware assignment signature.

Reviews (2) · Last reviewed commit: "chore: rm replay changes"

Comment thread pkg/scheduling/v1/scheduler.go
@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark results

goos: linux
goarch: amd64
pkg: github.com/hatchet-dev/hatchet/pkg/scheduling/v1
cpu: AMD Ryzen 9 7950X3D 16-Core Processor          
                                                                    │ /tmp/old.txt │             /tmp/new.txt              │
                                                                    │    sec/op    │    sec/op      vs base                │
BatchSchedulerWorstCaseMemory-8                                        1.777 ± 15%     1.574 ±  6%   -11.39% (p=0.002 n=6)
RateLimiter-8                                                         89.44µ ± 11%    47.44µ ±  9%   -46.95% (p=0.002 n=6)
Scheduler_ConcurrentAssignReplenishSnapshot-8                         335.1µ ±  3%    446.1µ ± 18%   +33.12% (p=0.002 n=6)
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_01-8          5.918m ±  3%    5.266m ±  4%   -11.03% (p=0.002 n=6)
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_04-8          5.953m ± 11%    5.909m ±  1%         ~ (p=0.818 n=6)
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_16-8          12.50m ±  3%    12.17m ±  5%         ~ (p=0.132 n=6)
Scheduler_InventoryShape_ReplenishMust/small_dense-8                  49.51µ ±  7%    46.17µ ±  5%    -6.75% (p=0.041 n=6)
Scheduler_InventoryShape_ReplenishMust/dense_high_action_fanout-8     7.837m ±  3%    7.896m ±  3%         ~ (p=0.485 n=6)
Scheduler_InventoryShape_ReplenishMust/dense_high_slot_capacity-8     1.425m ±  6%    1.374m ±  1%    -3.59% (p=0.002 n=6)
Scheduler_InventoryShape_ReplenishMust/sparse_low_fanout-8            515.3µ ± 17%    429.4µ ± 10%   -16.69% (p=0.015 n=6)
Scheduler_InventoryShape_ReplenishMust/partitioned_20-8               2.344m ±  5%    2.510m ±  7%    +7.06% (p=0.015 n=6)
Scheduler_InventoryShape_ActiveCountScan/small_dense-8                11.69µ ±  6%    11.89µ ±  9%         ~ (p=0.818 n=6)
Scheduler_InventoryShape_ActiveCountScan/dense_high_action_fanout-8   3.720m ±  4%    3.875m ±  3%    +4.15% (p=0.015 n=6)
Scheduler_InventoryShape_ActiveCountScan/dense_high_slot_capacity-8   55.17µ ±  4%    56.13µ ±  2%         ~ (p=0.240 n=6)
Scheduler_InventoryShape_ActiveCountScan/sparse_low_fanout-8          63.84µ ±  2%    64.56µ ±  8%         ~ (p=0.394 n=6)
Scheduler_InventoryShape_ActiveCountScan/partitioned_20-8             949.2µ ±  4%   1008.2µ ±  6%    +6.22% (p=0.026 n=6)
Scheduler_InventoryShape_TryAssignBatch/small_dense-8                 43.04µ ±  6%   118.34µ ±  8%  +174.98% (p=0.002 n=6)
Scheduler_InventoryShape_TryAssignBatch/dense_high_action_fanout-8    60.79µ ±  3%   144.41µ ±  6%  +137.54% (p=0.002 n=6)
Scheduler_InventoryShape_TryAssignBatch/dense_high_slot_capacity-8    57.12µ ±  3%   141.20µ ±  4%  +147.20% (p=0.002 n=6)
Scheduler_InventoryShape_TryAssignBatch/sparse_low_fanout-8           25.08µ ±  7%    94.58µ ±  2%  +277.11% (p=0.002 n=6)
Scheduler_InventoryShape_TryAssignBatch/partitioned_20-8              36.93µ ±  7%   123.72µ ±  9%  +235.04% (p=0.002 n=6)
Scheduler_Replenish_DenseSharedActions-8                              4.581m ±  2%    5.230m ± 11%   +14.18% (p=0.002 n=6)
geomean                                                               542.7µ          673.9µ         +24.18%

                                │ /tmp/old.txt │         /tmp/new.txt          │
                                │  bytes/item  │ bytes/item  vs base           │
BatchSchedulerWorstCaseMemory-8     70.17 ± 0%   70.17 ± 0%  ~ (p=1.000 n=6) ¹
¹ all samples are equal

                                │ /tmp/old.txt  │           /tmp/new.txt           │
                                │ worst_case_MB │ worst_case_MB  vs base           │
BatchSchedulerWorstCaseMemory-8     1.403k ± 0%     1.403k ± 0%  ~ (p=1.000 n=6) ¹
¹ all samples are equal

                                │   /tmp/old.txt   │           /tmp/new.txt            │
                                │ worst_case_bytes │ worst_case_bytes  vs base         │
BatchSchedulerWorstCaseMemory-8        1.403G ± 0%        1.403G ± 0%  ~ (p=0.853 n=6)

                                                                    │ /tmp/old.txt │              /tmp/new.txt               │
                                                                    │     B/op     │     B/op       vs base                  │
BatchSchedulerWorstCaseMemory-8                                       6.400Gi ± 0%    6.400Gi ± 0%         ~ (p=0.563 n=6)
RateLimiter-8                                                         137.7Ki ± 0%    137.7Ki ± 0%    -0.01% (p=0.017 n=6)
Scheduler_ConcurrentAssignReplenishSnapshot-8                         259.2Ki ± 1%    373.1Ki ± 0%   +43.95% (p=0.002 n=6)
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_01-8          2.263Mi ± 0%    2.263Mi ± 0%         ~ (p=0.141 n=6)
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_04-8          2.663Mi ± 0%    2.663Mi ± 0%         ~ (p=0.558 n=6)
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_16-8          4.426Mi ± 0%    4.426Mi ± 0%         ~ (p=0.699 n=6)
Scheduler_InventoryShape_ReplenishMust/small_dense-8                  28.03Ki ± 0%    28.03Ki ± 0%         ~ (p=0.524 n=6)
Scheduler_InventoryShape_ReplenishMust/dense_high_action_fanout-8     3.731Mi ± 0%    3.729Mi ± 0%         ~ (p=0.180 n=6)
Scheduler_InventoryShape_ReplenishMust/dense_high_slot_capacity-8     3.132Mi ± 0%    3.132Mi ± 0%         ~ (p=0.803 n=6)
Scheduler_InventoryShape_ReplenishMust/sparse_low_fanout-8            665.1Ki ± 0%    665.1Ki ± 0%         ~ (p=1.000 n=6)
Scheduler_InventoryShape_ReplenishMust/partitioned_20-8               1.872Mi ± 0%    1.872Mi ± 0%         ~ (p=0.613 n=6)
Scheduler_InventoryShape_ActiveCountScan/small_dense-8                  168.0 ± 0%      168.0 ± 0%         ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_action_fanout-8     168.0 ± 0%      168.0 ± 0%         ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_slot_capacity-8     168.0 ± 0%      168.0 ± 0%         ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/sparse_low_fanout-8            168.0 ± 0%      168.0 ± 0%         ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/partitioned_20-8               168.0 ± 0%      168.0 ± 0%         ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/small_dense-8                 39.31Ki ± 0%   128.34Ki ± 0%  +226.45% (p=0.002 n=6)
Scheduler_InventoryShape_TryAssignBatch/dense_high_action_fanout-8    151.6Ki ± 0%    244.6Ki ± 0%   +61.33% (p=0.002 n=6)
Scheduler_InventoryShape_TryAssignBatch/dense_high_slot_capacity-8    119.6Ki ± 0%    212.6Ki ± 0%   +77.73% (p=0.002 n=6)
Scheduler_InventoryShape_TryAssignBatch/sparse_low_fanout-8           13.72Ki ± 0%    99.46Ki ± 0%  +625.00% (p=0.002 n=6)
Scheduler_InventoryShape_TryAssignBatch/partitioned_20-8              40.61Ki ± 0%   133.59Ki ± 0%  +228.92% (p=0.002 n=6)
Scheduler_Replenish_DenseSharedActions-8                              2.166Mi ± 0%    2.166Mi ± 0%    +0.00% (p=0.002 n=6)
geomean                                                               105.3Ki         137.0Ki        +30.00%
¹ all samples are equal

                                                                    │ /tmp/old.txt │             /tmp/new.txt              │
                                                                    │  allocs/op   │  allocs/op   vs base                  │
BatchSchedulerWorstCaseMemory-8                                        3.720k ± 0%   3.720k ± 0%         ~ (p=0.455 n=6)
RateLimiter-8                                                          1.022k ± 0%   1.022k ± 0%         ~ (p=1.000 n=6) ¹
Scheduler_ConcurrentAssignReplenishSnapshot-8                          1.075k ± 1%   3.756k ± 0%  +249.40% (p=0.002 n=6)
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_01-8           6.683k ± 0%   6.683k ± 0%         ~ (p=1.000 n=6)
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_04-8           13.58k ± 0%   13.58k ± 0%         ~ (p=0.545 n=6)
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_16-8           41.70k ± 0%   41.70k ± 0%         ~ (p=1.000 n=6)
Scheduler_InventoryShape_ReplenishMust/small_dense-8                    333.0 ± 0%    333.0 ± 0%         ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/dense_high_action_fanout-8      13.51k ± 0%   13.51k ± 0%         ~ (p=1.000 n=6)
Scheduler_InventoryShape_ReplenishMust/dense_high_slot_capacity-8      56.57k ± 0%   56.57k ± 0%         ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/sparse_low_fanout-8             6.196k ± 0%   6.196k ± 0%         ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/partitioned_20-8                15.21k ± 0%   15.21k ± 0%         ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/small_dense-8                  4.000 ± 0%    4.000 ± 0%         ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_action_fanout-8     4.000 ± 0%    4.000 ± 0%         ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_slot_capacity-8     4.000 ± 0%    4.000 ± 0%         ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/sparse_low_fanout-8            4.000 ± 0%    4.000 ± 0%         ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/partitioned_20-8               4.000 ± 0%    4.000 ± 0%         ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/small_dense-8                   382.0 ± 0%   2449.0 ± 0%  +541.10% (p=0.002 n=6)
Scheduler_InventoryShape_TryAssignBatch/dense_high_action_fanout-8      430.0 ± 0%   2617.0 ± 0%  +508.60% (p=0.002 n=6)
Scheduler_InventoryShape_TryAssignBatch/dense_high_slot_capacity-8      430.0 ± 0%   2617.0 ± 0%  +508.60% (p=0.002 n=6)
Scheduler_InventoryShape_TryAssignBatch/sparse_low_fanout-8             277.0 ± 0%   2244.0 ± 0%  +710.11% (p=0.002 n=6)
Scheduler_InventoryShape_TryAssignBatch/partitioned_20-8                430.0 ± 0%   2617.0 ± 0%  +508.60% (p=0.002 n=6)
Scheduler_Replenish_DenseSharedActions-8                               4.891k ± 0%   4.891k ± 0%         ~ (p=0.182 n=6)
geomean                                                                 604.7         979.9        +62.04%
¹ all samples are equal

                                                                    │ /tmp/old.txt │            /tmp/new.txt             │
                                                                    │ action_rows  │ action_rows  vs base                │
Scheduler_ConcurrentAssignReplenishSnapshot-8                          10.00k ± 0%   10.00k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_01-8           50.00k ± 0%   50.00k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_04-8           50.00k ± 0%   50.00k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_16-8           50.00k ± 0%   50.00k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/small_dense-8                    200.0 ± 0%    200.0 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/dense_high_action_fanout-8      86.20k ± 0%   86.20k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/dense_high_slot_capacity-8      1.200k ± 0%   1.200k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/sparse_low_fanout-8             1.000k ± 0%   1.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/partitioned_20-8                20.00k ± 0%   20.00k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/small_dense-8                  200.0 ± 0%    200.0 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_action_fanout-8    86.20k ± 0%   86.20k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_slot_capacity-8    1.200k ± 0%   1.200k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/sparse_low_fanout-8           1.000k ± 0%   1.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/partitioned_20-8              20.00k ± 0%   20.00k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/small_dense-8                   200.0 ± 0%    200.0 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/dense_high_action_fanout-8     86.20k ± 0%   86.20k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/dense_high_slot_capacity-8     1.200k ± 0%   1.200k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/sparse_low_fanout-8            1.000k ± 0%   1.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/partitioned_20-8               20.00k ± 0%   20.00k ± 0%       ~ (p=1.000 n=6) ¹
geomean                                                                5.421k        5.421k       +0.00%
¹ all samples are equal

                                                                    │ /tmp/old.txt │            /tmp/new.txt             │
                                                                    │   actions    │   actions    vs base                │
Scheduler_ConcurrentAssignReplenishSnapshot-8                           200.0 ± 0%    200.0 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_01-8            500.0 ± 0%    500.0 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_04-8            500.0 ± 0%    500.0 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_16-8            500.0 ± 0%    500.0 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/small_dense-8                    20.00 ± 0%    20.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/dense_high_action_fanout-8      1.724k ± 0%   1.724k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/dense_high_slot_capacity-8       30.00 ± 0%    30.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/sparse_low_fanout-8             2.000k ± 0%   2.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/partitioned_20-8                2.000k ± 0%   2.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/small_dense-8                  20.00 ± 0%    20.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_action_fanout-8    1.724k ± 0%   1.724k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_slot_capacity-8     30.00 ± 0%    30.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/sparse_low_fanout-8           2.000k ± 0%   2.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/partitioned_20-8              2.000k ± 0%   2.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/small_dense-8                   20.00 ± 0%    20.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/dense_high_action_fanout-8     1.724k ± 0%   1.724k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/dense_high_slot_capacity-8      30.00 ± 0%    30.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/sparse_low_fanout-8            2.000k ± 0%   2.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/partitioned_20-8               2.000k ± 0%   2.000k ± 0%       ~ (p=1.000 n=6) ¹
geomean                                                                 346.2         346.2       +0.00%
¹ all samples are equal

                                                                   │ /tmp/old.txt │            /tmp/new.txt            │
                                                                   │  batch_size  │ batch_size  vs base                │
Scheduler_ConcurrentAssignReplenishSnapshot-8                          64.00 ± 0%   64.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/small_dense-8                  64.00 ± 0%   64.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/dense_high_action_fanout-8     64.00 ± 0%   64.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/dense_high_slot_capacity-8     64.00 ± 0%   64.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/sparse_low_fanout-8            64.00 ± 0%   64.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/partitioned_20-8               64.00 ± 0%   64.00 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                                                64.00        64.00       +0.00%
¹ all samples are equal

                                                                    │ /tmp/old.txt │            /tmp/new.txt            │
                                                                    │  slot_types  │ slot_types  vs base                │
Scheduler_ConcurrentAssignReplenishSnapshot-8                           1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_01-8            1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_04-8            4.000 ± 0%   4.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_16-8            16.00 ± 0%   16.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/small_dense-8                    1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/dense_high_action_fanout-8       1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/dense_high_slot_capacity-8       1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/sparse_low_fanout-8              1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/partitioned_20-8                 1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/small_dense-8                  1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_action_fanout-8     1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_slot_capacity-8     1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/sparse_low_fanout-8            1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/partitioned_20-8               1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/small_dense-8                   1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/dense_high_action_fanout-8      1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/dense_high_slot_capacity-8      1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/sparse_low_fanout-8             1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/partitioned_20-8                1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                                                 1.245        1.245       +0.00%
¹ all samples are equal

                                                                    │   /tmp/old.txt   │               /tmp/new.txt               │
                                                                    │ slots_per_worker │ slots_per_worker  vs base                │
Scheduler_ConcurrentAssignReplenishSnapshot-8                               20.00 ± 0%         20.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_01-8                20.00 ± 0%         20.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_04-8                20.00 ± 0%         20.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_16-8                20.00 ± 0%         20.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/small_dense-8                        4.000 ± 0%         4.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/dense_high_action_fanout-8           20.00 ± 0%         20.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/dense_high_slot_capacity-8          1.400k ± 0%        1.400k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/sparse_low_fanout-8                  20.00 ± 0%         20.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/partitioned_20-8                     20.00 ± 0%         20.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/small_dense-8                      4.000 ± 0%         4.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_action_fanout-8         20.00 ± 0%         20.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_slot_capacity-8        1.400k ± 0%        1.400k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/sparse_low_fanout-8                20.00 ± 0%         20.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/partitioned_20-8                   20.00 ± 0%         20.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/small_dense-8                       4.000 ± 0%         4.000 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/dense_high_action_fanout-8          20.00 ± 0%         20.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/dense_high_slot_capacity-8         1.400k ± 0%        1.400k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/sparse_low_fanout-8                 20.00 ± 0%         20.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/partitioned_20-8                    20.00 ± 0%         20.00 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                                                     30.34              30.34       +0.00%
¹ all samples are equal

                                                                    │ /tmp/old.txt │             /tmp/new.txt             │
                                                                    │ unique_slots │ unique_slots  vs base                │
Scheduler_ConcurrentAssignReplenishSnapshot-8                          1.000k ± 0%    1.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_01-8           2.000k ± 0%    2.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_04-8           8.000k ± 0%    8.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_16-8           32.00k ± 0%    32.00k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/small_dense-8                    40.00 ± 0%     40.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/dense_high_action_fanout-8      1.000k ± 0%    1.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/dense_high_slot_capacity-8      56.00k ± 0%    56.00k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/sparse_low_fanout-8             4.000k ± 0%    4.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/partitioned_20-8                4.000k ± 0%    4.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/small_dense-8                  40.00 ± 0%     40.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_action_fanout-8    1.000k ± 0%    1.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_slot_capacity-8    56.00k ± 0%    56.00k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/sparse_low_fanout-8           4.000k ± 0%    4.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/partitioned_20-8              4.000k ± 0%    4.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/small_dense-8                   40.00 ± 0%     40.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/dense_high_action_fanout-8     1.000k ± 0%    1.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/dense_high_slot_capacity-8     56.00k ± 0%    56.00k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/sparse_low_fanout-8            4.000k ± 0%    4.000k ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/partitioned_20-8               4.000k ± 0%    4.000k ± 0%       ~ (p=1.000 n=6) ¹
geomean                                                                2.444k         2.444k       +0.00%
¹ all samples are equal

                                                                    │ /tmp/old.txt │            /tmp/new.txt            │
                                                                    │   workers    │  workers    vs base                │
Scheduler_ConcurrentAssignReplenishSnapshot-8                           50.00 ± 0%   50.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_01-8            100.0 ± 0%   100.0 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_04-8            100.0 ± 0%   100.0 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_SlotTypeCardinality/slot_types_16-8            100.0 ± 0%   100.0 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/small_dense-8                    10.00 ± 0%   10.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/dense_high_action_fanout-8       50.00 ± 0%   50.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/dense_high_slot_capacity-8       40.00 ± 0%   40.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/sparse_low_fanout-8              200.0 ± 0%   200.0 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ReplenishMust/partitioned_20-8                 200.0 ± 0%   200.0 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/small_dense-8                  10.00 ± 0%   10.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_action_fanout-8     50.00 ± 0%   50.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/dense_high_slot_capacity-8     40.00 ± 0%   40.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/sparse_low_fanout-8            200.0 ± 0%   200.0 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_ActiveCountScan/partitioned_20-8               200.0 ± 0%   200.0 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/small_dense-8                   10.00 ± 0%   10.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/dense_high_action_fanout-8      50.00 ± 0%   50.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/dense_high_slot_capacity-8      40.00 ± 0%   40.00 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/sparse_low_fanout-8             200.0 ± 0%   200.0 ± 0%       ~ (p=1.000 n=6) ¹
Scheduler_InventoryShape_TryAssignBatch/partitioned_20-8                200.0 ± 0%   200.0 ± 0%       ~ (p=1.000 n=6) ¹
geomean                                                                 64.71        64.71       +0.00%
¹ all samples are equal

Compared against main (f468f4c)

handleReplayTasks called ReplayTasks once per workflow run, and each call
fetched the inputs of the whole replay subtree from the payload store while
holding the transaction and the tenant replay advisory lock. With external
payload storage that serialized one S3 round trip per run, so a batch of
fifty replays took minutes before any message was acked.

Add RetrieveReplayInputs, which expands the subtree outside of a
transaction and fetches every input for the batch in one parallel fan-out.
ReplayTasks takes the prefetched inputs and only retrieves tasks missing
from them inside the transaction.
…after discard

Reshape the previous commit: instead of prefetching inputs outside of the
transaction, which reads payloads for tasks the preflight may discard, the
handler now replays the whole batch in a single ReplayTasks call. Inside
the transaction, after the advisory lock, subtree locks, and discard
checks, only the inputs of tasks that are replayed immediately are fetched,
in one parallel fan-out for the batch.

Drops the per-workflow-run grouping in handleReplayTasks and the
RetrieveReplayInputs repository method.
ReplayTasks held one try-lock per tenant, so every replay for a tenant was
serialized through a single controller and any concurrent attempt failed
and cycled through the DLQ.

Lock each workflow run in the batch instead, with a blocking advisory lock
taken in ascending key order so overlapping batches cannot deadlock. The
batch still runs in one transaction. A concurrent replay of the same run
waits, then finds the tasks already queued and discards them in the
preflight check, so it degrades to a no-op rather than a duplicate replay.

Tasks without a workflow run id are locked on their own external id.
@mrkaye97 mrkaye97 changed the title chore(engine): add more spans inside try-assign-batch chore(engine): add more spans inside try-assign-batch + disable JIT on a few queries Sep 21, 2026
@mrkaye97

Copy link
Copy Markdown
Contributor Author

@greptileai

Exec(ctx context.Context, sql string, args ...any) (pgconn.CommandTag, error)
}

func DisableJITForTransaction(ctx context.Context, tx execer) error {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Exported Function Lacks Godoc

The exported DisableJITForTransaction function has no preceding Godoc comment. This violates the repository requirement that exported types and functions have Godoc comments, so it must be documented before merging.

Context Used: Comment and logging conventions for the Hatchet codebase (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@mrkaye97
mrkaye97 merged commit 8f5020a into main Sep 21, 2026
61 checks passed
@mrkaye97
mrkaye97 deleted the mk/try-assign-spans branch September 21, 2026 20:43

This branch was successfully deployed

1 active deployment
Preview — 904fd06f Deployed Sep 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine Related to the core Hatchet engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants