Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename stuff attempt 3 #6

Merged
merged 11 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: Barrium
path: ./build/libs/barium-fabric-0.1-SNAPSHOT-all.jar
path: ./build/libs/C2ME-fabric-0.1-SNAPSHOT-all.jar

17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<img width="200" src="https://yatopiamc.org/static/img/barrium.png" alt="Yatopia" align="right">
<div align="left">
<h1>Barium</h1>
<h1>C^2M-Engine</h1>

[![Github-CI](https://github.com/YatopiaMC/barium-fabric/workflows/Barium%20Build%20Script/badge.svg)](https://github.com/YatopiaMC/barium-fabric/actions?query=workflow%3ACI)
[![CodeMC](https://ci.codemc.io/buildStatus/icon?job=YatopiaMC%2Fbarium-fabric%2Fver%252F1.16.5)](https://ci.codemc.io/job/YatopiaMC/job/barium-fabric/job/ver%252F1.16.5/)
[![Github-CI](https://github.com/YatopiaMC/C2ME-fabric/workflows/C2ME%20Build%20Script/badge.svg)](https://github.com/YatopiaMC/C2ME-fabric/actions?query=workflow%3ACI)
[![CodeMC](https://ci.codemc.io/buildStatus/icon?job=YatopiaMC%2FC2ME-fabric%2Fver%252F1.16.5)](https://ci.codemc.io/job/YatopiaMC/job/C2ME-fabric/job/ver%252F1.16.5/)
[![Discord](https://img.shields.io/discord/342814924310970398?color=%237289DA&label=Discord&logo=discord&logoColor=white)](https://discord.io/YatopiaMC)
<h3>A Fabric mod designed to improve the chunk performance of Minecraft.</h3>
</div>

## So what is Barium?
Barium is a Fabric mod designed to improve the performance of chunk generation, I/O, and loading. This is done by taking advantage of multiple CPU cores in parallel. For the best performance it is recommended to use Barium with [Lithium](https://github.com/CaffeineMC/lithium-fabric) and [Starlight](https://github.com/Spottedleaf/Starlight).
## So what is C2ME?
C^2M-Engine or C2ME is a for short is a Fabric mod designed to improve the performance of chunk generation, I/O, and loading. This is done by taking advantage of multiple CPU cores in parallel. For the best performance it is recommended to use C2ME with [Lithium](https://github.com/CaffeineMC/lithium-fabric) and [Starlight](https://github.com/Spottedleaf/Starlight).
ishland marked this conversation as resolved.
Show resolved Hide resolved
What does C2ME stand for?
Concurrent chunky management engine, its about making the game better threaded and more scallable in regards to world gen and chunk io performance.
## So what is C2ME not?

## So what is Barium not?
Barium is not affiliated with the CaffieneMC.
Barium is not production ready and still pretty experimental.
C2ME is not production ready and still pretty experimental.
YOU HAVE BEEN WARNED!!!!

## Building and setting up
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ version = project.mod_version
group = project.maven_group

loom {
accessWidener "src/main/resources/barium.accesswidener"
accessWidener "src/main/resources/C2ME.accesswidener"
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.yatopiamc.barium;
package org.yatopiamc.C2ME;

import net.fabricmc.api.ModInitializer;

public class BariumMod implements ModInitializer {
public class C2MEMod implements ModInitializer {
@Override
public void onInitialize() {
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/yatopiamc/C2ME/common/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package org.yatopiamc.C2ME.common;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.yatopiamc.barium.common.threading.chunkio;
package org.yatopiamc.C2ME.common.threading.chunkio;

import com.google.common.base.Preconditions;
import com.google.common.cache.Cache;
Expand All @@ -16,8 +16,8 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
import org.yatopiamc.barium.common.util.BariumForkJoinWorkerThreadFactory;
import org.yatopiamc.barium.common.util.SneakyThrow;
import org.yatopiamc.C2ME.common.util.C2MEForkJoinWorkerThreadFactory;
import org.yatopiamc.C2ME.common.util.SneakyThrow;

import java.io.DataInputStream;
import java.io.DataOutputStream;
Expand All @@ -31,18 +31,18 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

public class BariumCachedRegionStorage extends StorageIoWorker {
public class C2MECachedRegionStorage extends StorageIoWorker {

private static final CompoundTag EMPTY_VALUE = new CompoundTag();
private static final Logger LOGGER = LogManager.getLogger();
private static final ForkJoinPool IOExecutor = new ForkJoinPool(
Math.min(8, Runtime.getRuntime().availableProcessors()),
new BariumForkJoinWorkerThreadFactory("barium chunkio io worker #%d", Thread.NORM_PRIORITY - 3),
new C2MEForkJoinWorkerThreadFactory("C2ME chunkio io worker #%d", Thread.NORM_PRIORITY - 3),
null, true
);
private static final ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(
1,
new ThreadFactoryBuilder().setNameFormat("barium chunkio scheduler").setDaemon(true).setPriority(Thread.NORM_PRIORITY - 1).build()
new ThreadFactoryBuilder().setNameFormat("C2ME chunkio scheduler").setDaemon(true).setPriority(Thread.NORM_PRIORITY - 1).build()
);

private final RegionBasedStorage storage;
Expand All @@ -54,7 +54,7 @@ public class BariumCachedRegionStorage extends StorageIoWorker {

private final AtomicBoolean isClosed = new AtomicBoolean(false);

public BariumCachedRegionStorage(File file, boolean bl, String string) {
public C2MECachedRegionStorage(File file, boolean bl, String string) {
super(file, bl, string);
this.storage = new RegionBasedStorage(file, bl);
this.chunkCache = CacheBuilder.newBuilder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.yatopiamc.barium.common.threading.chunkio;
package org.yatopiamc.C2ME.common.threading.chunkio;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.yatopiamc.barium.common.threading.chunkio;
package org.yatopiamc.C2ME.common.threading.chunkio;

import org.yatopiamc.barium.common.util.BariumForkJoinWorkerThreadFactory;
import org.yatopiamc.C2ME.common.util.C2MEForkJoinWorkerThreadFactory;

import java.util.concurrent.ForkJoinPool;

public class ChunkIoThreadingExecutorUtils {

public static final ForkJoinPool serializerExecutor = new ForkJoinPool(
Math.min(6, Runtime.getRuntime().availableProcessors()),
new BariumForkJoinWorkerThreadFactory("barium chunkio serializer worker #%d", Thread.NORM_PRIORITY - 1),
new C2MEForkJoinWorkerThreadFactory("C2ME chunkio serializer worker #%d", Thread.NORM_PRIORITY - 1),
null,
true
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.yatopiamc.barium.common.threading.chunkio;
package org.yatopiamc.C2ME.common.threading.chunkio;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.ChunkPos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.yatopiamc.barium.common.threading.worldgen;
package org.yatopiamc.C2ME.common.threading.worldgen;

import com.google.common.base.Preconditions;
import com.ibm.asyncutil.locks.AsyncLock;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.yatopiamc.barium.common.threading.worldgen;
package org.yatopiamc.C2ME.common.threading.worldgen;

import com.ibm.asyncutil.locks.AsyncLock;
import com.ibm.asyncutil.locks.AsyncNamedLock;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.yatopiamc.barium.common.threading.worldgen;
package org.yatopiamc.C2ME.common.threading.worldgen;

import com.ibm.asyncutil.locks.AsyncLock;
import com.ibm.asyncutil.locks.AsyncNamedLock;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.yatopiamc.barium.common.threading.worldgen;
package org.yatopiamc.C2ME.common.threading.worldgen;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.yatopiamc.barium.common.util.BariumForkJoinWorkerThreadFactory;
import org.yatopiamc.C2ME.common.util.C2MEForkJoinWorkerThreadFactory;

import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.LinkedBlockingQueue;
Expand All @@ -12,7 +12,7 @@ public class WorldGenThreadingExecutorUtils {

public static final ForkJoinPool mainExecutor = new ForkJoinPool(
Math.min(8, Runtime.getRuntime().availableProcessors()),
new BariumForkJoinWorkerThreadFactory("barium worldgen worker #%d", Thread.NORM_PRIORITY - 1),
new C2MEForkJoinWorkerThreadFactory("C2ME worldgen worker #%d", Thread.NORM_PRIORITY - 1),
null,
true
);
Expand All @@ -21,7 +21,7 @@ public class WorldGenThreadingExecutorUtils {
1,
0, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(),
new ThreadFactoryBuilder().setNameFormat("barium worldgen scheduler").setDaemon(true).setPriority(Thread.NORM_PRIORITY).build()
new ThreadFactoryBuilder().setNameFormat("C2ME worldgen scheduler").setDaemon(true).setPriority(Thread.NORM_PRIORITY).build()
);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.yatopiamc.C2ME.common.util;

import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinWorkerThread;
import java.util.concurrent.atomic.AtomicLong;

public class C2MEForkJoinWorkerThreadFactory implements ForkJoinPool.ForkJoinWorkerThreadFactory {
private final AtomicLong serial = new AtomicLong(0);
private final String namePattern;
private final int priority;

public C2MEForkJoinWorkerThreadFactory(String namePattern, int priority) {
this.namePattern = namePattern;
this.priority = priority;
}

@Override
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
final C2MEForkJoinWorkerThread C2MEForkJoinWorkerThread = new C2MEForkJoinWorkerThread(pool);
C2MEForkJoinWorkerThread.setName(String.format(namePattern, serial.incrementAndGet()));
C2MEForkJoinWorkerThread.setPriority(priority);
C2MEForkJoinWorkerThread.setDaemon(true);
return C2MEForkJoinWorkerThread;
}

private static class C2MEForkJoinWorkerThread extends ForkJoinWorkerThread {

/**
* Creates a ForkJoinWorkerThread operating in the given pool.
*
* @param pool the pool this thread works in
* @throws NullPointerException if pool is null
*/
protected C2MEForkJoinWorkerThread(ForkJoinPool pool) {
super(pool);
}

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.yatopiamc.barium.common.util;
package org.yatopiamc.C2ME.common.util;

public class SneakyThrow {

Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/yatopiamc/C2ME/mixin/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package org.yatopiamc.C2ME.mixin;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.yatopiamc.barium.mixin.threading.chunkio;
package org.yatopiamc.C2ME.mixin.threading.chunkio;

import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.ChunkSectionPos;
Expand All @@ -11,7 +11,7 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.yatopiamc.barium.common.threading.chunkio.ChunkIoMainThreadTaskUtils;
import org.yatopiamc.C2ME.common.threading.chunkio.ChunkIoMainThreadTaskUtils;

@Mixin(ChunkSerializer.class)
public class MixinChunkSerializer {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.yatopiamc.barium.mixin.threading.chunkio;
package org.yatopiamc.C2ME.mixin.threading.chunkio;

import com.mojang.serialization.DynamicOps;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -13,8 +13,8 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.yatopiamc.barium.common.threading.chunkio.BariumCachedRegionStorage;
import org.yatopiamc.barium.common.threading.chunkio.ISerializingRegionBasedStorage;
import org.yatopiamc.C2ME.common.threading.chunkio.C2MECachedRegionStorage;
import org.yatopiamc.C2ME.common.threading.chunkio.ISerializingRegionBasedStorage;

import java.io.File;

Expand All @@ -31,6 +31,6 @@ public void update(ChunkPos pos, CompoundTag tag) {

@Redirect(method = "<init>", at = @At(value = "NEW", target = "net/minecraft/world/storage/StorageIoWorker"))
private StorageIoWorker onStorageIoInit(File file, boolean bl, String string) {
return new BariumCachedRegionStorage(file, bl, string);
return new C2MECachedRegionStorage(file, bl, string);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.yatopiamc.barium.mixin.threading.chunkio;
package org.yatopiamc.C2ME.mixin.threading.chunkio;

import com.mojang.datafixers.util.Either;
import net.minecraft.nbt.CompoundTag;
Expand All @@ -17,7 +17,7 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.yatopiamc.barium.common.threading.chunkio.BariumCachedRegionStorage;
import org.yatopiamc.C2ME.common.threading.chunkio.C2MECachedRegionStorage;

import java.util.Map;
import java.util.concurrent.CompletableFuture;
Expand All @@ -42,7 +42,7 @@ public abstract class MixinStorageIoWorker {
@Inject(method = "<init>", at = @At("RETURN"))
private void onPostInit(CallbackInfo info) {
//noinspection ConstantConditions
if (((Object) this) instanceof BariumCachedRegionStorage) {
if (((Object) this) instanceof C2MECachedRegionStorage) {
this.storage = null;
this.results = null;
this.field_24468 = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.yatopiamc.barium.mixin.threading.chunkio;
package org.yatopiamc.C2ME.mixin.threading.chunkio;

import com.ibm.asyncutil.locks.AsyncNamedLock;
import com.mojang.datafixers.DataFixer;
Expand Down Expand Up @@ -28,11 +28,11 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.yatopiamc.barium.common.threading.chunkio.BariumCachedRegionStorage;
import org.yatopiamc.barium.common.threading.chunkio.ChunkIoMainThreadTaskUtils;
import org.yatopiamc.barium.common.threading.chunkio.ChunkIoThreadingExecutorUtils;
import org.yatopiamc.barium.common.threading.chunkio.ISerializingRegionBasedStorage;
import org.yatopiamc.barium.common.util.SneakyThrow;
import org.yatopiamc.C2ME.common.threading.chunkio.C2MECachedRegionStorage;
import org.yatopiamc.C2ME.common.threading.chunkio.ChunkIoMainThreadTaskUtils;
import org.yatopiamc.C2ME.common.threading.chunkio.ChunkIoThreadingExecutorUtils;
import org.yatopiamc.C2ME.common.threading.chunkio.ISerializingRegionBasedStorage;
import org.yatopiamc.C2ME.common.util.SneakyThrow;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -98,7 +98,7 @@ private void onInit(CallbackInfo info) {
@Overwrite
private CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>> loadChunk(ChunkPos pos) {

final CompletableFuture<CompoundTag> poiData = ((BariumCachedRegionStorage) this.pointOfInterestStorage.worker).getNbtAtAsync(pos);
final CompletableFuture<CompoundTag> poiData = ((C2MECachedRegionStorage) this.pointOfInterestStorage.worker).getNbtAtAsync(pos);

return getUpdatedChunkTagAtAsync(pos).thenApplyAsync(compoundTag -> {
if (compoundTag != null) {
Expand Down Expand Up @@ -161,7 +161,7 @@ private CompletableFuture<Either<Chunk, ChunkHolder.Unloaded>> loadChunk(ChunkPo
}

private CompletableFuture<CompoundTag> getUpdatedChunkTagAtAsync(ChunkPos pos) {
return chunkLock.acquireLock(pos).toCompletableFuture().thenCompose(lockToken -> ((BariumCachedRegionStorage) this.worker).getNbtAtAsync(pos).thenApply(compoundTag -> {
return chunkLock.acquireLock(pos).toCompletableFuture().thenCompose(lockToken -> ((C2MECachedRegionStorage) this.worker).getNbtAtAsync(pos).thenApply(compoundTag -> {
if (compoundTag != null)
return this.updateChunkTag(this.world.getRegistryKey(), this.persistentStateManagerFactory, compoundTag);
else return null;
Expand Down Expand Up @@ -203,7 +203,7 @@ private boolean save(Chunk chunk) {
}

this.world.getProfiler().visit("chunkSave");
// barium start - async serialization
// C2ME start - async serialization
if (saveFutures == null) saveFutures = new ConcurrentLinkedQueue<>();

saveFutures.add(chunkLock.acquireLock(chunk.getPos()).toCompletableFuture().thenCompose(lockToken ->
Expand All @@ -216,7 +216,7 @@ private boolean save(Chunk chunk) {
return unused;
})));
this.method_27053(chunkPos, chunkStatus.getChunkType());
// barium end
// C2ME end
return true;
} catch (Exception var5) {
LOGGER.error("Failed to save chunk {},{}", chunkPos.x, chunkPos.z, var5);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.yatopiamc.barium.mixin.threading.chunkio;
package org.yatopiamc.C2ME.mixin.threading.chunkio;

import net.minecraft.world.storage.StorageIoWorker;
import net.minecraft.world.storage.VersionedChunkStorage;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.yatopiamc.barium.common.threading.chunkio.BariumCachedRegionStorage;
import org.yatopiamc.C2ME.common.threading.chunkio.C2MECachedRegionStorage;

import java.io.File;

Expand All @@ -14,7 +14,7 @@ public class MixinVersionedChunkStorage {

@Redirect(method = "<init>", at = @At(value = "NEW", target = "net/minecraft/world/storage/StorageIoWorker"))
private StorageIoWorker onStorageIoInit(File file, boolean bl, String string) {
return new BariumCachedRegionStorage(file, bl, string);
return new C2MECachedRegionStorage(file, bl, string);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.yatopiamc.barium.mixin.threading.lighting;
package org.yatopiamc.C2ME.mixin.threading.lighting;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import net.minecraft.server.world.ServerWorld;
Expand Down
Loading