-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tube: fix slow take on busy utubes #229
tube: fix slow take on busy utubes #229
Conversation
9e7bd98
to
7827b24
Compare
Right now only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Added fix for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, update the README.md.
We need notes about the utube
/utubettl
configuration, policy/option (I'm still not sure about the naming) differences and performance.
Please, apply fixes for the comments to both queues.
0e0a63a
to
3e07f7d
Compare
@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
Updated the code according to comments. |
9d8360b
to
f78cb5d
Compare
f78cb5d
to
1e1645c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea seems rather clear after inspecting the issue and, since tests are green, everything should be fine. I had left some code nits, but it shouldn't be anything crucial there.
1e1645c
to
7961003
Compare
Updated the code according to the comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Updated the code according to comments. |
a7df866
to
31adb7d
Compare
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
If some of the utubes for tasks at the start 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 spacespace_ready
. It contains first task withREADY
status from each utube.This solution shows great results for the stated problem, but with the cost of slowing the
put
method. 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_BUFFER
forutube
andqueue.driver.utubettl.STORAGE_MODE_READY_BUFFER
forutubettl
). 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).put
andtake
methods. 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 usedfifo
tube):As we can see, new utube implementation has slower
put
method.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
, thenyield
and thenack
every 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 tasks
were used 140k and not 150k tasks).Closes #228