Skip to content

Commit 8f668ed

Browse files
committed
bunch of changes
1 parent f84ef42 commit 8f668ed

11 files changed

Lines changed: 519 additions & 47 deletions

File tree

.mvn/extensions.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
4+
<extension>
5+
<groupId>org.apache.maven.extensions</groupId>
6+
<artifactId>maven-build-cache-extension</artifactId>
7+
<version>1.2.3</version>
8+
</extension>
9+
</extensions>

java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/channels/ChannelPoolDpImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
import javax.annotation.Nullable;
5858
import javax.annotation.concurrent.GuardedBy;
5959

60+
// TODO: more aggressively create new channels to catch new AFEs
61+
6062
/**
6163
* Proof of concept channel pool that avoids parallel channels to the same afe. The pool is
6264
* dynamically sized based on outstanding streams and tries to limit each channel to at most 10
@@ -76,7 +78,7 @@ public class ChannelPoolDpImpl implements ChannelPool {
7678

7779
@VisibleForTesting volatile int minGroups = 2;
7880
@VisibleForTesting volatile int maxGroups = 50;
79-
@VisibleForTesting volatile int softMaxPerGroup = 5;
81+
@VisibleForTesting volatile int softMaxPerGroup = 8;
8082

8183
private final Clock clock;
8284
private final Supplier<ManagedChannel> channelSupplier;
@@ -476,7 +478,8 @@ private synchronized void serviceChannelsSafe() {
476478
}
477479
} else if (desiredGroups > channelGroups.size() + startingGroup.channels.size()) {
478480
log(Level.FINE, "Adding %d channels", desiredGroups - channelGroups.size());
479-
for (int i = channelGroups.size(); i < desiredGroups; i++) {
481+
int desiredExtraGroups = desiredGroups - channelGroups.size();
482+
for (int i = 0; i < desiredExtraGroups * softMaxPerGroup; i++) {
480483
addChannel();
481484
}
482485
}
@@ -539,6 +542,7 @@ static class AfeChannelGroup {
539542
private int numStreams;
540543
private Optional<Float> ewma_network_latency_ms = Optional.empty();
541544
private Optional<Float> traffic_weight = Optional.empty();
545+
// TODO: we probably don't need to set this here, all the processing happens in SessionList.
542546
private volatile PeerLoadInfo afeLoad = PeerLoadInfo.getDefaultInstance();
543547

544548
public AfeChannelGroup(AfeId afeId) {

java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/session/DynamicPicker.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,21 @@ public void updateConfig(SessionClientConfiguration.SessionPoolConfiguration con
5353
}
5454

5555
private Picker createPicker(LoadBalancingOptions options) {
56-
switch (options.getLoadBalancingStrategyCase()) {
57-
case RANDOM:
58-
return new SimplePicker(sessions, options.getRandom());
59-
case LEAST_IN_FLIGHT:
60-
return new LeastInFlightPicker(sessions, options.getLeastInFlight());
61-
case PEAK_EWMA:
62-
return new LeastLatencyPicker(sessions, options.getPeakEwma());
63-
default:
64-
LOGGER.log(
65-
Level.FINE,
66-
"got load balancing strategy {0} which was not implemented",
67-
options.getLoadBalancingStrategyCase());
68-
return new LeastInFlightPicker(
69-
sessions, LoadBalancingOptions.LeastInFlight.getDefaultInstance());
70-
}
56+
return new WeightedLeastInFlightPicker(sessions);
57+
// switch (options.getLoadBalancingStrategyCase()) {
58+
// case RANDOM:
59+
// return new SimplePicker(sessions, options.getRandom());
60+
// case LEAST_IN_FLIGHT:
61+
// return new LeastInFlightPicker(sessions, options.getLeastInFlight());
62+
// case PEAK_EWMA:
63+
// return new LeastLatencyPicker(sessions, options.getPeakEwma());
64+
// default:
65+
// LOGGER.log(
66+
// Level.FINE,
67+
// "got load balancing strategy {0} which was not implemented",
68+
// options.getLoadBalancingStrategyCase());
69+
// return new LeastInFlightPicker(
70+
// sessions, LoadBalancingOptions.LeastInFlight.getDefaultInstance());
71+
// }
7172
}
7273
}

java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/session/LeastInFlightPicker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Optional<SessionHandle> pickSession() {
4646
List<AfeHandle> candidates = new ArrayList<>(readyAfes);
4747
int bestCost = Integer.MAX_VALUE;
4848
AfeHandle bestAfe = null;
49-
long iterations = readyAfes.size();
49+
long iterations = candidates.size();
5050
if (options.getRandomSubsetSize() > 0) {
5151
iterations = Math.min(options.getRandomSubsetSize(), iterations);
5252
}

java-bigtable/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/session/PoolSizer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public int getScaleDelta() {
7171
// support for multiplexing.
7272
int effectivePending = (int) Math.ceil((float) pendingRpcs.getSize() / pendingVRpcsPerSession);
7373
int sessionsInUse = effectivePending + stats.getInUseCount();
74-
int unboundedDesiredIdleSessions = (int) Math.ceil(sessionsInUse * idlesSessionHeadRoom);
74+
// TODO: double-check this logic.
75+
int unboundedDesiredIdleSessions = (int) Math.ceil(sessionsInUse * idlesSessionHeadRoom / stats.getUsableFraction());
7576
int desiredIdleSessions =
7677
Math.max(Math.min(unboundedDesiredIdleSessions, maxIdleSessions), minIdleSessions);
7778

0 commit comments

Comments
 (0)