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

Allow user specified concurrency for Scalar to Group and Group to Scalar #720

Merged

Conversation

crioux-stripe
Copy link
Collaborator

Context

The default concurrency for ScalarToGroup and GroupToScalar stages is -1 and thus relies on the number of inner observables when executing the stage. There may be cases such as CPU bound stages where the user wants fine grained control over how many threads are executing the stage logic.

Some discussion in #681 indicates a desire for this, but I agree with @calvin681 that changing defaults shouldn't be done lightly as users have come to expect certain threading behavior with the stages. I think this represents a compromise where unaware users can continue with the default and power users can begin to control threading.

Checklist

  • ./gradlew build compiles code correctly
  • Added new tests where applicable
  • ./gradlew test passes all tests
  • Extended README or added javadocs where applicable

Copy link

github-actions bot commented Oct 7, 2024

Test Results

614 tests  ±0   604 ✅ +2   8m 7s ⏱️ -8s
142 suites ±0    10 💤 ±0 
142 files   ±0     0 ❌  - 2 

Results for commit 6a45a4a. ± Comparison against base commit 0aabc16.

♻️ This comment has been updated with latest results.

@@ -33,7 +33,12 @@ public abstract class KeyValueStageConfig<T, K, R> extends StageConfig<T, R> {
private final Codec<K> keyCodec;

public KeyValueStageConfig(String description, Codec<?> inputKeyCodec, Codec<T> inputCodec, Codec<K> outputKeyCodec, Codec<R> outputCodec, INPUT_STRATEGY inputStrategy, List<ParameterDefinition<?>> params) {
super(description, inputKeyCodec, inputCodec, outputCodec, inputStrategy, params);
super(description, inputKeyCodec, inputCodec, outputCodec, inputStrategy, params, DEFAULT_STAGE_CONCURRENCY);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: you could call the other constructor in this class instead of duplicate call to super + keyCodec assignment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call. Pushed a change.

@@ -116,6 +118,12 @@ public Config<T, K, R> concurrentInput() {
return this;
}

public Config<T, K, R> concurrentInput(final int concurrency) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this could cause issues, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I went looking around and we do allocate the same key to the same thread every time. We have concurrency either way, this just lets the user specify it precisely, unless I'm misunderstanding the if/else that contains the linked line.

@crioux-stripe crioux-stripe merged commit 3a936bc into master Oct 11, 2024
4 of 5 checks passed
@crioux-stripe crioux-stripe deleted the crioux-stripe/scalar-to-group-group-to-scalar-concurrency branch October 11, 2024 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants