Skip to content

Commit

Permalink
add cachelib traces to the simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Mar 22, 2023
1 parent c8ed5e8 commit 0670fce
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/actions/run-gradle/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ runs:
version: 'latest'
components: 'native-image'
github-token: ${{ inputs.token }}
java-version: ${{ env.JAVA_VERSION }}
java-version: '${{ env.JAVA_VERSION }}'
- name: Prepare JDK ${{ inputs.java }}
shell: bash
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void updateProject(long id, String name) {
}
}

public void persist(Project project, User user, Skill skill) {
public void persist(User user, Project project, Skill skill) {
try (var session = sessionFactory.openSession()) {
var txn = session.beginTransaction();
session.persist(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private long createData(String userName, String projectName, String skillName) {

skill.setName(skillName);

repository.persist(project, user, skill);
repository.persist(user, project, skill);
return project.getId();
}
}
4 changes: 2 additions & 2 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ext {
cache2k: '2.6.1.Final',
checkerFramework: '3.32.0',
coherence: '22.06.2',
commonsCompress: '1.22',
commonsCompress: '1.23.0',
commonsLang3: '3.12.0',
commonsMath3: '3.6.1',
commonsIo: '2.11.0',
Expand Down Expand Up @@ -92,7 +92,7 @@ ext {
bnd: '6.4.0',
checkstyle: '10.9.2',
coveralls: '2.12.2',
dependencyCheck: '8.1.2',
dependencyCheck: '8.2.0',
errorprone: '3.0.1',
findsecbugs: '1.12.0',
forbiddenApis: '3.4',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.github.benmanes.caffeine.cache.simulator.parser.address.penalties.AddressPenaltiesTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.arc.ArcTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.cache2k.Cache2kTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.cachelib.CachelibTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.camelab.CamelabTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.cloud_physics.CloudPhysicsTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.corda.CordaTraceReader;
Expand Down Expand Up @@ -67,6 +68,7 @@ public enum TraceFormat {
ADAPT_SIZE(AdaptSizeTraceReader::new),
ARC(ArcTraceReader::new),
CACHE2K(Cache2kTraceReader::new),
CACHELIB(CachelibTraceReader::new),
CAMELAB(CamelabTraceReader::new),
CLOUD_PHYSICS(CloudPhysicsTraceReader::new),
CORDA(CordaTraceReader::new),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright 2023 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.cachelib;

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;

/**
* A reader for the trace files provided by the authors of cachelib. See
* <a href="https://cachelib.org/docs/Cache_Library_User_Guides/Cachebench_FB_HW_eval">traces</a>.
*
* @author [email protected] (Ben Manes)
*/
public final class CachelibTraceReader extends TextTraceReader {

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

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

@Override
public Stream<AccessEvent> events() {
return lines().skip(1)
.map(line -> line.split(","))
.filter(array -> array[1].equals("GET"))
.map(array -> AccessEvent.forKeyAndWeight(
Long.parseLong(array[0]), Integer.parseInt(array[1])));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@CheckReturnValue
package com.github.benmanes.caffeine.cache.simulator.parser.cachelib;

import com.google.errorprone.annotations.CheckReturnValue;
1 change: 1 addition & 0 deletions simulator/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ caffeine.simulator {
# address: format of UCSD program address traces
# address-penalties: format of UCSD program address traces with hit & miss penalties
# cache2k: format from the author of the Cache2k library
# cachelib: format from the author of the Cachelib library
# camelab: format of the Camelab storage traces
# cloud-physics: format of the Cloud Physics traces
# corda: format of Corda traces
Expand Down

0 comments on commit 0670fce

Please sign in to comment.