Skip to content

Commit ae7df99

Browse files
committed
Merge remote-tracking branch 'origin/1.20' into 1.21.1
2 parents 619e15e + a170f07 commit ae7df99

File tree

8 files changed

+75
-67
lines changed

8 files changed

+75
-67
lines changed

common/src/main/java/org/embeddedt/modernfix/ModernFixClient.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.embeddedt.modernfix.api.entrypoint.ModernFixClientIntegration;
1010
import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
1111
import org.embeddedt.modernfix.platform.ModernFixPlatformHooks;
12+
import org.embeddedt.modernfix.spark.SparkLaunchProfiler;
1213
import org.embeddedt.modernfix.util.ClassInfoManager;
1314
import org.embeddedt.modernfix.world.IntegratedWatchdog;
1415

@@ -90,6 +91,9 @@ public void onRenderTickEnd() {
9091
ModernFix.LOGGER.warn("Time from main menu to in-game was " + timeSpentLoading + " seconds");
9192
ModernFix.LOGGER.warn("Total time to load game and open world was " + (timeSpentLoading + gameStartTimeSeconds) + " seconds");
9293
}
94+
if (ModernFixPlatformHooks.INSTANCE.modPresent("spark") && ModernFixMixinPlugin.instance.isOptionEnabled("feature.spark_profile_world_join.WorldJoin")) {
95+
SparkLaunchProfiler.stop("world_join");
96+
}
9397
resetWorldLoadStateMachine();
9498
}
9599
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.embeddedt.modernfix.common.mixin.feature.spark_profile_world_join;
2+
3+
import net.minecraft.client.Minecraft;
4+
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
5+
import org.embeddedt.modernfix.spark.SparkLaunchProfiler;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.injection.At;
8+
import org.spongepowered.asm.mixin.injection.Inject;
9+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
10+
11+
@Mixin(Minecraft.class)
12+
@ClientOnlyMixin
13+
public class MinecraftMixin {
14+
@Inject(method = "prepareForMultiplayer", at = @At("HEAD"))
15+
private void startProfiling(CallbackInfo ci) {
16+
SparkLaunchProfiler.start("world_join");
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.embeddedt.modernfix.common.mixin.feature.spark_profile_world_join;
2+
3+
import net.minecraft.server.WorldLoader;
4+
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
5+
import org.embeddedt.modernfix.spark.SparkLaunchProfiler;
6+
import org.spongepowered.asm.mixin.Mixin;
7+
import org.spongepowered.asm.mixin.injection.At;
8+
import org.spongepowered.asm.mixin.injection.Inject;
9+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
10+
11+
@Mixin(WorldLoader.class)
12+
@ClientOnlyMixin
13+
public class WorldLoaderMixin {
14+
@Inject(method = "load", at = @At("HEAD"))
15+
private static void startProfiling(CallbackInfoReturnable<?> cir) {
16+
SparkLaunchProfiler.start("world_join");
17+
}
18+
}

common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/memoize_creative_tab_build/CreativeModeTabMixin.java

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22

33
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
44
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
5+
import net.minecraft.core.registries.BuiltInRegistries;
56
import net.minecraft.world.item.CreativeModeTab;
67
import org.spongepowered.asm.mixin.Mixin;
8+
import org.spongepowered.asm.mixin.Shadow;
79
import org.spongepowered.asm.mixin.Unique;
810

911
@Mixin(CreativeModeTab.class)
10-
public class CreativeModeTabMixin {
12+
public abstract class CreativeModeTabMixin {
13+
@Shadow public abstract CreativeModeTab.Type getType();
14+
1115
@Unique
1216
private CreativeModeTab.ItemDisplayParameters mfix$oldParameters;
1317

18+
@Unique
19+
private static boolean MFIX$REBUILT_NON_CATEGORY = false;
20+
1421
/**
1522
* @author embeddedt
1623
* @reason Vanilla already does similar memoization in the CreativeModeTabs class, but mods often have to bypass
@@ -20,9 +27,26 @@ public class CreativeModeTabMixin {
2027
*/
2128
@WrapMethod(method = "buildContents")
2229
private synchronized void buildContentsIfChanged(CreativeModeTab.ItemDisplayParameters parameters, Operation<Void> original) {
23-
if (mfix$oldParameters == null || mfix$oldParameters.needsUpdate(parameters.enabledFeatures(), parameters.hasPermissions(), parameters.holders())) {
24-
original.call(parameters);
30+
synchronized (CreativeModeTab.class) {
31+
if (mfix$oldParameters == null || mfix$oldParameters.needsUpdate(parameters.enabledFeatures(), parameters.hasPermissions(), parameters.holders())) {
32+
original.call(parameters);
33+
if (this.getType() == CreativeModeTab.Type.CATEGORY) {
34+
if (MFIX$REBUILT_NON_CATEGORY) {
35+
// We must mark every other tab that's not a category as needing rebuild. Not doing this causes mods
36+
// that build a search tab early on without having built the dependencies to permanently leave it
37+
// in a broken state.
38+
for (CreativeModeTab tab : BuiltInRegistries.CREATIVE_MODE_TAB) {
39+
if (tab.getType() != CreativeModeTab.Type.CATEGORY) {
40+
((CreativeModeTabMixin)(Object)tab).mfix$oldParameters = null;
41+
}
42+
}
43+
MFIX$REBUILT_NON_CATEGORY = false;
44+
}
45+
} else {
46+
MFIX$REBUILT_NON_CATEGORY = true;
47+
}
48+
}
49+
mfix$oldParameters = parameters;
2550
}
26-
mfix$oldParameters = parameters;
2751
}
2852
}

common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/nbt_memory_usage/CompoundTag1Mixin.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/nbt_memory_usage/CompoundTagMixin.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ public DefaultSettingMapBuilder put(String key, Boolean value) {
181181
.put("mixin.feature.snapshot_easter_egg", true)
182182
.put("mixin.feature.warn_missing_perf_mods", true)
183183
.put("mixin.feature.spark_profile_launch", false)
184+
.put("mixin.feature.spark_profile_world_join", false)
184185
.put("mixin.feature.log_stdout_in_log_files", true)
185186
.put("mixin.devenv", isDevEnv)
186187
.putConditionally(() -> !isFabric, "mixin.bugfix.fix_config_crashes", true)
@@ -237,6 +238,7 @@ private ModernFixEarlyConfig(File file) {
237238
disableIfModPresent("mixin.bugfix.buffer_builder_leak", "isometric-renders", "witherstormmod");
238239
disableIfModPresent("mixin.feature.remove_chat_signing", "nochatreports");
239240
disableIfModPresent("mixin.perf.faster_texture_loading", "stitch", "optifine", "changed");
241+
disableIfModPresent("mixin.perf.faster_ingredients", "vmp");
240242
if(isFabric) {
241243
disableIfModPresent("mixin.bugfix.packet_leak", "memoryleakfix");
242244
}

common/src/main/java/org/embeddedt/modernfix/spark/SparkLaunchProfiler.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,19 @@ public class SparkLaunchProfiler {
3636
private static ExecutorService executor = Executors.newSingleThreadScheduledExecutor((new ThreadFactoryBuilder()).setNameFormat("spark-modernfix-async-worker").build());
3737
private static final SparkPlatform platform = new SparkPlatform(new ModernFixSparkPlugin());
3838

39-
private static final boolean USE_JAVA_SAMPLER_FOR_LAUNCH = true; //Boolean.getBoolean("modernfix.profileLaunchWithJavaSampler");
39+
private static final boolean USE_JAVA_SAMPLER_FOR_LAUNCH = !Boolean.getBoolean("modernfix.profileWithAsyncSampler");
40+
private static final int SAMPLING_INTERVAL = Integer.getInteger("modernfix.profileSamplingIntervalMicroseconds", 4000);
41+
private static final String THREAD_GROUPER = System.getProperty("modernfix.profileSamplingThreadGrouper", "by-pool");
4042

4143
public static void start(String key) {
4244
if (!ongoingSamplers.containsKey(key)) {
4345
Sampler sampler;
44-
SamplerSettings settings = new SamplerSettings(4000, ThreadDumper.ALL, ThreadGrouper.BY_NAME.get(), -1, false, true);
46+
SamplerSettings settings = new SamplerSettings(SAMPLING_INTERVAL, ThreadDumper.ALL, ThreadGrouper.parseConfigSetting(THREAD_GROUPER).get(), -1, false, true);
4547
try {
4648
if(USE_JAVA_SAMPLER_FOR_LAUNCH) {
4749
throw new UnsupportedOperationException();
4850
}
49-
sampler = new AsyncSampler(platform, settings, new SampleCollector.Execution(4000));
51+
sampler = new AsyncSampler(platform, settings, new SampleCollector.Execution(SAMPLING_INTERVAL));
5052
} catch (UnsupportedOperationException e) {
5153
sampler = new JavaSampler(platform, settings);
5254
}

0 commit comments

Comments
 (0)