Skip to content

Commit

Permalink
Add debug system properties for the mod discovery and resolution time…
Browse files Browse the repository at this point in the history
…outs
  • Loading branch information
sfPlayer1 committed Jul 17, 2021
1 parent d0ff21b commit 1e10604
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import net.fabricmc.loader.impl.metadata.NestedJarEntry;
import net.fabricmc.loader.impl.metadata.ParseMetadataException;
import net.fabricmc.loader.impl.util.ExceptionUtil;
import net.fabricmc.loader.impl.util.SystemProperties;
import net.fabricmc.loader.impl.util.log.Log;
import net.fabricmc.loader.impl.util.log.LogCategory;

Expand Down Expand Up @@ -97,8 +98,11 @@ public Collection<ModCandidate> discoverMods(FabricLoaderImpl loader) throws Mod

try {
pool.shutdown();
// Comment out for debugging
pool.awaitTermination(30, TimeUnit.SECONDS);

int timeout = Integer.getInteger(SystemProperties.DEBUG_DISCOVERY_TIMEOUT, 60);
if (timeout <= 0) timeout = Integer.MAX_VALUE;

pool.awaitTermination(timeout, TimeUnit.SECONDS);

for (Future<ModCandidate> future : futures) {
if (!future.isDone()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import net.fabricmc.loader.api.metadata.version.VersionInterval;
import net.fabricmc.loader.api.metadata.version.VersionPredicate;
import net.fabricmc.loader.impl.discovery.Explanation.ErrorKind;
import net.fabricmc.loader.impl.util.SystemProperties;
import net.fabricmc.loader.impl.util.log.Log;
import net.fabricmc.loader.impl.util.log.LogCategory;
import net.fabricmc.loader.impl.util.version.SemanticVersionImpl;
Expand All @@ -65,7 +66,9 @@ static Result solve(List<ModCandidate> allModsSorted, Map<String, List<ModCandid
solverPrepTime = System.nanoTime();

IPBSolver solver = SolverFactory.newDefaultOptimizer();
solver.setTimeout(60); // 60s

int timeout = Integer.getInteger(SystemProperties.DEBUG_RESOLUTION_TIMEOUT, 60);
if (timeout > 0) solver.setTimeout(timeout); // in seconds

DependencyHelper<DomainObject, Explanation> dependencyHelper = createDepHelper(solver);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public final class SystemProperties {
public static final String DEBUG_DISABLE_MOD_SHUFFLE = "fabric.debug.disableModShuffle";
// workaround for bad load order dependencies
public static final String DEBUG_LOAD_LATE = "fabric.debug.loadLate";
// override the mod discovery timeout, unit in seconds, <= 0 to disable
public static final String DEBUG_DISCOVERY_TIMEOUT = "fabric.debug.discoveryTimeout";
// override the mod resolution timeout, unit in seconds, <= 0 to disable
public static final String DEBUG_RESOLUTION_TIMEOUT = "fabric.debug.resolutionTimeout";

private SystemProperties() {
}
Expand Down

0 comments on commit 1e10604

Please sign in to comment.