Skip to content

Commit

Permalink
fix the simulator's GD-Wheel policy if the entry exceeds the max size
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Nov 14, 2022
1 parent 9536f65 commit 1a780e5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Dependency Review
uses: actions/dependency-review-action@v2
uses: actions/dependency-review-action@v3
4 changes: 2 additions & 2 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ext {
commonsIo: '2.11.0',
concurrentlinkedhashmap: '1.4.2',
config: '1.4.2',
ehcache3: '3.10.2',
ehcache3: '3.10.3',
errorprone: '2.16',
errorproneSupport: '0.5.0',
expiringMap: '0.5.10',
Expand Down Expand Up @@ -110,7 +110,7 @@ ext {
spotbugsContrib: '7.4.7',
spotbugsPlugin: '5.0.13',
stats: '0.47.0',
versions: '0.43.0',
versions: '0.44.0',
]
platformVerrsions = [
asm: '9.4',
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-rc-2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-rc-3-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.gradle.enterprise' version '3.11.3'
id 'com.gradle.enterprise' version '3.11.4'
id 'com.gradle.common-custom-user-data-gradle-plugin' version '1.8.2'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static com.github.benmanes.caffeine.cache.simulator.policy.Policy.Characteristic.WEIGHTED;

import java.math.BigInteger;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Stream;

Expand Down Expand Up @@ -48,15 +49,15 @@ public Stream<AccessEvent> events() {
return lines()
.map(line -> line.split(" "))
.filter(array -> array[1].equals("REST.GET.OBJECT"))
.flatMap(array -> {
long key = new BigInteger(array[2], 16).longValue();
.map(array -> {
long start = Long.parseLong(array[4]);
long end = Long.parseLong(array[5]);
int weight = Ints.saturatedCast(end - start);
if (weight < 0) {
return Stream.empty();
int weight = Ints.saturatedCast(end - start);
if (weight <= 0) {
return null;
}
return Stream.of(AccessEvent.forKeyAndWeight(key, weight));
});
long key = new BigInteger(array[2], 16).longValue();
return AccessEvent.forKeyAndWeight(key, weight);
}).filter(Objects::nonNull);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ public void record(AccessEvent event) {
}

private void onMiss(AccessEvent event, Node node) {
evict(event);
add(event, node);
if (event.weight() <= maximumSize) {
evict(event);
add(event, node);
}
}

private void evict(AccessEvent event) {
Expand Down Expand Up @@ -148,8 +150,7 @@ private void migrate(int level) {

private void onHit(AccessEvent event, Node node) {
remove(node);
evict(event);
add(event, node);
onMiss(event, node);
}

private void remove(Node node) {
Expand Down

0 comments on commit 1a780e5

Please sign in to comment.