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

Issue #350 Add more efficient shortest queue selection methods. #557

Merged
merged 1 commit into from
May 24, 2017

Conversation

cschanck
Copy link
Contributor

@cschanck cschanck commented May 10, 2017

Updated for rework...

For StageQueueImpl, an interface StageQueue was extracted; a factory
is now used to create StageQueue's. This allowed me to split
StageQueueImpl into 2 different implementations. SingletonStageQueueImpl
is used when only 1 queue is desired (allowing for much more efficiency)
in this case, while MultiStageQueueImpl is used for queue counts >1.

In MultiStageQueueImpl, I created an enum for two different shortest path
impls. BRUTE is the classic brute force approach, while PARTITION
simply partitions the queues into sets of 4 (or 2 if the number of
queue is <8, or 1 if <2), and then on each findShortestQueue(),
we choose the next partition, and brute force the shortest queue
within that partition. Since the partitions are so small, the short
brute force search is fast, and the clock-cache like behavior
of round robin selection of partition should be pretty good at finding
the shortest queue most of the time. Synthetic testing showed this to
be extremely efficient.

Another minheap approach was tried, but the overhead on put()/poll()
was too great to be useful.

A system property, "tc.stagequeueimpl.findstrategy", is available which
cane be set to one of BRUTE or PARTITION to choose the findstrategy
while we test in real world conditions. By default, PARTITION is used.



private static ShortestFindStrategy chooseStrategy(ShortestFindStrategy defaultVal) {
String stratName = System.getProperty(FINDSTRATEGY_PROPNAME, defaultVal.name());
Copy link
Member

Choose a reason for hiding this comment

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

formalize with a tc.property? It is easier to enable in tests etc.

} else if (queueCount > 2) {
LEAP_SHIFT = 1;
} else {
LEAP_SHIFT = 0;
Copy link
Member

Choose a reason for hiding this comment

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

The vast majority of StageQueue uses are this. Is it worth fastpathing this in find shortest queue (probably never used) and disabling the added infrastructure?

…methods.

For StageQueueImpl, and interface StageQueue was extracted; a factory
is now used to create StageQueue's. This allowed me to split
StageQueueImpl into 2 different implementations. SingletonStageQueueImpl
is used when only 1 queue is desired (allowing for much more efficiency
in this case, while MultiStageQueueImpl is used for queue counts >1.

In MultiStageQueueImpl, I created an enum for two different shortest path
impls. BRUTE is the classic brute force approach, while PARTITION
simply partitions the queues into sets of 4 (or 2 if the number of
queue is <8, or 1 if <2), and then on each findShortestQueue(),
we choose the next partition, and brute force the shortest queue
within that partition. Since the partitions are so small, the short
brute force search is fast, and the clock-cache like behavior
of round robin selection of partition should be pretty good at finding
the shortest queue most of the time. Synthetic testing showed this to
be extremely efficient.

Another minheap approach was tried, but the overhead on put()/poll()
was too great to be useful.

A system property, "tc.stagequeueimpl.findstrategy", is available which
cane be set to one of BRUTE or PARTITION to choose the findstrategy
while we test in real world conditions. By default, PARTITION is used.
@myronkscott myronkscott merged commit d975cf3 into Terracotta-OSS:master May 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants