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

Add BatchingProcessor #1

Closed
wants to merge 3 commits into from
Closed

Add BatchingProcessor #1

wants to merge 3 commits into from

Conversation

ryamagishi
Copy link
Owner

int capacity;
long maxRetryCount;

private final ConcurrentMap<String, BufferedTaskGroup> windowedTasks = new ConcurrentHashMap<>(64, 0.75f,

Choose a reason for hiding this comment

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

capacityやload factorなどを詳細に設定する理由ってなんでしょうか?

Copy link
Owner Author

Choose a reason for hiding this comment

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

すみません、参考元をそのままコピペしてしまっただけで特に理由はないですmm

@Override
public void process(ProcessingContext<T> context, T task) throws InterruptedException {
String key = context.key();
BufferedTaskGroup taskGroup = windowedTasks.get(key);

Choose a reason for hiding this comment

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

見たところkeyごとにbatchingする設計のようですが、key単位でのバッチングは以下のようなデメリットがあるかと思います。

  • keyのcardinalityが高い時に、バッチングが効かずにほとんどlingerでのflushとなる

key単位でのバッチングが有効なケースもあるとは思いますが、Decatonでbuilt-inで提供することを考えると、シンプルにBatchingProcessor instance単位でのバッチングが行われる、というほうがより分かりやすいし多くのユースケースにマッチするのではないでしょうか。

Copy link
Owner Author

Choose a reason for hiding this comment

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

instance 単位でバッチングが行えるように書き換えました。(大部分の変更になってしまいレビュー負担をおかけしてすみません)

}

BatchingProcessor(
BiConsumer<String, List<BufferedTask<T>>> processor,

Choose a reason for hiding this comment

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

実際のprocessingロジックをBiConsumerで受け取るのではなく、BatchingProcessorをabstract classにしてuserに実装してもらうほうが、processorのlifecycle管理をDecatonに移譲できてよいと思いました。

Copy link
Owner Author

Choose a reason for hiding this comment

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

承知しました!

@ryamagishi
Copy link
Owner Author

https://github.com/line/decaton 側に draft PR を直接たてるため、この PR はクローズします

@ryamagishi ryamagishi closed this Dec 9, 2021
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