Skip to content

Only poll work when there are slots to work on#393

Merged
cschleiden merged 3 commits intomainfrom
limited-worker-task-queue
Aug 7, 2025
Merged

Only poll work when there are slots to work on#393
cschleiden merged 3 commits intomainfrom
limited-worker-task-queue

Conversation

@cschleiden
Copy link
Copy Markdown
Owner

@cschleiden cschleiden commented Aug 1, 2025

This pull request refactors the worker queue implementation to introduce a new workQueue abstraction, improving the management of task concurrency and queue operations. The main changes include replacing the direct use of channels for task queuing and concurrency control with the new workQueue type, updating the worker logic to use this abstraction, and adding comprehensive tests for the new queue.

If the number of max parallel tasks a worker can work is constrained, it will pause polling until capacity is available.

@cschleiden cschleiden force-pushed the limited-worker-task-queue branch 2 times, most recently from e03c154 to 9f4db5c Compare August 1, 2025 19:09
@cschleiden
Copy link
Copy Markdown
Owner Author

!bench

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 1, 2025

Benchmark Results

MySQL run

Command Mean [ms] Min [ms] Max [ms] Relative
mysql-main 533.2 ± 202.9 404.1 1094.6 1.06 ± 0.43
mysql-pr 502.4 ± 66.4 391.5 586.0 1.00

SQLite run

Command Mean [ms] Min [ms] Max [ms] Relative
sqlite-main 510.1 ± 89.5 393.3 651.5 1.00
sqlite-pr 520.5 ± 103.9 375.3 643.2 1.02 ± 0.27

Redis run

Command Mean [ms] Min [ms] Max [ms] Relative
redis-main 190.4 ± 21.7 160.5 246.4 1.01 ± 0.19
redis-pr 189.2 ± 28.1 130.4 251.7 1.00

@cschleiden
Copy link
Copy Markdown
Owner Author

!bench large

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 1, 2025

Benchmark Results

MySQL run

Command Mean [ms] Min [ms] Max [ms] Relative
mysql-main 500.5 ± 52.8 444.7 627.3 1.00
mysql-pr 568.1 ± 50.1 489.3 642.5 1.13 ± 0.16

SQLite run

Command Mean [ms] Min [ms] Max [ms] Relative
sqlite-main 714.7 ± 131.8 460.9 843.8 1.00
sqlite-pr 737.8 ± 107.6 614.3 864.8 1.03 ± 0.24

Redis run

Command Mean [ms] Min [ms] Max [ms] Relative
redis-main 195.6 ± 31.9 152.6 256.3 1.04 ± 0.21
redis-pr 188.2 ± 22.4 172.3 250.3 1.00

@cschleiden
Copy link
Copy Markdown
Owner Author

!bench verylarge

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 1, 2025

Benchmark Results

MySQL run

Command Mean [ms] Min [ms] Max [ms] Relative
mysql-main 560.7 ± 86.6 441.5 701.3 1.03 ± 0.23
mysql-pr 546.2 ± 91.0 429.4 681.5 1.00

SQLite run

Command Mean [ms] Min [ms] Max [ms] Relative
sqlite-main 633.8 ± 120.3 434.6 838.9 1.07 ± 0.32
sqlite-pr 592.3 ± 139.0 414.8 822.9 1.00

Redis run

Command Mean [ms] Min [ms] Max [ms] Relative
redis-main 198.5 ± 18.1 170.7 247.2 1.10 ± 0.20
redis-pr 180.7 ± 27.6 130.5 249.3 1.00

@cschleiden
Copy link
Copy Markdown
Owner Author

!bench !large

@github-actions
Copy link
Copy Markdown

github-actions bot commented Aug 1, 2025

Benchmark Results

MySQL run

Command Mean [ms] Min [ms] Max [ms] Relative
mysql-main 601.6 ± 107.2 467.8 851.5 1.11 ± 0.31
mysql-pr 541.2 ± 114.2 457.1 860.3 1.00

Large MySQL payload run (1MB)

Command Mean [s] Min [s] Max [s] Relative
mysql-main 24.968 ± 1.006 23.284 26.494 1.00
mysql-pr 30.961 ± 18.858 24.131 84.610 1.24 ± 0.76

SQLite run

Command Mean [ms] Min [ms] Max [ms] Relative
sqlite-main 626.0 ± 128.4 425.4 849.1 1.02 ± 0.27
sqlite-pr 614.9 ± 104.2 415.5 810.6 1.00

Large SQLite payload run (1MB)

Command Mean [s] Min [s] Max [s] Relative
sqlite-main 22.388 ± 0.695 20.997 23.107 1.00
sqlite-pr 22.664 ± 0.738 21.316 23.480 1.01 ± 0.05

Redis run

Command Mean [ms] Min [ms] Max [ms] Relative
redis-main 208.3 ± 25.4 185.9 265.8 1.00
redis-pr 211.6 ± 31.1 170.9 254.5 1.02 ± 0.19

Large Redis payload run (1MB)

Command Mean [s] Min [s] Max [s] Relative
redis-main 22.232 ± 0.327 21.803 22.746 1.01 ± 0.02
redis-pr 22.024 ± 0.406 21.507 22.587 1.00

Comment thread internal/worker/worker.go
@cschleiden cschleiden marked this pull request as ready for review August 6, 2025 22:28
@cschleiden cschleiden force-pushed the limited-worker-task-queue branch from 014128a to 1e8fc85 Compare August 7, 2025 19:32
@cschleiden cschleiden merged commit 9793749 into main Aug 7, 2025
4 checks passed
@cschleiden cschleiden deleted the limited-worker-task-queue branch August 7, 2025 19:40
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