-
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.
Add support for LRB traces to the simulator
LRB offers a 17gb cdn trace (2.8B events) that it was analyzed against. The archive support was improved so that a tar.gz can be supplied and the entries will be concatenated. When hit/miss penalty support was added, the Optimal policy degraded by having to hold the entire event in-memory. This is now conditioned so that for non-latency traces only the key (primitive long) is held. This reduces GC pressure and improves performance on large traces.
- Loading branch information
Showing
14 changed files
with
249 additions
and
75 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
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
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
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
54 changes: 54 additions & 0 deletions
54
...src/main/java/com/github/benmanes/caffeine/cache/simulator/parser/lrb/LrbTraceReader.java
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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.lrb; | ||
|
||
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 LRB algorithm. See | ||
* <a href="https://github.com/sunnyszy/lrb#trace">traces</a>. | ||
* | ||
* @author ben.manes@gmail.com (Ben Manes) | ||
*/ | ||
public final class LrbTraceReader extends TextTraceReader { | ||
|
||
public LrbTraceReader(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 -> { | ||
return AccessEvent.forKeyAndWeight( | ||
Long.parseLong(array[1]), Integer.parseInt(array[2])); | ||
}); | ||
} | ||
} |
Oops, something went wrong.
23cd333
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it the same format as
adapt_size
? (it comes from the same group)23cd333
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ohadeytan oops, you’re right. There is a new column, extra_features, which I ignored. I can’t tell if they still hash the key+weight, though, as the caffeine runner does not. So maybe having both isn’t so bad...