Skip to content

Commit

Permalink
Add K5 cloud traces to the simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Aug 17, 2020
1 parent 383f834 commit 057a78d
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.github.benmanes.caffeine.cache.simulator.parser.lirs.LirsTraceReader;
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.parallel.K5cloudTraceReader;
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.umass.network.YoutubeTraceReader;
Expand Down Expand Up @@ -68,6 +69,7 @@ public enum TraceFormat {
OUTBRAIN(OutbrainTraceReader::new),
SCARAB(ScarabTraceReader::new),
SNIA_CAMBRIDGE(CambridgeTraceReader::new),
SNIA_K5CLOUD(K5cloudTraceReader::new),
SNIA_TENCENT_BLOCK(TencentBlockTraceReader::new),
SNIA_TENCENT_PHOTO(TencentPhotoTraceReader::new),
UMASS_STORAGE(StorageTraceReader::new),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright 2020 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.parallel;

import java.io.IOException;
import java.util.stream.LongStream;

import com.github.benmanes.caffeine.cache.simulator.parser.TextTraceReader;
import com.github.benmanes.caffeine.cache.simulator.parser.TraceReader.KeyOnlyTraceReader;

/**
* A reader for the K5cloud trace files provided by
* <a href="http://iotta.snia.org/tracetypes/4">SNIA</a>.
*
* @author [email protected] (Ben Manes)
*/
public final class K5cloudTraceReader extends TextTraceReader implements KeyOnlyTraceReader {
static final int BLOCK_SIZE = 512;

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

@Override
public LongStream keys() throws IOException {
return lines()
.map(line -> line.split(","))
.filter(array -> array[2].charAt(0) == 'R')
.flatMapToLong(array -> {
long offset = Long.parseLong(array[3]);
long startBlock = (offset / BLOCK_SIZE);
int sequence = Integer.parseInt(array[4]) / BLOCK_SIZE;
return LongStream.range(startBlock, startBlock + sequence);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
package com.github.benmanes.caffeine.cache.simulator.parser.snia.parallel;

import java.io.IOException;
import java.util.List;
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.base.Splitter;

/**
* A reader for the Tencent Block Storage trace files provided by
Expand All @@ -30,25 +28,25 @@
* @author [email protected] (Ben Manes)
*/
public final class TencentBlockTraceReader extends TextTraceReader implements KeyOnlyTraceReader {
static final Splitter splitter = Splitter.on(',');
static final int BLOCK_SIZE = 512;
static final char WRITE = '1';
static final char READ = '0';

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

@Override
public LongStream keys() throws IOException {
return lines().flatMapToLong(line -> {
List<String> list = splitter.splitToList(line);
if (list.get(3).charAt(0) == WRITE) {
return LongStream.empty();
}
long offset = Long.parseLong(list.get(1));
long startBlock = (offset / BLOCK_SIZE);
int sequence = Integer.parseInt(list.get(2));
return LongStream.range(startBlock, startBlock + sequence);
});
return lines()
.map(line -> line.split(","))
.filter(array -> array[3].charAt(0) == READ)
.flatMapToLong(array -> {
long offset = Long.parseLong(array[1]);
long startBlock = (offset / BLOCK_SIZE);
int sequence = Integer.parseInt(array[2]);
int volumeId = Integer.parseInt(array[4]);
long key = (((long) volumeId) << 31) | Long.hashCode(startBlock);
return LongStream.range(key, key + sequence);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void record(long key) {
if (node == null) {
onMiss(key);
} else if (node.status == Status.NON_RESIDENT) {
onNonResidentHir(node);
onNonResidentHit(node);
} else if (node.status == Status.INACTIVE) {
onInactiveHit(node);
} else if (node.status == Status.ACTIVE) {
Expand Down Expand Up @@ -149,7 +149,7 @@ private void onActiveHit(Node node) {
policyStats.recordHit();
}

private void onNonResidentHir(Node node) {
private void onNonResidentHit(Node node) {
// So when a refault distance of (R - E) is observed and there are at least (R - E) active
// pages, the refaulting page is activated optimistically in the hope that (R - E) active pages
// are actually used less frequently than the refaulting page - or even not used at all anymore.
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 @@ -453,6 +453,7 @@ caffeine.simulator {
# outbrain: format from Outbrain trace provided on Kaggle
# scarab: format of Scarab Research traces
# snia-cambridge: format from the SNIA MSR Cambridge traces
# snia-k5cloud: format from the SNIA K5cloud traces
# snia-tencent-block: format from the SNIA Tencent Block traces
# snia-tencent-photo: format from the SNIA Tencent Photo traces
# umass-storage: format from the University of Massachusetts storage traces
Expand Down

0 comments on commit 057a78d

Please sign in to comment.