tube: fix slow take on busy utubes#229
Merged
oleg-jukovec merged 2 commits intomasterfrom May 18, 2024
Merged
Conversation
9e7bd98 to
7827b24
Compare
Contributor
Author
|
Right now only |
oleg-jukovec
requested changes
Apr 28, 2024
Contributor
oleg-jukovec
left a comment
There was a problem hiding this comment.
Please, add update the ready space for all updates of the READY state for a task cases: release, as example.
86a4164 to
8b14921
Compare
3afb16e to
80f33dc
Compare
Contributor
Author
|
Added fix for |
oleg-jukovec
reviewed
May 9, 2024
0e0a63a to
3e07f7d
Compare
Contributor
|
@DifferentialOrange @better0fdead this is a non-trivial fix, we need additional reviews with a clear head here. |
3e07f7d to
f33b2ba
Compare
f33b2ba to
9d8360b
Compare
Contributor
Author
|
Updated the code according to comments. |
oleg-jukovec
approved these changes
May 14, 2024
9d8360b to
f78cb5d
Compare
f78cb5d to
1e1645c
Compare
DifferentialOrange
approved these changes
May 15, 2024
1e1645c to
7961003
Compare
Contributor
Author
|
Updated the code according to the comments. |
oleg-jukovec
requested changes
May 16, 2024
Contributor
oleg-jukovec
left a comment
There was a problem hiding this comment.
In the utubettl we don't take into account priority when working with STORAGE_MODE_READY_BUFFER.
c9f6e74 to
9e58cf6
Compare
9e58cf6 to
9267b95
Compare
Contributor
Author
|
Updated the code according to comments. |
oleg-jukovec
approved these changes
May 17, 2024
a7df866 to
31adb7d
Compare
oleg-jukovec
approved these changes
May 18, 2024
If some of the utube for tasks at the top of the queue were busy
most of the time, `take` would slow down for every other task.
This problem is fixed by creating a new space `space_ready_buffer`. It
contains first task with `READY` status from each utube.
This solution shows great results for the stated problem, with the cost
of slowing the `put` method. Thus, this workaround is disabled by default.
To enable it, user should set the
`storage_mode = queue.driver.utube.STORAGE_MODE_READY_BUFFER` as an option
while creating the tube. As example:
```lua
local test_queue = queue.create_tube('test_queue', 'utube',
{temporary = true, storage_mode = queue.driver.utube.STORAGE_MODE_READY_BUFFER})
```
Part of #228
If some of the utubettl for tasks at the top of the queue were busy
most of the time, `take` would slow down for every other task.
This problem is fixed by creating a new space `space_ready_buffer`. It
contains first task with `READY` status from each utube.
This solution shows great results for the stated problem, with the cost
of slowing the `put` method. Thus, this workaround is disabled by default.
To enable it, user should set the
`storage_mode = queue.driver.utubettl.STORAGE_MODE_READY_BUFFER` as an option
while creating the tube. As example:
```lua
local test_queue = queue.create_tube('test_queue', 'utubettl',
{temporary = true, storage_mode = queue.driver.utubettl.STORAGE_MODE_READY_BUFFER})
```
Closes #228
31adb7d to
64033a6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If some of the utubes for tasks at the start of the queue were busy most of the time,
takewould slow down for every other task. This problem is fixed by creating a new spacespace_ready. It contains first task withREADYstatus from each utube.This solution shows great results for the stated problem, but with the cost of slowing the
putmethod. Thus, this workaround is disabled by default. To enable it, user should set thestorage_mode = "ready_buffer"as an option while creating the tube (orqueue.driver.utube.STORAGE_MODE_READY_BUFFERforutubeandqueue.driver.utubettl.STORAGE_MODE_READY_BUFFERforutubettl). As example:Or
Also added two benchmarks to compare
storage_mode = "default"andstorage_mode = "ready_buffer"(storage_mode = "default"is default and disables the workaround).putandtakemethods. 30k utubes are created with single task each. Task creation time is calculated. After that 30k consumers are callingtake+ack, each in the separate fiber. Time to ack all tasks is calculated. The results are as follows (for comparison I also usedfifotube):As we can see, new utube implementation has slower
putmethod.2. Benchmark for the stated problem. 10 tubes are created. Each contains 1000 task. After that 10 consumers are created (each works on his tube only, one tube -- one consumer). Each consumer will
take, thenyieldand thenackevery task from their utube (1000 tasks each).After that we can also run this benchmark with 10k tasks on each utube, 100k tasks and 150k tasks. But all that with 10 utubes and 10 consumers. The results are as follows:
We can see great time performance improvement.
Same change was also made for
utubettl. Here is benchmarks results forutubettl(on the same benchmarks):(note that for
busy taskswere used 140k and not 150k tasks).Closes #228