Skip to content

Commit

Permalink
add snia enterprise and baleen trace formats to the simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Sep 14, 2024
1 parent 2689917 commit dad696a
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.github.benmanes.caffeine.cache.simulator.parser.address.AddressTraceReader;
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.baleen.BaleenTraceReader;
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;
Expand All @@ -41,6 +42,7 @@
import com.github.benmanes.caffeine.cache.simulator.parser.lrb.LrbTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.scarab.ScarabTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.snia.cambridge.CambridgeTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.snia.enterprise.EnterpriseTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.snia.keyvalue.ObjectStoreTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.snia.parallel.K5cloudTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.snia.parallel.TencentBlockTraceReader;
Expand Down Expand Up @@ -69,6 +71,7 @@ public enum TraceFormat {
ADDRESS_PENALTIES(AddressPenaltiesTraceReader::new),
ADAPT_SIZE(AdaptSizeTraceReader::new),
ARC(ArcTraceReader::new),
BALEEN(BaleenTraceReader::new),
CACHE2K(Cache2kTraceReader::new),
CACHELIB(CachelibTraceReader::new),
CAMELAB(CamelabTraceReader::new),
Expand All @@ -83,6 +86,7 @@ public enum TraceFormat {
OUTBRAIN(OutbrainTraceReader::new),
SCARAB(ScarabTraceReader::new),
SNIA_CAMBRIDGE(CambridgeTraceReader::new),
SNIA_ENTERPRISE(EnterpriseTraceReader::new),
SNIA_K5CLOUD(K5cloudTraceReader::new),
SNIA_OBJECT_STORE(ObjectStoreTraceReader::new),
SNIA_SYSTOR(SystorTraceReader::new),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2024 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.baleen;

import java.math.RoundingMode;
import java.util.stream.LongStream;

import com.github.benmanes.caffeine.cache.simulator.parser.TextTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.TraceReader.KeyOnlyTraceReader;
import com.google.common.math.IntMath;

/**
* A reader for the trace files provided by the authors of the Baleen algorithm. See
* <a href="https://ftp.pdl.cmu.edu/pub/datasets/Baleen24">traces</a>.
*
* @author [email protected] (Ben Manes)
*/
public final class BaleenTraceReader extends TextTraceReader implements KeyOnlyTraceReader {
private static final int SEGMENT_SIZE = 128 * 1024;

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

@Override
public LongStream keys() {
return lines()
.dropWhile(line -> line.startsWith("#"))
.map(line -> line.split(" ", 6))
.filter(line -> isRead(line[4].charAt(0)))
.flatMapToLong(line -> {
long block = Long.parseLong(line[0]);
long byteOffset = Long.parseLong(line[1]);
int size = Integer.parseInt(line[2]);

int startSegment = Math.toIntExact(byteOffset / SEGMENT_SIZE);
int sequence = IntMath.divide(size, SEGMENT_SIZE, RoundingMode.UP);

long startKey = ((long) Long.hashCode(block) << 32) | startSegment;
return LongStream.range(startKey, startKey + sequence);
});
}

private static boolean isRead(char operation) {
return (operation == '1') || (operation == '2') || (operation == '5');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@CheckReturnValue
package com.github.benmanes.caffeine.cache.simulator.parser.baleen;

import com.google.errorprone.annotations.CheckReturnValue;
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2024 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.snia.enterprise;

import java.math.RoundingMode;
import java.util.function.Predicate;
import java.util.stream.LongStream;

import com.github.benmanes.caffeine.cache.simulator.parser.TextTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.TraceReader.KeyOnlyTraceReader;
import com.google.common.math.IntMath;

/**
* A reader for the SNIA Microsoft Enterprise trace files provided by
* <a href="https://iotta.snia.org/traces/block-io/130">SNIA</a> in the
* Event Tracing for Windows format.
*
* @author [email protected] (Ben Manes)
*/
public final class EnterpriseTraceReader
extends TextTraceReader implements KeyOnlyTraceReader {
private static final int BLOCK_SIZE = 4096;

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

@Override
public LongStream keys() {
return lines()
.dropWhile(new SkipHeader())
.filter(line -> line.stripLeading().startsWith("DiskRead,"))
.map(line -> line.split(",", 8))
.flatMapToLong(line -> {
long byteOffset = Long.parseLong(line[5].strip().substring(2), 16);
int size = Integer.parseInt(line[6].strip().substring(2), 16);

long startBlock = byteOffset / BLOCK_SIZE;
int sequence = IntMath.divide(size, BLOCK_SIZE, RoundingMode.UP);
return LongStream.range(startBlock, startBlock + sequence);
});
}

private static final class SkipHeader implements Predicate<String> {
private boolean isHeader;

@Override public boolean test(String line) {
if (line.equals("BeginHeader")) {
isHeader = true;
} else if (line.equals("EndHeader")) {
isHeader = false;
}
return isHeader;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@CheckReturnValue
package com.github.benmanes.caffeine.cache.simulator.parser.snia.enterprise;

import com.google.errorprone.annotations.CheckReturnValue;
2 changes: 2 additions & 0 deletions simulator/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ caffeine.simulator {
# adapt-size: format from the authors of the AdaptSize algorithm
# address: format of UCSD program address traces
# address-penalties: format of UCSD program address traces with hit & miss penalties
# baleen: format from the authors of the Baleen algorithm
# 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
Expand All @@ -514,6 +515,7 @@ caffeine.simulator {
# outbrain: format of Outbrain's trace provided on Kaggle
# scarab: format of Scarab Research traces
# snia-cambridge: format of the SNIA MSR Cambridge traces
# snia-enterprise: format of the SNIA MS Enterprise traces
# snia-k5cloud: format of the SNIA K5cloud traces
# snia-object-store: format of the SNIA IBM ObjectStore traces
# snia-systor: format of the SNIA SYSTOR '17 traces
Expand Down

0 comments on commit dad696a

Please sign in to comment.