-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests are hitting the time limit due to the exhaustive nature of brute forcing with millions of cases. This change avoids some of the unnecessary churn, though a deeper dive is needed or a request to extend the free limit. Using ParallelGC is only required for deterministic soft reference collection in tests. Switching the other tests to use G1 reduces their tasks by 1.5 minutes each.
- Loading branch information
Showing
10 changed files
with
53 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
bin | ||
build | ||
build-cache | ||
test-output | ||
jitwatch.out | ||
.java-version | ||
|
This file contains 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 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 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 |
---|---|---|
|
@@ -41,7 +41,7 @@ | |
* @author [email protected] (Ben Manes) | ||
*/ | ||
@Listeners(CacheValidationListener.class) | ||
@Test(groups = "isolated", dataProviderClass = CacheProvider.class) | ||
@Test(dataProviderClass = CacheProvider.class) | ||
public final class HashClashTest { | ||
private static final int STEP = 5; | ||
private static final Long LONG_1 = 1L; | ||
|
This file contains 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 |
---|---|---|
|
@@ -41,6 +41,7 @@ | |
import com.github.benmanes.caffeine.cache.testing.CacheSpec.ReferenceType; | ||
import com.github.benmanes.caffeine.cache.testing.CacheSpec.Stats; | ||
import com.github.benmanes.caffeine.cache.testing.CacheSpec.Writer; | ||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableSet; | ||
import com.google.common.collect.Maps; | ||
import com.google.common.collect.Sets; | ||
|
@@ -51,6 +52,11 @@ | |
* @author [email protected] (Ben Manes) | ||
*/ | ||
final class CacheGenerator { | ||
// Integer caches the object identity semantics of autoboxing for values between | ||
// -128 and 127 (inclusive) as required by JLS (assuming default setting) | ||
private static final List<Entry<Integer, Integer>> INTS = makeInts(); | ||
private static final int BASE = 1_000; | ||
|
||
private final Options options; | ||
private final CacheSpec cacheSpec; | ||
private final boolean isAsyncOnly; | ||
|
@@ -207,20 +213,18 @@ private void populate(CacheContext context, Cache<Integer, Integer> cache) { | |
return; | ||
} | ||
|
||
// Integer caches the object identity semantics of autoboxing for values between | ||
// -128 and 127 (inclusive) as required by JLS | ||
int base = 1000; | ||
|
||
int maximum = (int) Math.min(context.maximumSize(), context.population.size()); | ||
int first = base + (int) Math.min(1, context.population.size()); | ||
int last = base + maximum; | ||
int middle = Math.max(first, base + ((last - first) / 2)); | ||
int first = BASE + (int) Math.min(0, context.population.size()); | ||
int last = BASE + maximum - 1; | ||
int middle = Math.max(first, BASE + ((last - first) / 2)); | ||
|
||
context.disableRejectingCacheWriter(); | ||
for (int i = 1; i <= maximum; i++) { | ||
for (int i = 0; i < maximum; i++) { | ||
Entry<Integer, Integer> entry = INTS.get(i); | ||
|
||
// Reference caching (weak, soft) require unique instances for identity comparison | ||
Integer key = new Integer(base + i); | ||
Integer value = new Integer(-key); | ||
Integer key = context.isStrongKeys() ? entry.getKey() : new Integer(BASE + i); | ||
Integer value = context.isStrongValues() ? entry.getValue() : new Integer(-key); | ||
|
||
if (key == first) { | ||
context.firstKey = key; | ||
|
@@ -240,4 +244,18 @@ private void populate(CacheContext context, Cache<Integer, Integer> cache) { | |
reset(context.cacheWriter()); | ||
} | ||
} | ||
|
||
/** Returns a cache of integers and their negation. */ | ||
@SuppressWarnings("BoxedPrimitiveConstructor") | ||
private static List<Entry<Integer, Integer>> makeInts() { | ||
int size = Stream.of(CacheSpec.Population.values()) | ||
.mapToInt(population -> Math.toIntExact(population.size())) | ||
.max().getAsInt(); | ||
ImmutableList.Builder<Entry<Integer, Integer>> builder = ImmutableList.builder(); | ||
for (int i = 0; i < size; i++) { | ||
int value = BASE + i; | ||
builder.add(Maps.immutableEntry(new Integer(value), new Integer(-value))); | ||
} | ||
return builder.build(); | ||
} | ||
} |
This file contains 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 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
org.gradle.jvmargs=-Xmx1024m -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=0 -noverify | ||
org.gradle.caching=true | ||
org.gradle.daemon=true | ||
nexusUsername= | ||
nexusPassword= |
This file contains 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 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 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