Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make memory observer interval configurable #3161

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
make memory observer interval configurable
  • Loading branch information
nkuehnel committed Mar 12, 2024
commit 29519a5bd2b2b623e396d4a973c1d7f807a6f922
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ public enum CleanIterations {
private static final String COMPRESSION_TYPE = "compressionType";
private static final String EVENT_TYPE_TO_CREATE_SCORING_FUNCTIONS = "createScoringFunctionType";

private static final String MEMORY_OBSERVER_INTERVAL = "memoryObserverInterval";

/*package*/ static final String MOBSIM = "mobsim";
public enum MobsimType {qsim, JDEQSim, hermes}

Expand Down Expand Up @@ -109,6 +111,8 @@ public enum MobsimType {qsim, JDEQSim, hermes}

private CleanIterations cleanItersAtEnd = CleanIterations.keep;

private int memoryObserverInterval = 60;

public ControllerConfigGroup() {
super(GROUP_NAME);
}
Expand Down Expand Up @@ -151,6 +155,7 @@ public final Map<String, String> getComments() {
"to a file. `0' disables snapshots writing completely");
map.put(DUMP_DATA_AT_END, "true if at the end of a run, plans, network, config etc should be dumped to a file");
map.put(CLEAN_ITERS_AT_END, "Defines what should be done with the ITERS directory when a simulation finished successfully");
map.put(MEMORY_OBSERVER_INTERVAL, "Defines the interval for printing memory usage to the log in [seconds]. Must be positive. Defaults to 60.");
return map;
}

Expand Down Expand Up @@ -427,6 +432,17 @@ public EventTypeToCreateScoringFunctions getEventTypeToCreateScoringFunctions()
public void setEventTypeToCreateScoringFunctions(EventTypeToCreateScoringFunctions eventTypeToCreateScoringFunctions) {
this.eventTypeToCreateScoringFunctions = eventTypeToCreateScoringFunctions;
}

@StringGetter(MEMORY_OBSERVER_INTERVAL)
public int getMemoryObserverInterval() {
return memoryObserverInterval;
}

@StringSetter(MEMORY_OBSERVER_INTERVAL)
public void setMemoryObserverInterval(int memoryObserverInterval) {
this.memoryObserverInterval = memoryObserverInterval;
}

// ---
int writePlansUntilIteration = 1 ;
public int getWritePlansUntilIteration() {
Expand All @@ -450,5 +466,8 @@ protected void checkConsistency(Config config) {
log.warn( "this is not recommended, as it might result in a directory containing output from several model runs" );
log.warn( "prefer the options "+OverwriteFileSetting.deleteDirectoryIfExists+" or "+OverwriteFileSetting.failIfDirectoryExists );
}
if(config.controller().getMemoryObserverInterval() < 0) {
log.warn("Memory observer interval is negative. Simulation will most likely crash.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ final void setupOutputDirectory(OutputDirectoryHierarchy controlerIO) {
}

protected final void run(final Config config) {
MemoryObserver.start(60);
MemoryObserver.start(config.controller().getMemoryObserverInterval());
MatsimRuntimeModifications.MyRunnable runnable = new MatsimRuntimeModifications.MyRunnable() {
@Override
public void run() throws MatsimRuntimeModifications.UnexpectedShutdownException {
Expand Down