Skip to content

Commit

Permalink
fix: Update SystemExecutors to only use 4 threads, always (#1209)
Browse files Browse the repository at this point in the history
This can cause contention issues on high-core-count machines

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/java-pubsublite/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [ ] Ensure the tests and linter pass
- [ ] Code coverage does not decrease (if any source code was changed)
- [ ] Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> ☕️

If you write sample code, please follow the [samples format](
https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
  • Loading branch information
dpcollins-google authored Sep 20, 2022
1 parent ae60131 commit 65cfb99
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ If you are using Maven, add this to your pom.xml file:
If you are using Gradle without BOM, add this to your dependencies:

```Groovy
implementation 'com.google.cloud:google-cloud-pubsublite:1.6.3'
implementation 'com.google.cloud:google-cloud-pubsublite:1.7.0'
```

If you are using SBT, add this to your dependencies:

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-pubsublite" % "1.6.3"
libraryDependencies += "com.google.cloud" % "google-cloud-pubsublite" % "1.7.0"
```

## Authentication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ private static ThreadFactory newDaemonThreadFactory(String prefix) {

public static ScheduledExecutorService newDaemonExecutor(String prefix) {
ScheduledThreadPoolExecutor executor =
new ScheduledThreadPoolExecutor(
Math.max(4, Runtime.getRuntime().availableProcessors()),
newDaemonThreadFactory(prefix));
new ScheduledThreadPoolExecutor(4, newDaemonThreadFactory(prefix));
// Remove scheduled tasks from the executor as soon as they are cancelled.
executor.setRemoveOnCancelPolicy(true);
return executor;
Expand Down

0 comments on commit 65cfb99

Please sign in to comment.