Merge remote-tracking branch 'origin/1.18' into 1.19.2
This commit is contained in:
commit
912a8f9f2c
|
|
@ -17,15 +17,13 @@ import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.IntFunction;
|
import java.util.function.IntFunction;
|
||||||
|
|
||||||
public class DFUBlaster {
|
public class DFUBlaster {
|
||||||
|
private static final Cache<Pair<IntFunction<RewriteResult<?, ?>>, Integer>, RewriteResult<?, ?>> hmapApplyCache = CacheBuilder.newBuilder()
|
||||||
|
.expireAfterAccess(3, TimeUnit.MINUTES)
|
||||||
|
.build();
|
||||||
|
private static final Cache<Triple<Type<?>, TypeRewriteRule, PointFreeRule>, Optional<? extends RewriteResult<?, ?>>> rewriteCache = CacheBuilder.newBuilder()
|
||||||
|
.expireAfterAccess(3, TimeUnit.MINUTES)
|
||||||
|
.build();
|
||||||
public static void blastMaps() {
|
public static void blastMaps() {
|
||||||
Cache<Pair<IntFunction<RewriteResult<?, ?>>, Integer>, RewriteResult<?, ?>> hmapApplyCache = CacheBuilder.newBuilder()
|
|
||||||
.maximumSize(200) /* should mean approximately 50MB used max */
|
|
||||||
.expireAfterAccess(3, TimeUnit.MINUTES)
|
|
||||||
.build();
|
|
||||||
Cache<Triple<Type<?>, TypeRewriteRule, PointFreeRule>, Optional<? extends RewriteResult<?, ?>>> rewriteCache = CacheBuilder.newBuilder()
|
|
||||||
.maximumSize(1000)
|
|
||||||
.expireAfterAccess(3, TimeUnit.MINUTES)
|
|
||||||
.build();
|
|
||||||
try {
|
try {
|
||||||
Class<?> FOLD_CLASS = Class.forName("com.mojang.datafixers.functions.Fold");
|
Class<?> FOLD_CLASS = Class.forName("com.mojang.datafixers.functions.Fold");
|
||||||
Field hmapField = FOLD_CLASS.getDeclaredField("HMAP_APPLY_CACHE");
|
Field hmapField = FOLD_CLASS.getDeclaredField("HMAP_APPLY_CACHE");
|
||||||
|
|
@ -41,8 +39,30 @@ public class DFUBlaster {
|
||||||
base = unsafe.staticFieldBase(rewriteCacheField);
|
base = unsafe.staticFieldBase(rewriteCacheField);
|
||||||
offset = unsafe.staticFieldOffset(rewriteCacheField);
|
offset = unsafe.staticFieldOffset(rewriteCacheField);
|
||||||
unsafe.putObject(base, offset, rewriteCache.asMap());
|
unsafe.putObject(base, offset, rewriteCache.asMap());
|
||||||
|
new CleanerThread().start();
|
||||||
} catch(Throwable e) {
|
} catch(Throwable e) {
|
||||||
ModernFix.LOGGER.error("Could not replace DFU map", e);
|
ModernFix.LOGGER.error("Could not replace DFU map", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class CleanerThread extends Thread {
|
||||||
|
CleanerThread() {
|
||||||
|
this.setName("DFU cleaning thread");
|
||||||
|
this.setPriority(1);
|
||||||
|
this.setDaemon(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
while(true) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(15000);
|
||||||
|
} catch(InterruptedException e){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
rewriteCache.cleanUp();
|
||||||
|
hmapApplyCache.cleanUp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ public class LazyDataFixer implements DataFixer {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if(backingDataFixer == null) {
|
if(backingDataFixer == null) {
|
||||||
LOGGER.info("Instantiating Mojang DFU");
|
LOGGER.info("Instantiating Mojang DFU");
|
||||||
|
DFUBlaster.blastMaps();
|
||||||
backingDataFixer = dfuSupplier.get();
|
backingDataFixer = dfuSupplier.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ import net.minecraftforge.network.PacketDistributor;
|
||||||
import net.minecraftforge.server.ServerLifecycleHooks;
|
import net.minecraftforge.server.ServerLifecycleHooks;
|
||||||
import org.embeddedt.modernfix.forge.classloading.FastAccessTransformerList;
|
import org.embeddedt.modernfix.forge.classloading.FastAccessTransformerList;
|
||||||
import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
|
import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
|
||||||
import org.embeddedt.modernfix.dfu.DFUBlaster;
|
|
||||||
import org.embeddedt.modernfix.forge.packet.PacketHandler;
|
import org.embeddedt.modernfix.forge.packet.PacketHandler;
|
||||||
import org.embeddedt.modernfix.util.DummyList;
|
import org.embeddedt.modernfix.util.DummyList;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
|
|
@ -127,7 +126,6 @@ public class ModernFixPlatformHooksImpl {
|
||||||
|
|
||||||
public static void injectPlatformSpecificHacks() {
|
public static void injectPlatformSpecificHacks() {
|
||||||
FastAccessTransformerList.attemptReplace();
|
FastAccessTransformerList.attemptReplace();
|
||||||
DFUBlaster.blastMaps();
|
|
||||||
|
|
||||||
/* https://github.com/FabricMC/Mixin/pull/99 */
|
/* https://github.com/FabricMC/Mixin/pull/99 */
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user