Skip to content

Commit

Permalink
Add support for Tragen generated trace files
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Nov 6, 2021
1 parent b3ffd52 commit 9f62879
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,9 @@ final class CacheView<K, V> extends AbstractCacheView<K, V> {
}
}

@SuppressWarnings("serial")
abstract class AbstractCacheView<K, V> implements Cache<K, V>, Serializable {
private static final long serialVersionUID = 1L;

transient @Nullable AsMapView<K, V> asMapView;

abstract LocalAsyncCache<K, V> asyncCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,7 @@ final class GuavaPolicy implements Policy<K, V> {
}
}

static class GuavaLoadingCache<K, V> extends GuavaCache<K, V>
implements LoadingCache<K, V>, Serializable {
static class GuavaLoadingCache<K, V> extends GuavaCache<K, V> implements LoadingCache<K, V> {
private static final long serialVersionUID = 1L;

private final com.google.common.cache.LoadingCache<K, V> cache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private static TestAsyncMapGenerator asynchronousGenerator(AsyncCache<String, St
};
}

private static abstract class TestAsyncMapGenerator
private abstract static class TestAsyncMapGenerator
implements TestMapGenerator<String, CompletableFuture<String>> {
static final CompletableFuture<String> JAN = CompletableFuture.completedFuture("January");
static final CompletableFuture<String> FEB = CompletableFuture.completedFuture("February");
Expand Down
10 changes: 10 additions & 0 deletions checksum.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<trusted-key id='1861c322c56014b2' group='commons-lang' />
<trusted-key id='a41f13c999945293' group='commons-logging' />
<trusted-key id='379ce192d401ab61' group='info.picocli' />
<trusted-key id='6601e5c08dccbb96' group='info.picocli' />
<trusted-key id='0d9cb5ee96b7bc22' group='io.airlift' />
<trusted-key id='32bbf14af07ca77b' group='io.github.fastfilter' />
<trusted-key id='a6ea2e2bf22e0543' group='io.github.java-diff-utils' />
Expand Down Expand Up @@ -372,12 +373,21 @@
<dependency group='com.github.spotbugs.snom' module='spotbugs-gradle-plugin' version='4.7.8'>
<sha512>200B2783133DB13CEC356EC2390ED028AFE41A2E685A0805E9DC6F83BB0809C70FC1DCB14232F0863EC09C9508DABB988D3A728C4D10DC1E7AE17E25E5102C37</sha512>
</dependency>
<dependency group='com.github.spotbugs.snom' module='spotbugs-gradle-plugin' version='4.7.9'>
<sha512>755DA0929DEC520A7A5AFA7C46C5DAB0040A7DDD8C6DC9E2092BB83074BFF519E23DDE2CE45118F449B6CE417B4123D519FDA6FE6694D295B575C983F782C49D</sha512>
</dependency>
<dependency group='com.github.spotbugs.snom' module='spotbugs-gradle-plugin' version='5.0.0-beta.2'>
<sha512>BD956309B6719B39F5C9F76134F94D4868AB64BF34E811ECA6C2B435C1E6AB1ED9E036BF6F12EB928FE8424EF9CF8DFF023A2498D7A930FA4E2F570516990BAE</sha512>
</dependency>
<dependency group='com.github.spotbugs.snom' module='spotbugs-gradle-plugin' version='5.0.0-beta.3'>
<sha512>F49F447FBCE57A1C8EA792FFA38744929CAEEB7398056B3760C3DB984E911C52BBC2057CA1000E29C91931FB94125BF1D3267858D3981988CB8F912CAF1CAA1C</sha512>
</dependency>
<dependency group='com.github.spotbugs.snom' module='spotbugs-gradle-plugin' version='5.0.0-beta.5'>
<sha512>ED4830A92C542A6CA4DFFDC74F9A5AC80D4C554B8B54451083EA345E9B2F0790E90F20393F3E36B08EE44CDD053FA2489B3C489CF9A14A14BB4EF723938B79E8</sha512>
</dependency>
<dependency group='com.github.spotbugs.snom' module='spotbugs-gradle-plugin' version='5.0.0-beta.6'>
<sha512>B865FAE7D5F9515F7E92CB9442A5480597F024C779A47A53D68E09D6933AA95E68DE1FE74D73DF35C0A3D991D6882F9F8598738227CDE5CF13E3C1BCB08CDD54</sha512>
</dependency>
<dependency group='com.github.spotbugs' module='spotbugs-gradle-plugin' version='2.0.1'>
<sha512>2C09B102601DF179B615EF37F5E56B9AA1100BB2A17D742B8CB452C1A193C44ED3EBE029FEAFB9822D55A680D99B682184C733D56F835874DD01B02209AFA13D</sha512>
</dependency>
Expand Down
4 changes: 2 additions & 2 deletions examples/coalescing-bulkloader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

<properties>
<java.version>1.8</java.version>
<caffeine.version>3.0.2</caffeine.version>
<caffeine.version>3.0.4</caffeine.version>
<junit.version>4.13.2</junit.version>
<awaitility.version>4.1.0</awaitility.version>
<awaitility.version>4.1.1</awaitility.version>
</properties>

<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions examples/write-behind-rxjava/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

<properties>
<java.version>11</java.version>
<caffeine.version>3.0.2</caffeine.version>
<caffeine.version>3.0.4</caffeine.version>
<rxjava.version>2.2.21</rxjava.version>
<junit.version>4.13.2</junit.version>
<awaitility.version>4.1.0</awaitility.version>
<awaitility.version>4.1.1</awaitility.version>
</properties>

<dependencies>
Expand Down
16 changes: 8 additions & 8 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
ext {
versions = [
akka: '2.6.17',
cache2k: '2.3.1.Alpha',
checkerFramework: '3.18.1',
cache2k: '2.4.1.Final',
checkerFramework: '3.19.0',
coherence: '20.06',
commonsCompress: '1.21',
commonsLang3: '3.12.0',
Expand All @@ -36,7 +36,7 @@ ext {
concurrentlinkedhashmap: '1.4.2',
config: '1.4.1',
ehcache3: '3.9.7',
errorprone: '2.9.0',
errorprone: '2.10.0',
errorproneJavac: '9+181-r4173-1',
elasticSearch: '8.0.0-alpha1',
expiringMap: '0.5.10',
Expand All @@ -56,7 +56,7 @@ ext {
nullaway: '0.9.2',
ohc: '0.6.1',
osgiComponentAnnotations: '1.5.0',
picocli: '4.6.1',
picocli: '4.6.2',
slf4j: '2.0.0-alpha5',
tcache: '2.0.1',
stream: '2.9.8',
Expand All @@ -66,7 +66,7 @@ ext {
zstd: '1.5.0-4',
]
testVersions = [
awaitility: '4.1.0',
awaitility: '4.1.1',
guice: '5.0.1',
hamcrest: '2.2',
jcacheTck: '1.1.1',
Expand All @@ -85,7 +85,7 @@ ext {
]
pluginVersions = [
bnd: '6.0.0',
checkstyle: '9.0.1',
checkstyle: '9.1',
coveralls: '2.12.0',
errorprone: '2.0.2',
findsecbugs: '1.11.0',
Expand All @@ -94,12 +94,12 @@ ext {
jmhReport: '0.9.0',
nexusPublish: '1.1.0',
nullaway: '1.2.0',
pmd: '6.39.0',
pmd: '6.40.0',
semanticVersioning: '1.1.0',
shadow: '7.1.0',
sonarqube: '3.3',
spotbugs: '4.4.2',
spotbugsPlugin: '4.7.8',
spotbugsPlugin: '5.0.0-beta.6',
stats: '0.47.0',
versions: '0.39.0',
]
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.3-rc-2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-rc-5-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.github.benmanes.caffeine.cache.simulator.parser.snia.parallel.TencentBlockTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.snia.parallel.TencentPhotoTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.snia.systor.SystorTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.tragen.TragenTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.twitter.TwitterTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.umass.network.YoutubeTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.umass.storage.StorageTraceReader;
Expand Down Expand Up @@ -78,6 +79,7 @@ public enum TraceFormat {
SNIA_SYSTOR(SystorTraceReader::new),
SNIA_TENCENT_BLOCK(TencentBlockTraceReader::new),
SNIA_TENCENT_PHOTO(TencentPhotoTraceReader::new),
TRAGEN(TragenTraceReader::new),
TWITTER(TwitterTraceReader::new),
UMASS_STORAGE(StorageTraceReader::new),
UMASS_YOUTUBE(YoutubeTraceReader::new),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2021 Ben Manes. All Rights Reserved.
*
* Licensed 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.
*/
package com.github.benmanes.caffeine.cache.simulator.parser.tragen;

import static com.github.benmanes.caffeine.cache.simulator.policy.Policy.Characteristic.WEIGHTED;

import java.util.Set;
import java.util.stream.Stream;

import com.github.benmanes.caffeine.cache.simulator.parser.TextTraceReader;
import com.github.benmanes.caffeine.cache.simulator.policy.AccessEvent;
import com.github.benmanes.caffeine.cache.simulator.policy.Policy.Characteristic;
import com.google.common.collect.Sets;

/**
* A reader for the trace files provided by the authors of the
* <a href="https://github.com/UMass-LIDS/Tragen">Tragen</a> synthetic trace generator.
*
* @author [email protected] (Ben Manes)
*/
public final class TragenTraceReader extends TextTraceReader {

public TragenTraceReader(String filePath) {
super(filePath);
}

@Override
public Set<Characteristic> characteristics() {
return Sets.immutableEnumSet(WEIGHTED);
}

@Override
public Stream<AccessEvent> events() {
return lines()
.map(line -> line.split(","))
.map(array -> AccessEvent.forKeyAndWeight(
Long.parseLong(array[1]), Integer.parseInt(array[2])));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public String toString() {
}

@AutoValue @AutoBuilder
public static abstract class Metric {
public abstract static class Metric {
public enum MetricType { NUMBER, PERCENT, OBJECT }

public abstract String name();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private void registerProduct() {
}

@AutoValue
static abstract class Factory {
abstract static class Factory {
abstract Class<? extends Policy> policyClass();
abstract Function<Config, Set<Policy>> creator();

Expand Down
1 change: 1 addition & 0 deletions simulator/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ caffeine.simulator {
# snia-systor: format of the SNIA SYSTOR '17 traces
# snia-tencent-block: format of the SNIA Tencent Block traces
# snia-tencent-photo: format of the SNIA Tencent Photo traces
# tragen: format of the Tragen synthetic trace generator
# twitter: format of the Twitter Cache Cluster traces
# umass-storage: format of the University of Massachusetts storage traces
# umass-youtube: format of the University of Massachusetts youtube traces
Expand Down

0 comments on commit 9f62879

Please sign in to comment.