Просмотр исходного кода

Disable threading detector optimization by default, closes #62

malte0811 3 лет назад
Родитель
Сommit
7643560db7

+ 5 - 3
Common/src/main/java/malte0811/ferritecore/mixin/config/FerriteConfig.java

@@ -51,9 +51,11 @@ public class FerriteConfig {
                 "bakedQuadDeduplication",
                 "Deduplicate vertex data of baked quads in the basic model implementations"
         );
-        THREADING_DETECTOR = builder.createOption(
-                "smallThreadingDetector",
-                "Replace objects used to detect multi-threaded access to chunks by a much smaller field"
+        THREADING_DETECTOR = builder.createOptInOption(
+                "useSmallThreadingDetector",
+                "Replace objects used to detect multi-threaded access to chunks by a much smaller field. This option" +
+                        " is disabled by default due to very rare and very hard-to-reproduce crashes, use at your own" +
+                        " risk!"
         );
         COMPACT_FAST_MAP = builder.createOptInOption(
                 "compactFastMap",

+ 13 - 3
Common/src/main/java/malte0811/ferritecore/mixin/config/FerriteMixinConfig.java

@@ -21,29 +21,39 @@ public abstract class FerriteMixinConfig implements IMixinConfigPlugin {
         HAS_LITHIUM = hasClass("me.jellysquid.mods.lithium.common.LithiumMod");
         HAS_ROADRUNNER = hasClass("me.jellysquid.mods.lithium.common.RoadRunner");
     }
+
     private String prefix = null;
     private final FerriteConfig.Option enableOption;
     private final LithiumSupportState lithiumState;
+    private final boolean optIn;
 
-    protected FerriteMixinConfig(FerriteConfig.Option enableOption, LithiumSupportState lithiumCompat) {
+    protected FerriteMixinConfig(
+            FerriteConfig.Option enableOption, LithiumSupportState lithiumCompat, boolean optIn
+    ) {
         this.enableOption = enableOption;
         this.lithiumState = lithiumCompat;
+        this.optIn = optIn;
     }
 
     protected FerriteMixinConfig(FerriteConfig.Option enableOption) {
-        this(enableOption, LithiumSupportState.NO_CONFLICT);
+        this(enableOption, LithiumSupportState.NO_CONFLICT, false);
     }
 
     @Override
     public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
         Preconditions.checkState(mixinClassName.startsWith(prefix), "Unexpected prefix on " + mixinClassName);
         if (!enableOption.isEnabled()) {
-            LOGGER.warn("Mixin " + mixinClassName + " is disabled by config");
+            if (!optIn) {
+                LOGGER.warn("Mixin " + mixinClassName + " is disabled by config");
+            }
             return false;
         } else if (!this.lithiumState.shouldApply()) {
             LOGGER.warn("Mixin " + mixinClassName + " is disabled automatically as lithium is installed");
             return false;
         } else {
+            if (optIn) {
+                LOGGER.warn("Opt-in mixin {} is enabled by config", mixinClassName);
+            }
             return true;
         }
     }

+ 1 - 1
Common/src/main/java/malte0811/ferritecore/mixin/threaddetec/Config.java

@@ -5,6 +5,6 @@ import malte0811.ferritecore.mixin.config.FerriteMixinConfig;
 
 public class Config extends FerriteMixinConfig {
     public Config() {
-        super(FerriteConfig.THREADING_DETECTOR, LithiumSupportState.APPLY_IF_ROADRUNNER);
+        super(FerriteConfig.THREADING_DETECTOR, LithiumSupportState.APPLY_IF_ROADRUNNER, true);
     }
 }

+ 3 - 1
summary.md

@@ -158,4 +158,6 @@ with a non-atomic one, and does not need any additional atomic operations.
 Saved memory: 10-15 MB with only one player, more if more chunks are loaded. Does not depend on modpack size.  
 CPU impact: None or slightly negative  
 Side: Both  
-Mixin subpackage: `threaddetec`
+Mixin subpackage: `threaddetec`  
+Notes: Currently this optimization is disabled by default, since it seems to cause (very) rare race conditions under
+unknown circumstances.