Skip to content

Commit

Permalink
Lazy DFU
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Dec 24, 2021
1 parent af46c3b commit f032297
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

A fork of [gnembon's original CarpetMod for 1.13.2](https://github.com/gnembon/carpetmod). Thanks for gnembon's great tool allowing us to deal with bad performance of 1.13+.

Thanks to [Lithium mod](https://github.com/jellysquid3/lithium-fabric) for some epic optimizations
Thanks to [Lithium mod](https://github.com/jellysquid3/lithium-fabric) and [Lazy DFU](https://github.com/astei/lazydfu) for some epic optimizations

Thanks to [World Edit mod](https://github.com/EngineHub/WorldEdit) and [Spark mod](https://github.com/lucko/spark) for providing such powerful functionality extensions

Expand Down
1 change: 1 addition & 0 deletions docs/Features.md
Original file line number Diff line number Diff line change
Expand Up @@ -722,5 +722,6 @@ There are also a few optimizations which is not from lithium mod:
- Cache some property calculation about light in `IBlockState`
- Use multi-threading for chunk serializing during world saving
- Cache and skip redundant `session.lock` information check
- Make DataFixerUpper lazy like [Lazy DFU](https://github.com/astei/lazydfu)

If necessary, part of the optimization implementation can be switched manually in the `TISCMConfig` class
1 change: 1 addition & 0 deletions docs/Features_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -708,5 +708,6 @@ TISCM 中也有一些在 lithium mod 不包含的优化:
- 缓存了部分 `IBlockState` 中关于光照属性计算
- 在保存世界时使用多线程进行区块序列化操作
- 缓存并跳过冗余的 `session.lock` 信息检查
-[Lazy DFU](https://github.com/astei/lazydfu) 模组类似地让 DataFixerUpper 延后执行

如果需要,部分优化的实现可在 `TISCMConfig` 类中手动开关
22 changes: 22 additions & 0 deletions patches/net/minecraft/util/datafix/DataFixesManager.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- a/net/minecraft/util/datafix/DataFixesManager.java
+++ b/net/minecraft/util/datafix/DataFixesManager.java
@@ -1,5 +1,6 @@
package net.minecraft.util.datafix;

+import carpet.utils.TISCMConfig;
import com.google.common.collect.ImmutableMap;
import com.mojang.datafixers.DSL;
import com.mojang.datafixers.DataFixer;
@@ -133,7 +134,11 @@
{
DataFixerBuilder datafixerbuilder = new DataFixerBuilder(1631);
addFixers(datafixerbuilder);
- return datafixerbuilder.build(ForkJoinPool.commonPool());
+
+ // TISCM Lazy DFU
+// return datafixerbuilder.build(ForkJoinPool.commonPool());
+ //noinspection ConstantConditions
+ return datafixerbuilder.build(TISCMConfig.LAZY_DFU ? r -> {} : ForkJoinPool.commonPool());
}

public static DataFixer getDataFixer()
3 changes: 3 additions & 0 deletions src/main/java/carpet/utils/TISCMConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public class TISCMConfig
// When saving all chunks in a world, the session lock file is checked on processing each chunk and that's redundant
// This optimization performs the session lock check at the beginning of chunks saving and skip the following checks if it passes
public static final boolean MERGED_SESSION_LOCK_CHECK = TISCM_OPTIMIZATION_ENABLE && true;
// Lazy DFU Switch (https://github.com/astei/lazydfu)
// Not necessary to be under Mods since the code change is tiny
public static final boolean LAZY_DFU = TISCM_OPTIMIZATION_ENABLE && true;

// ============== Mods ==============

Expand Down

0 comments on commit f032297

Please sign in to comment.