Skip to content

Commit

Permalink
Temp for debugging excessive memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
NadavKeren committed Dec 25, 2024
1 parent f0184bc commit 5aebfb4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion simulator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ tasks.named('run').configure {
it.getKey().startsWith('akka') || it.getKey().startsWith('caffeine')
}

jvmArgs '-XX:+UseParallelGC', '-Xmx4g'
jvmArgs '-XX:+UseParallelGC', '-Xmx14g'
if (project.hasProperty('jvmArgs')) {
jvmArgs project.jvmArgs.split(',')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public final class PolicyActor extends AbstractBehavior<PolicyActor.Command> {
private final Policy policy;
private int eventNumber = 0;

private static final long MEMORY_THERSHOLD_GIGA = 4;
private static final long GIGABYTE = 1073741824L;

public PolicyActor(ActorContext<Command> context,
ActorRef<Simulator.Command> simulator, Policy policy) {
super(context);
Expand All @@ -59,11 +62,19 @@ public Receive<Command> createReceive() {
}

private Behavior<Command> process(List<AccessEvent> events) {
Runtime runtime = Runtime.getRuntime();
policy.stats().stopwatch().start();
for (AccessEvent event : events) {
event.setEventNum(eventNumber++);
try {
policy.record(event);
if (eventNumber % 1000000 == 0) {
double currentRAMUsage = (double) runtime.totalMemory() / GIGABYTE;
System.out.println(eventNumber / 1000000 + "m: Memory Used: " + currentRAMUsage + " GB");
if (currentRAMUsage > MEMORY_THERSHOLD_GIGA) {
System.out.println("Exceeded the threshold");
}
}
} catch (RuntimeException e) {
System.err.println("Error on event: " + event.eventNum());
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ private void registerSketch() {
registerMany(GhostHillClimberTinyLfuPolicy.class, GhostHillClimberTinyLfuPolicy::policies);
registerMany(AdaptiveCAPolicy.class, AdaptiveCAPolicy::policies);
register(AdaptiveCAWithBurstBlockPolicy.class, AdaptiveCAWithBurstBlockPolicy::policy);
register(AdaptivePipelineCache.class, AdaptivePipelineCache::new);

register(TinyCachePolicy.class, TinyCachePolicy::new);
register(WindowTinyCachePolicy.class, WindowTinyCachePolicy::new);
Expand Down

0 comments on commit 5aebfb4

Please sign in to comment.