-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For some reason the way we use sat4j seems to be non-optimal, leading to the full 5 seconds of optimising being used. (Removing this limit in the blanketcon pack leads to Sat4j churning for at least 20 mins to "prove" that it's found the most optimal result, with this PR Sat4j only takes ~60ms to solve the [remaining rules and options](https://gist.github.com/AlexIIL/86ba6059b4c6fbbd2b7a151667bf2608)). This means we can be more confident that we get a fully optimal solution in more cases. (When this isn't the case you'll see this line in the log: `Aborted mod solving optimisation due to timeout`) This also means we can use the solver system for more features, and be confident that it still finds the optimal solution quickly. Breaking changes: - Plugins can no longer override `LoadOption.equals` and `LoadOption.hashCode` Misc Changes: - Sat4jWrapper can now have rules changed at anytime, and correctly reverts back to solve it properly. Other changes from the src/main/resources/changelog/solver-pre-processor.txt file: * Added a pre-processor step to mod solving. * This greatly reduces the time taken for Sat4j to optimise the final mod set (pick the newest possible versions of every mod) * Previously this was capped at 5 seconds. * Added a warning when picking between two mods when we don't have any reason to pick one over the other. * This can happen when two mods provide each other, or two mods provide the same version of a third mod. * Added a system property to disable this "loader.mod_solving.disable_pre_processor" * Added a system property to explain what this pre-processor is struggling with (partially simplified mod sets) * "loader.mod_solving.print_results" prints unsolved sub-problems, and the final chosen options. * This is an alternative to the very verbose "loader.debug.mod_solving" property. * Made the log line "Aborted mod solving optimisation due to timeout" always print when it happens.
- Loading branch information
Showing
13 changed files
with
2,311 additions
and
372 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
71 changes: 71 additions & 0 deletions
71
src/main/java/org/quiltmc/loader/impl/solver/RuleComputeResult.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,71 @@ | ||
/* | ||
* Copyright 2023 QuiltMC | ||
* | ||
* 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 org.quiltmc.loader.impl.solver; | ||
|
||
import java.util.Map; | ||
|
||
import org.quiltmc.loader.api.plugin.solver.LoadOption; | ||
|
||
/** Returned by {@link RuleDefinition#computeConstants(Map)}. Valid values: | ||
* <ol> | ||
* <li>{@link #CONTRADICTION}</li> | ||
* <li>{@link #IDENTICAL}</li> | ||
* <li>{@link #TRIVIALLY_REMOVED}</li> | ||
* <li>{@link Changed}</li> | ||
* <li>{@link Removed}</li> | ||
* </ol> | ||
*/ | ||
/* sealed */ interface RuleComputeResult { | ||
static final RuleComputeResult CONTRADICTION = SimpleResult.CONTRADICTION; | ||
static final RuleComputeResult IDENTICAL = SimpleResult.IDENTICAL; | ||
static final RuleComputeResult TRIVIALLY_REMOVED = SimpleResult.TRIVIALLY_REMOVED; | ||
|
||
enum SimpleResult implements RuleComputeResult { | ||
CONTRADICTION, | ||
IDENTICAL, | ||
TRIVIALLY_REMOVED; | ||
} | ||
|
||
static abstract /* sealed */ class DeclaredConstants implements RuleComputeResult { | ||
final Map<LoadOption, Boolean> newConstants; | ||
|
||
private DeclaredConstants(Map<LoadOption, Boolean> newConstants) { | ||
this.newConstants = newConstants; | ||
} | ||
} | ||
|
||
/** Indicates that the rule definition fully inlined to constants, and doesn't need to be present in solving any | ||
* more. */ | ||
static final class Removed extends DeclaredConstants { | ||
|
||
Removed(Map<LoadOption, Boolean> newConstants) { | ||
super(newConstants); | ||
} | ||
} | ||
|
||
/** Indicates that the rule definition partially inlined to constants, and a different rule should now be used | ||
* instead. */ | ||
static final class Changed extends DeclaredConstants { | ||
final RuleDefinition newDefintion; | ||
|
||
Changed(RuleDefinition newDefintion, Map<LoadOption, Boolean> newConstants) { | ||
super(newConstants); | ||
this.newDefintion = newDefintion; | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.