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

Borrow WC variants of executor views to reduce thread count and increase reuse #4877

Merged
merged 2 commits into from
Jul 2, 2020

Conversation

carterkozak
Copy link
Contributor

@carterkozak carterkozak commented Jun 30, 2020

Goals (and why):

Fewer total threads.
Threads are reused effectively.

Implementation Description (bullets):

  • This includes an API+ABI break for fixed-size-executor factory methods which have been updated to return ExecutorService instead of ThreadPoolExecutor.
  • Pending the next jboss-threads release, the executor wrapping code will be replaced by a dependency.

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

The executor code is already used in wc which has been rolled out broadly.

LinkedBlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>();
NamedThreadFactory threadFactory = new NamedThreadFactory("Atlas Cassandra Async KVS", false);

return PTExecutors.newThreadPoolExecutor(0, maxPoolSize, 1, TimeUnit.MINUTES, workQueue, threadFactory);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This executor configuration is highly suspect. At a glance I believe it will only ever have a single thread unless we manage to fill the LinkedBlockingQueue with Integer.MAX_VALUE elements.

Copy link
Contributor

Choose a reason for hiding this comment

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

We looked at metrics-platform and it turns out this executor is basically unused in practice...

…ase reuse

Note that this includes an API+ABI break for fixed-size-executor factory
methods which have been updated to return ExecutorService instead
of ThreadPoolExecutor.
@carterkozak carterkozak force-pushed the ckozak/shared_executors branch from 78c8ead to 8e42db5 Compare July 1, 2020 18:55
@carterkozak carterkozak changed the title [stack] Borrow WC variants of executor views to reduce thread count and increase reuse Borrow WC variants of executor views to reduce thread count and increase reuse Jul 1, 2020
@carterkozak carterkozak changed the base branch from ckozak/atlas_fixed_executor_consolidation to develop July 1, 2020 18:55
Copy link
Contributor

@jeremyk-91 jeremyk-91 left a comment

Choose a reason for hiding this comment

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

Cool. I've verified equivalence between the classes from jboss, so we should go ahead. As acknowledged, there is an API/ABI break, but it does not affect the common libraries used with AtlasDB.

LinkedBlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>();
NamedThreadFactory threadFactory = new NamedThreadFactory("Atlas Cassandra Async KVS", false);

return PTExecutors.newThreadPoolExecutor(0, maxPoolSize, 1, TimeUnit.MINUTES, workQueue, threadFactory);
Copy link
Contributor

Choose a reason for hiding this comment

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

We looked at metrics-platform and it turns out this executor is basically unused in practice...

- type: break
break:
description: |-
`PTExecutors.newFixedThreadPool` overloads return `ExecutorService` instead of the concrete `ThreadPoolExecutor` type.
Copy link
Contributor

Choose a reason for hiding this comment

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

note: will cause breaks in large internal product. Can confirm not used by the common AtlasDB supporting libraries.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm planning to fix the internal product once this is available.

* Borrowed from jboss-threads. http://www.apache.org/licenses/LICENSE-2.0
* https://github.com/jbossas/jboss-threads/blob/master/src/main/java/org/jboss/threads/QueuedViewExecutor.java Changes
* have been contributed and merged, this may be replaced by the upstream ViewExecutor pending a release including
* https://github.com/jbossas/jboss-threads/pull/85.
Copy link
Contributor

Choose a reason for hiding this comment

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

This PR merged, though I wouldn't block on us using the alternative there. I checked for equivalence - it seems we have a bit more interrupt handling logic here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pull/86 hasn't merged quite yet, but it's much less substantial than the others. Folks on their end are busy.

@@ -239,20 +232,7 @@ public static LocalPaxosServices createInstrumentedLocalServices(
// TODO (jkong): Make the limits configurable.
// Current use cases tend to have not more than 10 (<< 100) inflight tasks under normal circumstances.
private static ExecutorService createExecutor(MetricsManager metricsManager, String useCase, int corePoolSize) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this is private so we could probably remove the unused corepoolsize parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

iirc it's passed through several methods and I wanted to keep the code churn to a minimum.

@bulldozer-bot bulldozer-bot bot merged commit abedbf0 into develop Jul 2, 2020
@bulldozer-bot bulldozer-bot bot deleted the ckozak/shared_executors branch July 2, 2020 16:27
jeremyk-91 added a commit that referenced this pull request Jul 21, 2020
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.

2 participants