Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Avoid creating thousands of get-ranges threads #5224

Conversation

carterkozak
Copy link
Contributor

Our metrics show services with thousands of threads in the
serializabletransactionmanager-get-ranges pool, however the
executor was not instrumented with Tritium, so it's not clear
how saturated it is, or if it is used at all. Threads are incredibly
expensive, it's generally a sign of failure when a service reaches
1000 total threads.

Using PTExecutors factories we get tracing and execution metrics
for free, as well as resource utilization improvements to share
a slice of an underlying cached executor so threads are only
used as needed. The provided numThreads is still an upper limit
for the ExecutorService instance, however idle threads can be
used elsewhere.

The existing queue size warning logic is preserved using a counter
rather than instrumenting the queue itself in much the same way
tritium estimates ExecutorService queue size.

Goals (and why):

Vastly reduce memory overhead for several services.

Implementation Description (bullets):

Use the standard ptexecutors factory with a wrapper to support queue size warnings. Ideally this would move to Hyperion instead, but that's out of scope here.

Testing (What was existing testing like? What have you done to improve it?):

No behavior change, only a reduction in resource utilization.

Concerns (what feedback would you like?):

Where should we start reviewing?:

Priority (whenever / two weeks / yesterday):

@changelog-app
Copy link

changelog-app bot commented Jan 26, 2021

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Avoid creating thousands of serializabletransactionmanager-get-ranges threads by using the efficient PTExecutors ExecutorService factory methods.

Check the box to generate changelog(s)

  • Generate changelog entry

Our metrics show services with thousands of threads in the
`serializabletransactionmanager-get-ranges` pool, however the
executor was not instrumented with Tritium, so it's not clear
how saturated it is, or if it is used at all.

Using PTExecutors factories we get tracing and execution metrics
for free, as well as resource utilization improvements to share
a slice of an underlying cached executor so threads are only
used as needed. The provided `numThreads` is still an upper limit
for the ExecutorService instance, however idle threads can be
used elsewhere.

The existing queue size warning logic is preserved using a counter
rather than instrumenting the queue itself in much the same way
tritium estimates ExecutorService queue size.
@carterkozak carterkozak force-pushed the ckozak/AbstractTransactionManager_getRangesExecutor_threads branch from 400c80a to 1499b86 Compare January 26, 2021 22:33
Copy link
Contributor

@gmaretic gmaretic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@bulldozer-bot bulldozer-bot bot merged commit 9013add into develop Feb 2, 2021
@bulldozer-bot bulldozer-bot bot deleted the ckozak/AbstractTransactionManager_getRangesExecutor_threads branch February 2, 2021 14:25
@svc-autorelease
Copy link
Collaborator

Released 0.290.1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants