Skip to content
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

New implementation of WorkQueue that allows concurrent enqueuing of tasks #2859

Merged
merged 4 commits into from
Mar 16, 2021

Conversation

spericas
Copy link
Member

New implementation of WorkQueue that allows concurrent enqueuing of tasks. Previous implementation was based on LinkedBlockingQueue which uses a lock to prevent concurrent additions to the queue. Under high concurrency, this effectively introduces a "chicane" that results in a lot of threads waiting and a poor CPU utilization. The new implementation uses a ConcurrentLinkedQueue and two semaphores to enable concurrent enqueuing of tasks. The poor CPU utilization was discovered while running DBClient tests that used a ThreadPool to execute blocking calls. Credit to @olotenko.

Signed-off-by: Santiago Pericasgeertsen santiago.pericasgeertsen@oracle.com

…asks. Previous implementation was based on LinkedBlockingQueue which uses a lock to prevent concurrent additions to the queue. Under high concurrency, this effectively introduces a "chicane" that results in a lot of threads waiting and a poor CPU utilization. The new implementation uses a ConcurrentLinkedQueue and two semaphores to enable concurrent enqueuing of tasks. The poor CPU utilization was discovered while running DBClient tests that used a ThreadPool to execute blocking calls.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
@spericas spericas self-assigned this Mar 12, 2021
@spericas spericas added the enhancement New feature or request label Mar 12, 2021
Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
ljnelson
ljnelson previously approved these changes Mar 12, 2021
Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
…ainTo().

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
@spericas spericas merged commit 48e8165 into helidon-io:master Mar 16, 2021
paulparkinson pushed a commit that referenced this pull request Mar 29, 2021
…asks (#2859)

* New implementation of WorkQueue that allows concurrent enqueuing of tasks. Previous implementation was based on LinkedBlockingQueue which uses a lock to prevent concurrent additions to the queue. Under high concurrency, this effectively introduces a "chicane" that results in a lot of threads waiting and a poor CPU utilization. The new implementation uses a ConcurrentLinkedQueue and two semaphores to enable concurrent enqueuing of tasks. The poor CPU utilization was discovered while running DBClient tests that used a ThreadPool to execute blocking calls.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* Use try-finally when calling enqueue(task).

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* Fixed unnecessary formatting.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* Moved try-block logic into enqueue() method. New implementation of drainTo().

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
aseovic pushed a commit to aseovic/helidon that referenced this pull request Apr 26, 2021
…asks (helidon-io#2859)

* New implementation of WorkQueue that allows concurrent enqueuing of tasks. Previous implementation was based on LinkedBlockingQueue which uses a lock to prevent concurrent additions to the queue. Under high concurrency, this effectively introduces a "chicane" that results in a lot of threads waiting and a poor CPU utilization. The new implementation uses a ConcurrentLinkedQueue and two semaphores to enable concurrent enqueuing of tasks. The poor CPU utilization was discovered while running DBClient tests that used a ThreadPool to execute blocking calls.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* Use try-finally when calling enqueue(task).

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* Fixed unnecessary formatting.

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>

* Moved try-block logic into enqueue() method. New implementation of drainTo().

Signed-off-by: Santiago Pericasgeertsen <santiago.pericasgeertsen@oracle.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants