Skip to content

Commit

Permalink
LoliASM 2.0 - check changelog.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Rongmario committed May 3, 2021
1 parent fd51093 commit 6db0583
Show file tree
Hide file tree
Showing 49 changed files with 2,579 additions and 338 deletions.
35 changes: 30 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
buildscript {
repositories {
jcenter()
maven { url = "https://files.minecraftforge.net/maven" }
maven { url = 'https://files.minecraftforge.net/maven' }
maven { url = 'https://repo.spongepowered.org/maven' }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
}
}

apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'org.spongepowered.mixin'
//Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.


version = "1.1"
version = "2.0"
group = "zone.rong.loliasm" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "loliasm"

Expand Down Expand Up @@ -45,12 +47,27 @@ repositories {

jcenter()

maven {
url "https://repo.spongepowered.org/maven"
}

}

dependencies {

embed 'me.nallar.whocalled:WhoCalled:1.1'

// implementation ("org.spongepowered:mixin:0.8.3-SNAPSHOT") {
embed ("org.spongepowered:mixin:0.8") {
exclude module: "asm-commons"
exclude module: "asm-tree"
exclude module: "launchwrapper"
exclude module: "guava"
exclude module: "log4j-core"
exclude module: "gson"
exclude module: "commons-io"
}

}

processResources {
Expand All @@ -72,6 +89,12 @@ processResources {
}
}

sourceSets {
main {
ext.refMap = "mixins.loliasm.refmap.json"
}
}

