-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
2,579 additions
and
338 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
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. |
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,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
46
src/main/java/com/google/common/collect/LoliImmutableMap.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,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; | ||
} | ||
} |
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,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; | ||
} | ||
} |
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,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; | ||
}); | ||
} | ||
|
||
} |
Oops, something went wrong.