-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add support parallel combine in brokers #6629
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2aabb38
Add support parallel combine in brokers
jihoonson 737d2e6
Fix teamcity
jihoonson 21f63b5
Merge branch 'master' of github.com:druid-io/druid into parallel-comb…
jihoonson 97c17b0
Fix checkstyle
jihoonson 7f709c9
add doc
jihoonson 89d8bb3
fix race when calling available()
jihoonson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
702 changes: 702 additions & 0 deletions
702
...marks/src/main/java/org/apache/druid/benchmark/query/CachingClusteredClientBenchmark.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <!-- | ||
| ~ Licensed to the Apache Software Foundation (ASF) under one | ||
| ~ or more contributor license agreements. See the NOTICE file | ||
| ~ distributed with this work for additional information | ||
| ~ regarding copyright ownership. The ASF licenses this file | ||
| ~ to you under the Apache License, Version 2.0 (the | ||
| ~ "License"); you may not use this file except in compliance | ||
| ~ with the License. You may obtain a copy of the License at | ||
| ~ | ||
| ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| ~ | ||
| ~ Unless required by applicable law or agreed to in writing, | ||
| ~ software distributed under the License is distributed on an | ||
| ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| ~ KIND, either express or implied. See the License for the | ||
| ~ specific language governing permissions and limitations | ||
| ~ under the License. | ||
| --> | ||
|
|
||
| <Configuration status="WARN"> | ||
| <Appenders> | ||
| <Console name="Console" target="SYSTEM_OUT"> | ||
| <PatternLayout pattern="%d{ISO8601} %p [%t] %c - %m%n"/> | ||
| </Console> | ||
| </Appenders> | ||
| <Loggers> | ||
| <Root level="info"> | ||
| <AppenderRef ref="Console"/> | ||
| </Root> | ||
| </Loggers> | ||
| </Configuration> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,11 +71,28 @@ public int maxSize() | |
| } | ||
|
|
||
| @VisibleForTesting | ||
| public int getPoolSize() | ||
| public int available() | ||
| { | ||
| return objects.size(); | ||
| } | ||
|
|
||
| @Override | ||
| public List<ReferenceCountingResourceHolder<T>> pollAll() | ||
| { | ||
| checkInitialized(); | ||
| final ReentrantLock lock = this.lock; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this assignment doing something?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, just following other codes. |
||
| lock.lock(); | ||
| try { | ||
| final List<T> list = new ArrayList<>(objects.size()); | ||
| list.addAll(objects); | ||
| objects.clear(); | ||
| return list.stream().map(this::wrapObject).collect(Collectors.toList()); | ||
| } | ||
| finally { | ||
| lock.unlock(); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| @Nullable | ||
| public ReferenceCountingResourceHolder<T> take(final long timeoutMs) | ||
|
|
@@ -160,25 +177,30 @@ private T takeObject() throws InterruptedException | |
| } | ||
|
|
||
| @Override | ||
| public List<ReferenceCountingResourceHolder<T>> takeBatch(final int elementNum, final long timeoutMs) | ||
| public TakeBatchResult<T> takeBatch(final int elementNum, final long timeoutMs) | ||
| { | ||
| Preconditions.checkArgument(elementNum > 0, "elementNum should be positive"); | ||
| Preconditions.checkArgument(timeoutMs >= 0, "timeoutMs must be a non-negative value, but was [%s]", timeoutMs); | ||
| checkInitialized(); | ||
| try { | ||
| final List<T> objects = timeoutMs > 0 ? pollObjects(elementNum, timeoutMs) : pollObjects(elementNum); | ||
| return objects.stream().map(this::wrapObject).collect(Collectors.toList()); | ||
| return new TakeBatchResult<>(objects.stream().map(this::wrapObject).collect(Collectors.toList()), objects.size()); | ||
| } | ||
| catch (InterruptedException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public List<ReferenceCountingResourceHolder<T>> takeBatch(final int elementNum) | ||
| public TakeBatchResult<T> takeBatch(final int elementNum) | ||
| { | ||
| Preconditions.checkArgument(elementNum > 0, "elementNum should be positive"); | ||
| checkInitialized(); | ||
| try { | ||
| return takeObjects(elementNum).stream().map(this::wrapObject).collect(Collectors.toList()); | ||
| return new TakeBatchResult<>( | ||
| takeObjects(elementNum).stream().map(this::wrapObject).collect(Collectors.toList()), | ||
| objects.size() | ||
| ); | ||
| } | ||
| catch (InterruptedException e) { | ||
| throw new RuntimeException(e); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
BlockingQueueinterface has adrainTomethod that does something similar. Can you add documentation on how the behavior of this method is similar or different compared todrainTo?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask why you think it should be documented?
BlockingPoolis our own API and it doesn't useBlockingQueue.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to think as a new developer. What would reduce the total spinup time to get effective contributions. There's a lot of methods which are kind of like core java methods, but are a little different, and it gets hard to differentiate what is important and what is not.
IMHO "This is a subset of
BlockingQueuewith some other added features, but we don't want to depend on keeping up withBlockingQueueupstream changes" is an easier story than "We made up our own interfaces that behave different than other things you've seen, and you have to learn about how the new interfaces are and are not enforced"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a subset of BlockingQueue. It's only similar in terms of "the blocking operation", but it doesn't mean they're similar. The queue and the pool are different. The key characteristic of the queue is that it's FIFO, but there's no order for inserting/getting items to/from the pool.
I don't think anyone would guess BlockingPool's behavior by comparing it with BlockingQueue. If something is not clear, it just means we need to add more detailed doc.