jar {
from (configurations.embed.collect { it.isDirectory() ? it : zipTree(it) }) {
exclude 'LICENSE.txt', 'META-INF/MANIFSET.MF', 'META-INF/maven/**', 'META-INF/*.RSA', 'META-INF/*.SF'
Expand All @@ -80,7 +103,9 @@ jar {
attributes([
"FMLCorePluginContainsFMLMod": true,
"FMLCorePlugin": 'zone.rong.loliasm.LoliLoadingPlugin',
"ForceLoadAsMod": true
"ForceLoadAsMod": true,
"TweakClass": 'org.spongepowered.asm.launch.MixinTweaker',
"FMLAT": "loliasm_at.cfg"
])
}
}
21 changes: 21 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# LoliASM Changelog

## 2.0
- Revamped configuration. Some new options there. **REFRESH YOUR CONFIGS**
- Removed soft/hard patch variations for optimizing BakedQuads. Hard patch remains as it is now stable and saves more RAM.
- Implemented 'cleanupLaunchClassLoader' - saves lots of memory in the `LaunchClassLoader` caching things relating to class transformation/loading. *Foamfix* does this already to some fields but I've done it on more fields.
- Implemented 'remapperMemorySaver' - saves lots of memory in `FMLDeobfuscatingRemapper` by deduplicating Strings as well as not caching non-Minecraft/Forge classes/fields/methods.
- Implemented 'optimizeDataStructures' - optimizes structures around Minecraft. This will be updated nearly every version if I find any places that gives tangible results.
- Implemented 'optimizeFurnaceRecipes' - optimizes tick time when searching for FurnaceRecipes. By Hashing recipes and queries are only a hash lookup now rather than a loop => if match => return.
- Starting to implement object canonization, or deduplication as Foamfix calls it, hopefully it will match Foamfix and beat it out. We'll see.
- Starting to implement BlockStateContainer, StateImplementation memory squashers.
- Added mixins to do some of the leg work for me as I'm too lazy to write ASM all the time.
- Cleaned up `LoliReflector`, potentially an API candidate.
- Relocated some coremod classes.

## 1.1
- Fixed issues in some cases (first found in Thaumcraft) where redirecting BakedQuad::new calls would fail because of stackframe issues.

## 1.0
- First release.
- Optimizations on BakedQuads, soft/hard patch variants.
38 changes: 38 additions & 0 deletions src/main/java/com/google/common/collect/LoliEntrySet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.google.common.collect;

import javax.annotation.Nullable;
import java.util.Map;

public class LoliEntrySet<K> extends ImmutableSet<Map.Entry<K, Comparable<?>>> {

private final Object viewedState;

public LoliEntrySet(Object viewedState) {
this.viewedState = viewedState;
}

@Override
public UnmodifiableIterator<Map.Entry<K, Comparable<?>>> iterator() {
return new LoliIterator<>(i -> (Map.Entry<K, Comparable<?>>) LoliImmutableMap.stateAndIndex.getBy(viewedState, i), size());
}

@Override
public int size() {
return LoliImmutableMap.numProperties.applyAsInt(viewedState);
}

@Override
public boolean contains(@Nullable Object key) {
if (!(key instanceof Map.Entry)) {
return false;
}
Map.Entry<?, ?> entry = (Map.Entry<?, ?>) key;
Object valueInMap = LoliImmutableMap.stateAndKey.getBy(viewedState, entry.getKey());
return valueInMap != null && valueInMap.equals(entry.getValue());
}

@Override
boolean isPartialView() {
return false;
}
}
46 changes: 46 additions & 0 deletions src/main/java/com/google/common/collect/LoliImmutableMap.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.google.common.collect;

import zone.rong.loliasm.api.datastructures.fastmap.StateAndIndex;
import zone.rong.loliasm.api.datastructures.fastmap.StateAndKey;
import zone.rong.loliasm.api.datastructures.fastmap.FastMapStateHolder;

import javax.annotation.Nullable;
import java.util.function.ToIntFunction;

public class LoliImmutableMap<K> extends ImmutableMap<K, Comparable<?>> {

public static ToIntFunction<Object> numProperties;
public static StateAndKey stateAndKey;
public static StateAndIndex stateAndIndex;

private final FastMapStateHolder viewedState;

public LoliImmutableMap(FastMapStateHolder viewedState) {
this.viewedState = viewedState;
}

@Override
public int size() {
return numProperties.applyAsInt(viewedState);
}

@Override
public Comparable<?> get(@Nullable Object key) {
return stateAndKey.getBy(viewedState, key);
}

@Override
public ImmutableSet<Entry<K, Comparable<?>>> createEntrySet() {
return new LoliEntrySet<>(viewedState);
}

@Override
public ImmutableSet<Entry<K, Comparable<?>>> entrySet() {
return new LoliEntrySet<>(viewedState);
}

@Override
boolean isPartialView() {
return false;
}
}
29 changes: 29 additions & 0 deletions src/main/java/com/google/common/collect/LoliIterator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.google.common.collect;

import java.util.Map;
import java.util.function.IntFunction;

public class LoliIterator<K> extends UnmodifiableIterator<Map.Entry<K, Comparable<?>>>{

private final IntFunction<Map.Entry<K, Comparable<?>>> getIth;
private final int length;

private int currentIndex;

public LoliIterator(IntFunction<Map.Entry<K, Comparable<?>>> getIth, int length) {
this.getIth = getIth;
this.length = length;
}

@Override
public boolean hasNext() {
return currentIndex < length;
}

@Override
public Map.Entry<K, Comparable<?>> next() {
Map.Entry<K, Comparable<?>> next = getIth.apply(currentIndex);
++currentIndex;
return next;
}
}
63 changes: 63 additions & 0 deletions src/main/java/zone/rong/loliasm/LoliASM.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package zone.rong.loliasm;

import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.util.HttpUtil;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import zone.rong.loliasm.api.mixins.RegistrySimpleExtender;
import zone.rong.loliasm.client.models.MultipartBakedModelCache;
import zone.rong.loliasm.client.models.conditions.CanonicalConditions;

import java.util.ArrayList;
import java.util.List;

@Mod(modid = "loliasm", name = "LoliASM", version = "1.2")
@Mod.EventBusSubscriber
public class LoliASM {

public static List<RegistrySimpleExtender> simpleRegistryInstances = new ArrayList<>();

/*
private static Deduplicator deduplicator;
@SubscribeEvent(priority = EventPriority.LOWEST)
public static void onModelBake(ModelBakeEvent event) {
if (deduplicator == null) {
deduplicator = new Deduplicator();
}
IRegistry<ModelResourceLocation, IBakedModel> bakedModels = event.getModelRegistry();
Set<ModelResourceLocation> keys = bakedModels.getKeys();
ProgressManager.ProgressBar bar = ProgressManager.push("LoliASM: Optimizing IBakedModels", keys.size());
Stopwatch stopwatch = Stopwatch.createStarted();
for (ModelResourceLocation mrl : keys) {
bar.step(mrl.toString());
deduplicator.deduplicate(bakedModels.getObject(mrl));
}
LoliLogger.instance.info("It took {} to optimize IBakedModels", stopwatch.stop());
}
*/

@Mod.EventHandler
@SuppressWarnings("deprecation")
public void preInit(FMLPreInitializationEvent event) {
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(manager -> {
CanonicalConditions.destroyCache();
MultipartBakedModelCache.destroyCache();
});
}

@Mod.EventHandler
public void loadComplete(FMLLoadCompleteEvent event) {
// Map<ResourceLocation, IModel> cache = (Map<ResourceLocation, IModel>) LoliReflector.resolveFieldGetter(ModelLoaderRegistry.class, "cache").invokeExact();
// ProgressManager.ProgressBar bar = ProgressManager.push("Optimizing Models", cache.size(), true);
// deduplicator = null; // Free the deduplicator
LoliLogger.instance.info("Trimming simple registries");
HttpUtil.DOWNLOADER_EXECUTOR.execute(() -> {
simpleRegistryInstances.forEach(RegistrySimpleExtender::trim);
simpleRegistryInstances = null;
});
}

}
Loading

0 comments on commit 6db0583

Please sign in to comment.