Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9cb627eaac |
+16
-17
@@ -39,8 +39,8 @@ public enum EDhApiDataCompressionMode
|
||||
/**
|
||||
* Should only be used internally and for unit testing. <br><br>
|
||||
*
|
||||
* Read Speed: 6.09 MS / DTO <br>
|
||||
* Write Speed: 6.01 MS / DTO <br>
|
||||
* Read Speed: 1.64 MS / DTO <br>
|
||||
* Write Speed: 12.44 MS / DTO <br>
|
||||
* Compression ratio: 1.0 <br>
|
||||
*/
|
||||
@DisallowSelectingViaConfigGui
|
||||
@@ -49,29 +49,28 @@ public enum EDhApiDataCompressionMode
|
||||
/**
|
||||
* Extremely fast (often faster than uncompressed), but generally poor compression. <br><br>
|
||||
*
|
||||
* Read Speed: 3.25 MS / DTO <br>
|
||||
* Write Speed: 5.99 MS / DTO <br>
|
||||
* Compression ratio: 0.4513 <br>
|
||||
* Read Speed: 1.85 MS / DTO <br>
|
||||
* Write Speed: 9.46 MS / DTO <br>
|
||||
* Compression ratio: 0.3638 <br>
|
||||
*/
|
||||
LZ4(1),
|
||||
|
||||
///**
|
||||
// * Decent speed and good compression. <br><br>
|
||||
// *
|
||||
// * Read Speed: 9.31 MS / DTO <br>
|
||||
// * Write Speed: 15.13 MS / DTO <br>
|
||||
// * Compression ratio: 0.2606 <br>
|
||||
// */
|
||||
////@DisallowSelectingViaConfigGui
|
||||
/*
|
||||
* Decent speed and good compression. <br><br>
|
||||
*
|
||||
* Read Speed: 11.78 MS / DTO <br>
|
||||
* Write Speed: 16.76 MS / DTO <br>
|
||||
* Compression ratio: 0.2199 <br>
|
||||
*/
|
||||
//@Deprecated
|
||||
//Z_STD(2),
|
||||
|
||||
|
||||
/**
|
||||
* Extremely slow, but very good compression. <br><br>
|
||||
*
|
||||
* Read Speed: 13.29 MS / DTO <br>
|
||||
* Write Speed: 70.95 MS / DTO <br>
|
||||
* Compression ratio: 0.2068 <br>
|
||||
* Read Speed: 12.25 MS / DTO <br>
|
||||
* Write Speed: 490.07 MS / DTO <br>
|
||||
* Compression ratio: 0.1242 <br>
|
||||
*/
|
||||
LZMA2(3);
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public final class ModInfo
|
||||
public static final String NAME = "DistantHorizons";
|
||||
/** Human-readable version of NAME */
|
||||
public static final String READABLE_NAME = "Distant Horizons";
|
||||
public static final String VERSION = "2.3.4-b";
|
||||
public static final String VERSION = "2.3.3-b-dev";
|
||||
/** Returns true if the current build is an unstable developer build, false otherwise. */
|
||||
public static final boolean IS_DEV_BUILD = VERSION.toLowerCase().contains("dev");
|
||||
|
||||
|
||||
+8
-6
@@ -31,12 +31,14 @@ import com.seibel.distanthorizons.coreapi.interfaces.config.IConverter;
|
||||
public class RenderModeEnabledConverter implements IConverter<EDhApiRendererMode, Boolean>
|
||||
{
|
||||
|
||||
@Override
|
||||
public EDhApiRendererMode convertToCoreType(Boolean renderingEnabled)
|
||||
{ return renderingEnabled ? EDhApiRendererMode.DEFAULT : EDhApiRendererMode.DISABLED; }
|
||||
@Override public EDhApiRendererMode convertToCoreType(Boolean renderingEnabled)
|
||||
{
|
||||
return renderingEnabled ? EDhApiRendererMode.DEFAULT : EDhApiRendererMode.DISABLED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean convertToApiType(EDhApiRendererMode renderingMode)
|
||||
{ return renderingMode == EDhApiRendererMode.DEFAULT; }
|
||||
@Override public Boolean convertToApiType(EDhApiRendererMode renderingMode)
|
||||
{
|
||||
return renderingMode == EDhApiRendererMode.DEFAULT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,9 +61,3 @@ shadowJar {
|
||||
// relocate "it.unimi.dsi.fastutil", "${librariesLocation}.unimi.dsi.fastutil"
|
||||
mergeServiceFiles()
|
||||
}
|
||||
|
||||
test {
|
||||
// this is necessary specifically for the Compression tests since those
|
||||
// need more than the default 512 MB of RAM
|
||||
jvmArgs '-Xmx4096m'
|
||||
}
|
||||
|
||||
+1
-2
@@ -26,7 +26,6 @@ import com.seibel.distanthorizons.api.interfaces.config.client.*;
|
||||
import com.seibel.distanthorizons.api.objects.config.DhApiConfigValue;
|
||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiRendererMode;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.coreapi.util.converters.RenderModeEnabledConverter;
|
||||
|
||||
public class DhApiGraphicsConfig implements IDhApiGraphicsConfig
|
||||
{
|
||||
@@ -61,7 +60,7 @@ public class DhApiGraphicsConfig implements IDhApiGraphicsConfig
|
||||
|
||||
@Override
|
||||
public IDhApiConfigValue<Boolean> renderingEnabled()
|
||||
{ return new DhApiConfigValue<EDhApiRendererMode, Boolean>(Config.Client.Advanced.Debugging.rendererMode, new RenderModeEnabledConverter()); }
|
||||
{ return new DhApiConfigValue<Boolean, Boolean>(Config.Client.quickEnableRendering); }
|
||||
|
||||
@Override
|
||||
public IDhApiConfigValue<EDhApiRendererMode> renderingMode()
|
||||
|
||||
@@ -89,15 +89,6 @@ public class ClientApi
|
||||
/** this includes the is dev build message and low allocated memory warning */
|
||||
private static final int MS_BETWEEN_STATIC_STARTUP_MESSAGES = 4_000;
|
||||
|
||||
/**
|
||||
* This isn't the cleanest way of storing variables before passing them to the LOD renderer,
|
||||
* but due to how mixins work and the inconsistency between MC versions,
|
||||
* having a static object that stores a single frame's data
|
||||
* is often the easiest solution. <br><br>
|
||||
*
|
||||
* Only downside is making sure each variable is populated before rendering.
|
||||
*/
|
||||
public static final RenderState RENDER_STATE = new RenderState();
|
||||
|
||||
|
||||
private boolean isDevBuildMessagePrinted = false;
|
||||
@@ -398,7 +389,7 @@ public class ClientApi
|
||||
// rendering //
|
||||
//===========//
|
||||
|
||||
/** Should be called before {@link ClientApi#renderDeferredLodsForShaders} */
|
||||
/** Should be called before {@link ClientApi#renderDeferredLods} */
|
||||
public void renderLods(IClientLevelWrapper levelWrapper, Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks)
|
||||
{ this.renderLodLayer(levelWrapper, mcModelViewMatrix, mcProjectionMatrix, partialTicks, false); }
|
||||
|
||||
@@ -406,10 +397,9 @@ public class ClientApi
|
||||
* Only necessary when Shaders are in use.
|
||||
* Should be called after {@link ClientApi#renderLods}
|
||||
*/
|
||||
public void renderDeferredLodsForShaders(IClientLevelWrapper levelWrapper, Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks)
|
||||
public void renderDeferredLods(IClientLevelWrapper levelWrapper, Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks)
|
||||
{ this.renderLodLayer(levelWrapper, mcModelViewMatrix, mcProjectionMatrix, partialTicks, true); }
|
||||
|
||||
|
||||
private void renderLodLayer(
|
||||
IClientLevelWrapper levelWrapper, Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks,
|
||||
boolean renderingDeferredLayer)
|
||||
@@ -455,25 +445,6 @@ public class ClientApi
|
||||
|
||||
|
||||
|
||||
//Mat4f mcCombined = mcModelViewMatrix.copy();
|
||||
//mcCombined.multiply(mcProjectionMatrix);
|
||||
//
|
||||
//com.seibel.distanthorizons.api.objects.math.DhApiMat4f dhCombined = renderEventParam.dhModelViewMatrix.copy();
|
||||
//dhCombined.multiply(renderEventParam.dhProjectionMatrix);
|
||||
//
|
||||
//LOGGER.info("\n\n" +
|
||||
// "API\n" +
|
||||
// "Mc MVM: \n" + mcModelViewMatrix.toString() + "\n" +
|
||||
// "Mc Proj: \n" + mcProjectionMatrix + "\n" +
|
||||
// "Mc Combined:\n" + mcCombined.toString() + "\n" +
|
||||
// "\n" +
|
||||
// "DH MVM: \n" + renderEventParam.dhModelViewMatrix.toString() + "\n" +
|
||||
// "DH Proj: \n" + renderEventParam.dhProjectionMatrix + "\n" +
|
||||
// "DH Combined:\n" + mcCombined.toString()
|
||||
//);
|
||||
|
||||
|
||||
|
||||
// render validation //
|
||||
|
||||
try
|
||||
@@ -584,26 +555,25 @@ public class ClientApi
|
||||
public void renderFadeOpaque(Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks, IClientLevelWrapper level)
|
||||
{
|
||||
// only fade when DH is rendering
|
||||
if (Config.Client.Advanced.Debugging.rendererMode.get() == EDhApiRendererMode.DEFAULT
|
||||
// only fade when requested
|
||||
&& Config.Client.Advanced.Graphics.Quality.vanillaFadeMode.get() == EDhApiMcRenderingFadeMode.DOUBLE_PASS
|
||||
// don't fade when Iris shaders are active, otherwise the rendering can get weird
|
||||
&& !DhApiRenderProxy.INSTANCE.getDeferTransparentRendering())
|
||||
if (Config.Client.Advanced.Debugging.rendererMode.get() == EDhApiRendererMode.DEFAULT)
|
||||
{
|
||||
FadeRenderer.INSTANCE.render(mcModelViewMatrix, mcProjectionMatrix, partialTicks, level);
|
||||
if (Config.Client.Advanced.Graphics.Quality.vanillaFadeMode.get() == EDhApiMcRenderingFadeMode.DOUBLE_PASS)
|
||||
{
|
||||
FadeRenderer.INSTANCE.render(mcModelViewMatrix, mcProjectionMatrix, partialTicks, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
/** should be called after DH and MC finish rendering so we can smooth the transition between the two */
|
||||
public void renderFade(Mat4f mcModelViewMatrix, Mat4f mcProjectionMatrix, float partialTicks, IClientLevelWrapper level)
|
||||
{
|
||||
// only fade when DH is rendering
|
||||
if (Config.Client.Advanced.Debugging.rendererMode.get() == EDhApiRendererMode.DEFAULT
|
||||
// only fade when requested
|
||||
&& Config.Client.Advanced.Graphics.Quality.vanillaFadeMode.get() != EDhApiMcRenderingFadeMode.NONE
|
||||
// don't fade when Iris shaders are active, otherwise the rendering can get weird
|
||||
&& !DhApiRenderProxy.INSTANCE.getDeferTransparentRendering())
|
||||
if (Config.Client.Advanced.Debugging.rendererMode.get() == EDhApiRendererMode.DEFAULT)
|
||||
{
|
||||
FadeRenderer.INSTANCE.render(mcModelViewMatrix, mcProjectionMatrix, partialTicks, level);
|
||||
// fade if any level fading is active
|
||||
if (Config.Client.Advanced.Graphics.Quality.vanillaFadeMode.get() != EDhApiMcRenderingFadeMode.NONE)
|
||||
{
|
||||
FadeRenderer.INSTANCE.render(mcModelViewMatrix, mcProjectionMatrix, partialTicks, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -682,8 +652,7 @@ public class ClientApi
|
||||
private void detectAndSendBootTimeWarnings()
|
||||
{
|
||||
// dev build
|
||||
if (ModInfo.IS_DEV_BUILD
|
||||
&& !this.isDevBuildMessagePrinted && MC_CLIENT.playerExists())
|
||||
if (ModInfo.IS_DEV_BUILD && !this.isDevBuildMessagePrinted && MC_CLIENT.playerExists())
|
||||
{
|
||||
this.isDevBuildMessagePrinted = true;
|
||||
this.lastStaticWarningMessageSentMsTime = System.currentTimeMillis();
|
||||
@@ -700,8 +669,7 @@ public class ClientApi
|
||||
|
||||
// memory
|
||||
if (this.staticStartupMessageSentRecently()) return;
|
||||
if (!this.lowMemoryWarningPrinted
|
||||
&& Config.Common.Logging.Warning.showLowMemoryWarningOnStartup.get())
|
||||
if (!this.lowMemoryWarningPrinted && Config.Common.Logging.Warning.showLowMemoryWarningOnStartup.get())
|
||||
{
|
||||
this.lowMemoryWarningPrinted = true;
|
||||
this.lastStaticWarningMessageSentMsTime = System.currentTimeMillis();
|
||||
@@ -726,8 +694,7 @@ public class ClientApi
|
||||
|
||||
// high vanilla render distance
|
||||
if (this.staticStartupMessageSentRecently()) return;
|
||||
if (!this.highVanillaRenderDistanceWarningPrinted
|
||||
&& Config.Common.Logging.Warning.showHighVanillaRenderDistanceWarning.get())
|
||||
if (!this.highVanillaRenderDistanceWarningPrinted && Config.Common.Logging.Warning.showHighVanillaRenderDistanceWarning.get())
|
||||
{
|
||||
// DH generally doesn't need a vanilla render distance above 12
|
||||
if (MC_RENDER.getRenderDistance() > 12)
|
||||
@@ -754,8 +721,7 @@ public class ClientApi
|
||||
{
|
||||
if (this.lastStaticWarningMessageSentMsTime == 0)
|
||||
{
|
||||
// no static message has ever been sent
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
long timeSinceLastMessage = System.currentTimeMillis() - this.lastStaticWarningMessageSentMsTime;
|
||||
@@ -774,47 +740,4 @@ public class ClientApi
|
||||
*/
|
||||
public void showOverlayMessageNextFrame(String message) { this.overlayMessageQueueForNextFrame.add(message); }
|
||||
|
||||
|
||||
|
||||
//================//
|
||||
// helper classes //
|
||||
//================//
|
||||
|
||||
public static class RenderState
|
||||
{
|
||||
public Mat4f mcModelViewMatrix = null;
|
||||
public Mat4f mcProjectionMatrix = null;
|
||||
public float frameTime = -1;
|
||||
|
||||
|
||||
public void canRenderOrThrow() throws IllegalStateException
|
||||
{
|
||||
String errorReasons = "";
|
||||
|
||||
if (this.mcModelViewMatrix == null)
|
||||
{
|
||||
errorReasons += "no MVM Matrix, ";
|
||||
}
|
||||
|
||||
if (this.mcProjectionMatrix == null)
|
||||
{
|
||||
errorReasons += "no Projection Matrix, ";
|
||||
}
|
||||
|
||||
if (this.frameTime == -1)
|
||||
{
|
||||
errorReasons += "no Frame Time, ";
|
||||
}
|
||||
|
||||
|
||||
if (!errorReasons.isEmpty())
|
||||
{
|
||||
throw new IllegalStateException(errorReasons);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -171,9 +171,11 @@ public class Config
|
||||
public static class Quality
|
||||
{
|
||||
public static ConfigEntry<Integer> lodChunkRenderDistanceRadius = new ConfigEntry.Builder<Integer>()
|
||||
.setChatCommandName("generation.maxRequestDistance")
|
||||
.setMinDefaultMax(32, 256, 4096)
|
||||
.comment("" +
|
||||
"The radius of the mod's render distance. (measured in chunks)\n" +
|
||||
"On server defines the distance allowed to generate around the player; note that real-time updates and synd on load limits are defined separately. \n" +
|
||||
"")
|
||||
.setPerformance(EConfigEntryPerformance.HIGH)
|
||||
.build();
|
||||
@@ -1342,20 +1344,20 @@ public class Config
|
||||
+ EDhApiDataCompressionMode.UNCOMPRESSED + " \n"
|
||||
+ "Should only be used for testing, is worse in every way vs ["+EDhApiDataCompressionMode.LZ4+"].\n"
|
||||
+ "Expected Compression Ratio: 1.0\n"
|
||||
+ "Estimated average DTO read speed: 3.25 milliseconds\n"
|
||||
+ "Estimated average DTO write speed: 5.99 milliseconds\n"
|
||||
+ "Estimated average DTO read speed: 1.64 milliseconds\n"
|
||||
+ "Estimated average DTO write speed: 12.44 milliseconds\n"
|
||||
+ "\n"
|
||||
+ EDhApiDataCompressionMode.LZ4 + " \n"
|
||||
+ "A good option if you're CPU limited and have plenty of hard drive space.\n"
|
||||
+ "Expected Compression Ratio: 0.26\n"
|
||||
+ "Expected Compression Ratio: 0.36\n"
|
||||
+ "Estimated average DTO read speed: 1.85 ms\n"
|
||||
+ "Estimated average DTO write speed: 9.46 ms\n"
|
||||
+ "\n"
|
||||
+ EDhApiDataCompressionMode.LZMA2 + " \n"
|
||||
+ "Slow but very good compression.\n"
|
||||
+ "Expected Compression Ratio: 0.2\n"
|
||||
+ "Estimated average DTO read speed: 13.29 ms\n"
|
||||
+ "Estimated average DTO write speed: 70.95 ms\n"
|
||||
+ "Expected Compression Ratio: 0.14\n"
|
||||
+ "Estimated average DTO read speed: 11.89 ms\n"
|
||||
+ "Estimated average DTO write speed: 192.01 ms\n"
|
||||
+ "")
|
||||
.build();
|
||||
|
||||
@@ -1620,15 +1622,6 @@ public class Config
|
||||
+ "")
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<Integer> maxGenerationRequestDistance = new ConfigEntry.Builder<Integer>()
|
||||
.setChatCommandName("generation.maxRequestDistance")
|
||||
.setMinDefaultMax(256, 4096, 4096)
|
||||
.comment("" +
|
||||
"Defines the distance allowed to generate around the player." +
|
||||
"")
|
||||
.setPerformance(EConfigEntryPerformance.HIGH)
|
||||
.build();
|
||||
|
||||
public static ConfigEntry<Integer> generationBoundsX = new ConfigEntry.Builder<Integer>()
|
||||
.setChatCommandName("generation.bounds.x")
|
||||
.setAppearance(EConfigEntryAppearance.ONLY_IN_FILE)
|
||||
@@ -1714,7 +1707,7 @@ public class Config
|
||||
+ "")
|
||||
.build();
|
||||
public static ConfigEntry<Boolean> enableAdaptiveTransferSpeed = new ConfigEntry.Builder<Boolean>()
|
||||
.set(false)
|
||||
.set(true)
|
||||
.comment(""
|
||||
+ "Enables adaptive transfer speed based on client performance.\n"
|
||||
+ "If true, DH will automatically adjust transfer rate to minimize connection lag.\n"
|
||||
|
||||
-10
@@ -105,15 +105,6 @@ public class RenderQualityPresetConfigEventHandler extends AbstractPresetConfigE
|
||||
this.put(EDhApiQualityPreset.HIGH, true);
|
||||
this.put(EDhApiQualityPreset.EXTREME, true);
|
||||
}});
|
||||
private final ConfigEntryWithPresetOptions<EDhApiQualityPreset, Boolean> caveCulling = new ConfigEntryWithPresetOptions<>(Config.Client.Advanced.Graphics.Culling.enableCaveCulling,
|
||||
new HashMap<EDhApiQualityPreset, Boolean>()
|
||||
{{
|
||||
this.put(EDhApiQualityPreset.MINIMUM, true);
|
||||
this.put(EDhApiQualityPreset.LOW, true);
|
||||
this.put(EDhApiQualityPreset.MEDIUM, true);
|
||||
this.put(EDhApiQualityPreset.HIGH, false);
|
||||
this.put(EDhApiQualityPreset.EXTREME, false);
|
||||
}});
|
||||
|
||||
|
||||
|
||||
@@ -132,7 +123,6 @@ public class RenderQualityPresetConfigEventHandler extends AbstractPresetConfigE
|
||||
this.configList.add(this.ssaoEnabled);
|
||||
this.configList.add(this.vanillaFade);
|
||||
this.configList.add(this.dhDither);
|
||||
this.configList.add(this.caveCulling);
|
||||
|
||||
|
||||
for (ConfigEntryWithPresetOptions<EDhApiQualityPreset, ?> config : this.configList)
|
||||
|
||||
+6
-8
@@ -70,12 +70,7 @@ public class ConfigFileHandling
|
||||
this.configBase = configBase;
|
||||
this.configPath = configPath;
|
||||
|
||||
this.nightConfig = CommentedFileConfig
|
||||
.builder(this.configPath.toFile())
|
||||
// sync is needed so file reading/writing only happens during locked sections,
|
||||
// otherwise some GUI changes may be lost when changing screens
|
||||
.sync()
|
||||
.build();
|
||||
this.nightConfig = CommentedFileConfig.builder(this.configPath.toFile()).build();
|
||||
}
|
||||
|
||||
|
||||
@@ -326,7 +321,10 @@ public class ConfigFileHandling
|
||||
*
|
||||
* @apiNote This overwrites any value currently stored in the config
|
||||
*/
|
||||
public void loadNightConfig() { this.loadNightConfig(this.nightConfig); }
|
||||
public void loadNightConfig()
|
||||
{
|
||||
loadNightConfig(this.nightConfig);
|
||||
}
|
||||
/**
|
||||
* Does {@link CommentedFileConfig#load()} but with error checking
|
||||
*
|
||||
@@ -355,7 +353,7 @@ public class ConfigFileHandling
|
||||
{
|
||||
System.out.println("Creating file failed");
|
||||
this.logger.error(ex);
|
||||
SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class).crashMinecraft("Loading file and resetting config file failed at path [" + this.configPath + "]. Please check the file is ok and you have the permissions", ex);
|
||||
SingletonInjector.INSTANCE.get(IMinecraftClientWrapper.class).crashMinecraft("Loading file and resetting config file failed at path [" + configPath + "]. Please check the file is ok and you have the permissions", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -139,7 +139,7 @@ public class FullDataToRenderDataTransformer
|
||||
}
|
||||
|
||||
columnSource.fillDebugFlag(0, 0, ColumnRenderSource.SECTION_SIZE, ColumnRenderSource.SECTION_SIZE, ColumnRenderSource.DebugSourceFlag.FULL);
|
||||
|
||||
|
||||
return columnSource;
|
||||
}
|
||||
|
||||
|
||||
@@ -277,7 +277,7 @@ public abstract class AbstractDhLevel implements IDhLevel
|
||||
|
||||
|
||||
// locked to prevent two threads from updating the same section at the same time
|
||||
ReentrantLock lock = this.beaconUpdateLockContainer.getLockForPos(sectionPosForLock); // TODO this can cause a lot of slow-downs
|
||||
ReentrantLock lock = this.beaconUpdateLockContainer.getLockForPos(sectionPosForLock);
|
||||
try
|
||||
{
|
||||
lock.lock();
|
||||
|
||||
@@ -143,9 +143,9 @@ public abstract class AbstractDhServerLevel extends AbstractDhLevel implements I
|
||||
|
||||
if (message.clientTimestamp == null)
|
||||
{
|
||||
if (distanceFromPlayer > Config.Server.maxGenerationRequestDistance.get())
|
||||
if (distanceFromPlayer > Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius.get())
|
||||
{
|
||||
message.sendResponse(new RequestOutOfRangeException("Distance too large: " + distanceFromPlayer + " > " + Config.Server.maxGenerationRequestDistance.get()));
|
||||
message.sendResponse(new RequestOutOfRangeException("Distance too large: " + distanceFromPlayer + " > " + Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius.get()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ import com.seibel.distanthorizons.core.render.renderer.generic.GenericObjectRend
|
||||
import com.seibel.distanthorizons.core.pos.blockPos.DhBlockPos2D;
|
||||
import com.seibel.distanthorizons.core.render.renderer.DebugRenderer;
|
||||
import com.seibel.distanthorizons.core.sql.dto.FullDataSourceV2DTO;
|
||||
import com.seibel.distanthorizons.core.util.threading.ThreadPoolUtil;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.block.IBlockStateWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftClientWrapper;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IProfilerWrapper;
|
||||
@@ -59,7 +58,7 @@ import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/** The level used when connected to a server */
|
||||
@@ -163,8 +162,7 @@ public class DhClientLevel extends AbstractDhLevel implements IDhClientLevel
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
try(FullDataSourceV2DTO dataSourceDto = this.networkState.fullDataPayloadReceiver.decodeDataSourceAndReleaseBuffer(message.payload))
|
||||
try (FullDataSourceV2DTO dataSourceDto = this.networkState.fullDataPayloadReceiver.decodeDataSourceAndReleaseBuffer(message.payload))
|
||||
{
|
||||
boolean isSameLevel = message.isSameLevelAs(this.levelWrapper);
|
||||
NETWORK_LOGGER.debug("Buffer {} isSameLevel: {}", message.payload.dtoBufferId, isSameLevel);
|
||||
@@ -173,28 +171,10 @@ public class DhClientLevel extends AbstractDhLevel implements IDhClientLevel
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Executor executor = ThreadPoolUtil.getFileHandlerExecutor();
|
||||
if (executor != null)
|
||||
{
|
||||
executor.execute(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
// TODO this has a lock which can cause stuttering/lag issues
|
||||
this.updateBeaconBeamsForSectionPos(dataSourceDto.pos, message.payload.beaconBeams);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error("Unexpected erorr while updating full data source, error: ["+e.getMessage()+"].", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.updateBeaconBeamsForSectionPos(dataSourceDto.pos, message.payload.beaconBeams);
|
||||
|
||||
FullDataSourceV2 fullDataSource = dataSourceDto.createDataSource(this.levelWrapper);
|
||||
this.updateDataSourcesAsync(fullDataSource)
|
||||
.whenComplete((result, e) -> fullDataSource.close());
|
||||
this.updateDataSourcesAsync(fullDataSource).whenComplete((result, e) -> fullDataSource.close());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ public class SessionConfig implements INetworkObject
|
||||
// Note: config values are transmitted in the insertion order
|
||||
|
||||
registerConfigEntry(Config.Common.WorldGenerator.enableDistantGeneration, Boolean::logicalAnd);
|
||||
registerConfigEntry(Config.Server.maxGenerationRequestDistance, Math::min);
|
||||
registerConfigEntry(Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius, Math::min);
|
||||
registerConfigEntry(Config.Server.generationBoundsX, (x, y) -> y);
|
||||
registerConfigEntry(Config.Server.generationBoundsZ, (x, y) -> y);
|
||||
registerConfigEntry(Config.Server.generationBoundsRadius, (x, y) -> y);
|
||||
@@ -67,7 +67,7 @@ public class SessionConfig implements INetworkObject
|
||||
//===============//
|
||||
|
||||
public boolean isDistantGenerationEnabled() { return this.getValue(Config.Common.WorldGenerator.enableDistantGeneration); }
|
||||
public int getMaxGenerationRequestDistance() { return this.getValue(Config.Server.maxGenerationRequestDistance); }
|
||||
public int getMaxGenerationRequestDistance() { return this.getValue(Config.Client.Advanced.Graphics.Quality.lodChunkRenderDistanceRadius); }
|
||||
public Integer getGenerationBoundsX() { return this.getValue(Config.Server.generationBoundsX); }
|
||||
public Integer getGenerationBoundsZ() { return this.getValue(Config.Server.generationBoundsZ); }
|
||||
public Integer getGenerationBoundsRadius() { return this.getValue(Config.Server.generationBoundsRadius); }
|
||||
|
||||
+11
-33
@@ -2,7 +2,6 @@ package com.seibel.distanthorizons.core.multiplayer.server;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode;
|
||||
import com.seibel.distanthorizons.core.config.Config;
|
||||
import com.seibel.distanthorizons.core.dataObjects.fullData.sources.FullDataSourceV2;
|
||||
import com.seibel.distanthorizons.core.file.fullDatafile.GeneratedFullDataSourceProvider;
|
||||
import com.seibel.distanthorizons.core.level.AbstractDhServerLevel;
|
||||
import com.seibel.distanthorizons.core.logging.ConfigBasedLogger;
|
||||
@@ -77,19 +76,14 @@ public class FullDataSourceRequestHandler
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// get the data requested by the client
|
||||
CompletableFuture<FullDataSourceV2> getServerDatasourceFuture = CompletableFuture.supplyAsync(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
CompletableFuture.completedFuture(null)
|
||||
.thenComposeAsync(v -> {
|
||||
// the client timestamp will be null if we want to retrieve the LOD regardless of when it was last updated
|
||||
long clientTimestamp = (message.clientTimestamp != null) ? message.clientTimestamp : -1;
|
||||
|
||||
// the server timestamp will be null if no LOD data exists for this position
|
||||
Long serverTimestamp = this.fullDataSourceProvider().getTimestampForPos(message.sectionPos);
|
||||
if (serverTimestamp == null
|
||||
|| serverTimestamp <= clientTimestamp)
|
||||
|| serverTimestamp <= clientTimestamp)
|
||||
{
|
||||
// either no data exists to sync, or the client is already up to date
|
||||
rateLimiterSet.syncOnLoginRateLimiter.release();
|
||||
@@ -97,28 +91,14 @@ public class FullDataSourceRequestHandler
|
||||
return null;
|
||||
}
|
||||
|
||||
// get the server's datasource
|
||||
return this.fullDataSourceProvider().get(message.sectionPos);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error("Unexpected issue getting server-side LOD for request at pos [" + DhSectionPos.toString(message.sectionPos) + "], error: [" + e.getMessage() + "].", e);
|
||||
return null;
|
||||
}
|
||||
}, fileHandlerExecutor);
|
||||
|
||||
// send the found data
|
||||
getServerDatasourceFuture.thenAcceptAsync(fullDataSource ->
|
||||
{
|
||||
try
|
||||
{
|
||||
// no server data source found
|
||||
return this.fullDataSourceProvider().getAsync(message.sectionPos);
|
||||
}, fileHandlerExecutor)
|
||||
.thenAcceptAsync(fullDataSource -> {
|
||||
if (fullDataSource == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// send the found data source to client
|
||||
try (FullDataPayload payload = new FullDataPayload(fullDataSource, this.getAllBeamsForPos(message.sectionPos)))
|
||||
{
|
||||
fullDataSource.close();
|
||||
@@ -129,13 +109,11 @@ public class FullDataSourceRequestHandler
|
||||
rateLimiterSet.syncOnLoginRateLimiter.release();
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.error("Unexpected issue sending request for pos [" + DhSectionPos.toString(message.sectionPos) + "], error: [" + e.getMessage() + "].", e);
|
||||
}
|
||||
}, networkCompressionExecutor);
|
||||
|
||||
}, networkCompressionExecutor)
|
||||
.exceptionally(e -> {
|
||||
LOGGER.error("Unexpected issue getting request for pos [" + DhSectionPos.toString(message.sectionPos) + "], error: [" + e.getMessage() + "].", e);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
public void queueWorldGenForRequestMessage(ServerPlayerState serverPlayerState, FullDataSourceRequestMessage message, ServerPlayerState.RateLimiterSet rateLimiterSet)
|
||||
|
||||
-7
@@ -46,13 +46,6 @@ public class ServerPlayerStateManager
|
||||
|
||||
public void handlePluginMessage(IServerPlayerWrapper player, AbstractNetworkMessage message)
|
||||
{
|
||||
// done to prevent a rare null-pointer on Neo/Forge
|
||||
if (player == null || message == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
MessageQueueState messageQueue = this.messageQueueByPlayerWrapper.computeIfAbsent(player, k -> new MessageQueueState());
|
||||
messageQueue.messageQueue.add(message);
|
||||
|
||||
|
||||
+3
-3
@@ -306,9 +306,9 @@ public class PhantomArrayListPool
|
||||
{
|
||||
// we only want to log when something has been returned
|
||||
if (checkoutCount != 0
|
||||
|| returnedByteArrayCount != 0
|
||||
|| returnedShortArrayCount != 0
|
||||
|| returnedLongArrayCount != 0)
|
||||
|| returnedByteArrayCount != 0
|
||||
|| returnedShortArrayCount != 0
|
||||
|| returnedLongArrayCount != 0)
|
||||
{
|
||||
LOGGER.warn("Pool: ["+ pool.name+"] phantom recovery. Returned checkouts:["+F3Screen.NUMBER_FORMAT.format(checkoutCount)+"], byte:["+F3Screen.NUMBER_FORMAT.format(returnedByteArrayCount)+"], short:["+F3Screen.NUMBER_FORMAT.format(returnedShortArrayCount)+"], long:["+F3Screen.NUMBER_FORMAT.format(returnedLongArrayCount)+"].");
|
||||
|
||||
|
||||
+2
-41
@@ -25,15 +25,9 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import com.seibel.distanthorizons.core.render.glObject.GLProxy;
|
||||
import org.lwjgl.PointerBuffer;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
import org.lwjgl.opengl.GL32C;
|
||||
import org.lwjgl.system.MemoryStack;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
import org.lwjgl.system.NativeType;
|
||||
|
||||
/**
|
||||
* This object holds a OpenGL reference to a shader
|
||||
@@ -69,7 +63,7 @@ public class Shader
|
||||
}
|
||||
|
||||
StringBuilder source = loadFile(path, absoluteFilePath, new StringBuilder());
|
||||
safeShaderSource(this.id, source);
|
||||
GL32.glShaderSource(this.id, source);
|
||||
|
||||
GL32.glCompileShader(this.id);
|
||||
// check if the shader compiled
|
||||
@@ -99,7 +93,7 @@ public class Shader
|
||||
throw new IllegalArgumentException("Failed to create shader with type ["+type+"] and Source: \n["+sourceString+"].");
|
||||
}
|
||||
|
||||
safeShaderSource(this.id, sourceString);
|
||||
GL32.glShaderSource(this.id, sourceString);
|
||||
GL32.glCompileShader(this.id);
|
||||
// check if the shader compiled
|
||||
int status = GL32.glGetShaderi(this.id, GL32.GL_COMPILE_STATUS);
|
||||
@@ -120,37 +114,6 @@ public class Shader
|
||||
// helpers //
|
||||
//=========//
|
||||
|
||||
/**
|
||||
* Identical in function to {@link GL32C#glShaderSource(int, CharSequence)} but
|
||||
* passes a null pointer for string length to force the driver to rely on the null
|
||||
* terminator for string length. This is a workaround for an apparent flaw with some
|
||||
* AMD drivers that don't receive or interpret the length correctly, resulting in
|
||||
* an access violation when the driver tries to read past the string memory.
|
||||
*
|
||||
* <p>Hat tip to fewizz for the find and the fix.
|
||||
*
|
||||
* <p>Source: https://github.com/vram-guild/canvas/commit/820bf754092ccaf8d0c169620c2ff575722d7d96
|
||||
*/
|
||||
private static void safeShaderSource(@NativeType("GLuint") int glId, @NativeType("GLchar const **") CharSequence source)
|
||||
{
|
||||
final MemoryStack stack = MemoryStack.stackGet();
|
||||
final int stackPointer = stack.getPointer();
|
||||
|
||||
try
|
||||
{
|
||||
final ByteBuffer sourceBuffer = MemoryUtil.memUTF8(source, true);
|
||||
final PointerBuffer pointers = stack.mallocPointer(1);
|
||||
pointers.put(sourceBuffer);
|
||||
|
||||
GL32.nglShaderSource(glId, 1, pointers.address0(), 0);
|
||||
org.lwjgl.system.APIUtil.apiArrayFree(pointers.address0(), 1);
|
||||
}
|
||||
finally
|
||||
{
|
||||
stack.setPointer(stackPointer);
|
||||
}
|
||||
}
|
||||
|
||||
public void free() { GL32.glDeleteShader(this.id); }
|
||||
|
||||
public static StringBuilder loadFile(String path, boolean absoluteFilePath, StringBuilder stringBuilder)
|
||||
@@ -188,6 +151,4 @@ public class Shader
|
||||
return stringBuilder;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -804,9 +804,6 @@ public class LodRenderer
|
||||
if (this.depthTexture != null)
|
||||
this.depthTexture.destroy();
|
||||
|
||||
this.setActiveDepthTextureId(-1);
|
||||
this.setActiveColorTextureId(-1);
|
||||
|
||||
EVENT_LOGGER.info("Renderer Cleanup Complete");
|
||||
});
|
||||
}
|
||||
|
||||
+3
-15
@@ -155,19 +155,6 @@ public class FadeShader extends AbstractShaderRenderer
|
||||
@Override
|
||||
protected void onRender()
|
||||
{
|
||||
int depthTextureId = LodRenderer.getActiveDepthTextureId();
|
||||
int colorTextureId = LodRenderer.getActiveColorTextureId();
|
||||
|
||||
if (depthTextureId == -1
|
||||
|| colorTextureId == -1)
|
||||
{
|
||||
// the renderer is currently being re-built and/or inactive,
|
||||
// we don't need to/can't render fading
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GLMC.glBindFramebuffer(GL32.GL_FRAMEBUFFER, this.frameBuffer);
|
||||
GLMC.disableScissorTest();
|
||||
GLMC.disableDepthTest();
|
||||
@@ -178,7 +165,8 @@ public class FadeShader extends AbstractShaderRenderer
|
||||
GL32.glUniform1i(this.uMcDepthTexture, 0);
|
||||
|
||||
GLMC.glActiveTexture(GL32.GL_TEXTURE1);
|
||||
GLMC.glBindTexture(depthTextureId);
|
||||
// FIXME it's possible for this to return an invalid texture ID if the renderer is being re-built at the same time
|
||||
GLMC.glBindTexture(LodRenderer.getActiveDepthTextureId());
|
||||
GL32.glUniform1i(this.uDhDepthTexture, 1);
|
||||
|
||||
GLMC.glActiveTexture(GL32.GL_TEXTURE2);
|
||||
@@ -186,7 +174,7 @@ public class FadeShader extends AbstractShaderRenderer
|
||||
GL32.glUniform1i(this.uCombinedMcDhColorTexture, 2);
|
||||
|
||||
GLMC.glActiveTexture(GL32.GL_TEXTURE3);
|
||||
GLMC.glBindTexture(colorTextureId);
|
||||
GLMC.glBindTexture(LodRenderer.getActiveColorTextureId());
|
||||
GL32.glUniform1i(this.uDhColorTexture, 3);
|
||||
|
||||
|
||||
|
||||
+1
-10
@@ -142,16 +142,7 @@ public class FullDataSourceV2DTO
|
||||
public FullDataSourceV2 createDataSource(@NotNull ILevelWrapper levelWrapper) throws IOException, InterruptedException, DataCorruptedException
|
||||
{
|
||||
FullDataSourceV2 dataSource = FullDataSourceV2.createEmpty(this.pos);
|
||||
try
|
||||
{
|
||||
this.internalPopulateDataSource(dataSource, levelWrapper, false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dataSource.close();
|
||||
throw e;
|
||||
}
|
||||
|
||||
this.internalPopulateDataSource(dataSource, levelWrapper, false);
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -20,8 +20,10 @@
|
||||
package com.seibel.distanthorizons.core.util.objects.dataStreams;
|
||||
|
||||
import com.seibel.distanthorizons.api.enums.config.EDhApiDataCompressionMode;
|
||||
import com.seibel.distanthorizons.core.Initializer;
|
||||
import com.seibel.distanthorizons.core.util.objects.DataCorruptedException;
|
||||
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||
import net.jpountz.lz4.LZ4FrameInputStream;
|
||||
//import org.apache.commons.compress.compressors.zstandard.ZstdCompressorInputStream;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.tukaani.xz.ResettableArrayCache;
|
||||
@@ -42,7 +44,6 @@ import java.io.*;
|
||||
public class DhDataInputStream extends DataInputStream
|
||||
{
|
||||
private static final ThreadLocal<ResettableArrayCache> LZMA_RESETTABLE_ARRAY_CACHE_GETTER = ThreadLocal.withInitial(() -> new ResettableArrayCache(new LzmaArrayCache()));
|
||||
//private static final ThreadLocal<ZstdArrayCache> ZSTD_RESETTABLE_ARRAY_CACHE_GETTER = ThreadLocal.withInitial(() -> new ZstdArrayCache());
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@@ -61,8 +62,6 @@ public class DhDataInputStream extends DataInputStream
|
||||
return stream;
|
||||
case LZ4:
|
||||
return new LZ4FrameInputStream(stream);
|
||||
//case Z_STD:
|
||||
// return new ZstdCompressorInputStream(stream, ZSTD_RESETTABLE_ARRAY_CACHE_GETTER.get());
|
||||
case LZMA2:
|
||||
// using an array cache significantly reduces GC pressure
|
||||
ResettableArrayCache arrayCache = LZMA_RESETTABLE_ARRAY_CACHE_GETTER.get();
|
||||
|
||||
+1
-5
@@ -23,7 +23,6 @@ import com.seibel.distanthorizons.api.enums.config.EDhApiDataCompressionMode;
|
||||
import net.jpountz.lz4.LZ4Factory;
|
||||
import net.jpountz.lz4.LZ4FrameOutputStream;
|
||||
import net.jpountz.xxhash.XXHashFactory;
|
||||
//import org.apache.commons.compress.compressors.zstandard.ZstdCompressorOutputStream;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.tukaani.xz.*;
|
||||
@@ -54,9 +53,6 @@ public class DhDataOutputStream extends DataOutputStream
|
||||
{
|
||||
case UNCOMPRESSED:
|
||||
return stream;
|
||||
|
||||
//case Z_STD:
|
||||
// return new ZstdCompressorOutputStream(stream, 3, true, true);
|
||||
case LZ4:
|
||||
return new LZ4FrameOutputStream(stream,
|
||||
LZ4FrameOutputStream.BLOCKSIZE.SIZE_64KB, -1L,
|
||||
@@ -73,7 +69,7 @@ public class DhDataOutputStream extends DataOutputStream
|
||||
arrayCache.reset();
|
||||
// Note: if the LZMA2Options are changed the array cache may need to be re-tested.
|
||||
// the array cache was specifically tested and tuned for LZMA preset 3/4
|
||||
return new XZOutputStream(stream, new LZMA2Options(3),
|
||||
return new XZOutputStream(stream, new LZMA2Options(3),
|
||||
XZ.CHECK_CRC64, arrayCache);
|
||||
|
||||
default:
|
||||
|
||||
+4
-20
@@ -63,16 +63,8 @@ public class LzmaArrayCache extends ArrayCache
|
||||
{
|
||||
return new byte[size];
|
||||
}
|
||||
|
||||
// the array only sometimes needs to be cleared,
|
||||
// clearing all the time results in unnecessary slowdowns
|
||||
if (fillWithZeros)
|
||||
{
|
||||
// TODO it appears that this can prevent the CPU from working on
|
||||
// other tasks, thus causing render thread lag even when run on a separate thread
|
||||
Arrays.fill(array, (byte) 0);
|
||||
}
|
||||
|
||||
// the array needs to be cleared to prevent accidentally sending dirty data
|
||||
Arrays.fill(array, (byte)0);
|
||||
return array;
|
||||
}
|
||||
|
||||
@@ -115,16 +107,8 @@ public class LzmaArrayCache extends ArrayCache
|
||||
{
|
||||
return new int[size];
|
||||
}
|
||||
|
||||
// the array only sometimes needs to be cleared,
|
||||
// clearing all the time results in unnecessary slowdowns
|
||||
if (fillWithZeros)
|
||||
{
|
||||
// TODO it appears that this can prevent the CPU from working on
|
||||
// other tasks, thus causing render thread lag even when run on a separate thread
|
||||
Arrays.fill(array, (byte) 0);
|
||||
}
|
||||
|
||||
// the array needs to be cleared to prevent accidentally sending dirty data
|
||||
Arrays.fill(array, (byte)0);
|
||||
return array;
|
||||
}
|
||||
|
||||
|
||||
-85
@@ -1,85 +0,0 @@
|
||||
package com.seibel.distanthorizons.core.util.objects.dataStreams;
|
||||
|
||||
//import com.github.luben.zstd.BufferPool;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ReferenceArrayMap;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
|
||||
/**
|
||||
* LZMA requires a custom object to cache it's backend arrays.
|
||||
*/
|
||||
public class ZstdArrayCache //implements BufferPool
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
/**
|
||||
* In James' testing the byte and int caches only ever had to store 2 and 4 arrays respectively.
|
||||
* With the in mind we could take a few shortcuts, but if that changes then we need to be
|
||||
* notified as it might cause issues with the current logic.
|
||||
*/
|
||||
public static final int WARN_CACHE_LENGTH_EXCEEDED = 10;
|
||||
|
||||
public static final AtomicInteger MAX_BYTE_CACHE_LENGTH_REF = new AtomicInteger(WARN_CACHE_LENGTH_EXCEEDED);
|
||||
|
||||
public final IntUnaryOperator maxByteCacheSizeUnaryOperator = (x) -> Math.max(this.bufferCache.size(), x);
|
||||
|
||||
|
||||
/**
|
||||
* generally only 2 items long <br>
|
||||
* {@link Int2ReferenceArrayMap} can be used since the cache should only be a few items long.
|
||||
* If the array ends up being longer then this design will need to be changed.
|
||||
*/
|
||||
public final Int2ReferenceArrayMap<ArrayList<ByteBuffer>> bufferCache = new Int2ReferenceArrayMap<>();
|
||||
|
||||
|
||||
|
||||
//=============//
|
||||
// byte arrays //
|
||||
//=============//
|
||||
|
||||
//@Override
|
||||
public ByteBuffer get(int size)
|
||||
{
|
||||
ArrayList<ByteBuffer> cacheList = this.bufferCache.computeIfAbsent(size, (newSize) -> new ArrayList<>(4));
|
||||
if (cacheList.isEmpty())
|
||||
{
|
||||
return ByteBuffer.allocate(size);
|
||||
}
|
||||
|
||||
ByteBuffer array = cacheList.remove(cacheList.size()-1);
|
||||
if (array == null)
|
||||
{
|
||||
return ByteBuffer.allocate(size);
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void release(ByteBuffer buffer)
|
||||
{
|
||||
int size = buffer.array().length;
|
||||
this.bufferCache.computeIfAbsent(size, (newSize) -> new ArrayList<>());
|
||||
this.bufferCache.get(size).add(buffer);
|
||||
|
||||
|
||||
if (this.bufferCache.size() > WARN_CACHE_LENGTH_EXCEEDED)
|
||||
{
|
||||
int previousMax = MAX_BYTE_CACHE_LENGTH_REF.getAndUpdate(this.maxByteCacheSizeUnaryOperator);
|
||||
int newMax = MAX_BYTE_CACHE_LENGTH_REF.get();
|
||||
if (newMax > previousMax)
|
||||
{
|
||||
LOGGER.warn("LZMA byte array cache expected size exceeded. Expected max length ["+WARN_CACHE_LENGTH_EXCEEDED+"], actual length ["+this.bufferCache.size()+"].");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public abstract class AbstractDhServerWorld<TDhServerLevel extends AbstractDhSer
|
||||
public void addPlayer(IServerPlayerWrapper serverPlayer)
|
||||
{
|
||||
ServerPlayerState playerState = this.serverPlayerStateManager.registerJoinedPlayer(serverPlayer);
|
||||
((TDhServerLevel) this.getOrLoadServerLevel(serverPlayer.getLevel())).addPlayer(serverPlayer);
|
||||
this.getLevel(serverPlayer.getLevel()).addPlayer(serverPlayer);
|
||||
|
||||
Iterator<TDhServerLevel> it = this.dhLevelByLevelWrapper.values().stream().distinct().iterator();
|
||||
while (it.hasNext())
|
||||
|
||||
@@ -921,7 +921,7 @@
|
||||
"distanthorizons.config.enum.EDhApiDistantGeneratorMode.FEATURES":
|
||||
"Features",
|
||||
"distanthorizons.config.enum.EDhApiDistantGeneratorMode.INTERNAL_SERVER":
|
||||
"Full - Save Chunks",
|
||||
"Internal Server",
|
||||
|
||||
"distanthorizons.config.enum.EDhApiDistantGeneratorProgressDisplayLocation.OVERLAY":
|
||||
"Overlay",
|
||||
@@ -935,11 +935,9 @@
|
||||
"distanthorizons.config.enum.EDhApiDataCompressionMode.UNCOMPRESSED":
|
||||
"Uncompressed",
|
||||
"distanthorizons.config.enum.EDhApiDataCompressionMode.LZ4":
|
||||
"Fastest/Big - LZ4",
|
||||
"distanthorizons.config.enum.EDhApiDataCompressionMode.Z_STD":
|
||||
"Fast/Small - Z_STD",
|
||||
"Fast/Big - LZ4",
|
||||
"distanthorizons.config.enum.EDhApiDataCompressionMode.LZMA2":
|
||||
"Slow/Smallest - LZMA2",
|
||||
"Slow/Small - LZMA2",
|
||||
|
||||
"distanthorizons.config.enum.EDhApiWorldCompressionMode.MERGE_SAME_BLOCKS":
|
||||
"1. Merge Same Blocks",
|
||||
|
||||
@@ -25,11 +25,11 @@ import com.seibel.distanthorizons.core.sql.dto.FullDataSourceV2DTO;
|
||||
import com.seibel.distanthorizons.core.sql.repo.FullDataSourceV2Repo;
|
||||
import com.seibel.distanthorizons.coreapi.util.StringUtil;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayList;
|
||||
//import org.apache.commons.compress.compressors.zstandard.ZstdCompressorOutputStream;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.CharacterIterator;
|
||||
import java.text.StringCharacterIterator;
|
||||
|
||||
/**
|
||||
* <strong>Note:</strong>
|
||||
@@ -47,14 +47,22 @@ import java.io.*;
|
||||
*/
|
||||
public class CompressionTest
|
||||
{
|
||||
public static String TEST_DIR = "C:\\DistantHorizonsWorkspace\\distant-horizons\\run\\client\\saves\\Archipelego\\data";
|
||||
public static String TEST_DIR = "C:\\DistantHorizonsWorkspace\\distant-horizons\\run\\saves\\Arcapelago\\data";
|
||||
public static String DB_FILE_NAME_PREFIX = "DistantHorizons";
|
||||
public static String UNCOMPRESSED_DB_FILE_NAME = "DistantHorizons_uncompressed.sqlite";
|
||||
public static String UNCOMPRESSED_DB_FILE_NAME = "DistantHorizons.sqlite";
|
||||
|
||||
/** -1 will test all of them */
|
||||
public static int MAX_DTO_TEST_COUNT = -1;
|
||||
|
||||
|
||||
|
||||
//@Test
|
||||
public void NoCompression()
|
||||
{
|
||||
String compressorName = "Uncompressed";
|
||||
this.testCompressor(compressorName, EDhApiDataCompressionMode.UNCOMPRESSED);
|
||||
}
|
||||
|
||||
// collapse the following commented out code when looking at tests
|
||||
|
||||
//@Test
|
||||
@@ -124,6 +132,17 @@ public class CompressionTest
|
||||
//}
|
||||
|
||||
|
||||
//@Test
|
||||
//public void Zstd()
|
||||
//{
|
||||
// String compressorName = "Zstd";
|
||||
//
|
||||
// DhDataInputStream.CreateInputStreamFunc createInputStreamFunc = (inputStream) -> new ZstdInputStream(inputStream);
|
||||
// DhDataOutputStream.CreateOutputStreamFunc createOutputStreamFunc = (outputStream) -> new ZstdOutputStream(outputStream);
|
||||
//
|
||||
// this.testCompressor(compressorName, createInputStreamFunc, createOutputStreamFunc);
|
||||
//}
|
||||
|
||||
////@Test
|
||||
//public void ZstdDictionary() throws SQLException // isn't any better than normal Zstd
|
||||
//{
|
||||
@@ -186,13 +205,6 @@ public class CompressionTest
|
||||
// this.testCompressor(compressorName, createInputStreamFunc, createOutputStreamFunc);
|
||||
//}
|
||||
|
||||
//@Test
|
||||
public void NoCompression()
|
||||
{
|
||||
String compressorName = "Uncompressed";
|
||||
this.testCompressor(compressorName, EDhApiDataCompressionMode.UNCOMPRESSED);
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void Lz4() // fast, poor compression
|
||||
{
|
||||
@@ -201,11 +213,11 @@ public class CompressionTest
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void Zstd() // middle of the road
|
||||
{
|
||||
//String compressorName = "Zstd";
|
||||
//this.testCompressor(compressorName, EDhApiDataCompressionMode.Z_STD);
|
||||
}
|
||||
//public void Zstd() // middle of the road
|
||||
//{
|
||||
// String compressorName = "Zstd";
|
||||
// this.testCompressor(compressorName, EDhApiDataCompressionMode.Z_STD);
|
||||
//}
|
||||
|
||||
//@Test
|
||||
public void LZMA2() // very slow, very good compression though
|
||||
@@ -242,15 +254,13 @@ public class CompressionTest
|
||||
long totalCompressedFileSizeInBytes;
|
||||
|
||||
|
||||
FullDataSourceV2Repo uncompressedRepo = null;
|
||||
FullDataSourceV2Repo compressedRepo = null;
|
||||
try
|
||||
{
|
||||
String uncompressedDatabaseFilePath = TEST_DIR + "/" + UNCOMPRESSED_DB_FILE_NAME;
|
||||
File uncompressedDatabaseFile = new File(uncompressedDatabaseFilePath);
|
||||
Assert.assertTrue(uncompressedDatabaseFile.exists());
|
||||
|
||||
uncompressedRepo = new FullDataSourceV2Repo("jdbc:sqlite", uncompressedDatabaseFile);
|
||||
FullDataSourceV2Repo uncompressedRepo = new FullDataSourceV2Repo("jdbc:sqlite", uncompressedDatabaseFile);
|
||||
|
||||
|
||||
String compressedDatabaseFilePath = TEST_DIR + "/output/" + DB_FILE_NAME_PREFIX + "_" + compressorName + ".sqlite";
|
||||
@@ -258,7 +268,7 @@ public class CompressionTest
|
||||
compressedDatabaseFile.mkdirs();
|
||||
compressedDatabaseFile.delete();
|
||||
Assert.assertTrue(!compressedDatabaseFile.exists());
|
||||
compressedRepo = new FullDataSourceV2Repo("jdbc:sqlite", compressedDatabaseFile);
|
||||
FullDataSourceV2Repo compressedRepo = new FullDataSourceV2Repo("jdbc:sqlite", uncompressedDatabaseFile);
|
||||
|
||||
|
||||
|
||||
@@ -282,47 +292,47 @@ public class CompressionTest
|
||||
|
||||
// uncompressed input //
|
||||
|
||||
try (FullDataSourceV2DTO uncompressedDto = uncompressedRepo.getByKey(pos))
|
||||
{
|
||||
Assert.assertEquals(uncompressedDto.compressionModeValue, EDhApiDataCompressionMode.UNCOMPRESSED.value);
|
||||
FullDataSourceV2 uncompressedDataSource = uncompressedDto.createUnitTestDataSource();
|
||||
|
||||
long uncompressedDtoSize = uncompressedRepo.getDataSizeInBytes(pos);
|
||||
minUncompressedDtoSizeInBytes = Math.min(uncompressedDtoSize, minUncompressedDtoSizeInBytes);
|
||||
maxUncompressedDtoSizeInBytes = Math.max(uncompressedDtoSize, maxUncompressedDtoSizeInBytes);
|
||||
avgUncompressedDtoSizeInBytes += uncompressedDtoSize;
|
||||
|
||||
|
||||
// compress file //
|
||||
|
||||
long startWriteNanoTime = System.nanoTime();
|
||||
|
||||
FullDataSourceV2DTO compressedDto = FullDataSourceV2DTO.CreateFromDataSource(uncompressedDataSource, compressionMode);
|
||||
compressedRepo.save(compressedDto);
|
||||
|
||||
long endWriteNanoTime = System.nanoTime();
|
||||
totalWriteTimeInNano += (endWriteNanoTime - startWriteNanoTime);
|
||||
|
||||
|
||||
long compressedDtoSize = compressedRepo.getDataSizeInBytes(pos);
|
||||
minCompressedDtoSizeInBytes = Math.min(compressedDtoSize, minCompressedDtoSizeInBytes);
|
||||
maxCompressedDtoSizeInBytes = Math.max(compressedDtoSize, maxCompressedDtoSizeInBytes);
|
||||
avgCompressedDtoSizeInBytes += compressedDtoSize;
|
||||
|
||||
|
||||
// read compressed file //
|
||||
|
||||
long startReadNanoTime = System.nanoTime();
|
||||
|
||||
compressedDto = compressedRepo.getByKey(pos);
|
||||
FullDataSourceV2 compressedDataSource = compressedDto.createUnitTestDataSource();
|
||||
|
||||
long endReadMsTime = System.nanoTime();
|
||||
totalReadTimeInNano += (endReadMsTime - startReadNanoTime);
|
||||
|
||||
|
||||
processedDtoCount++;
|
||||
}
|
||||
FullDataSourceV2DTO uncompressedDto = uncompressedRepo.getByKey(pos);
|
||||
Assert.assertEquals(uncompressedDto.compressionModeValue, EDhApiDataCompressionMode.UNCOMPRESSED.value);
|
||||
FullDataSourceV2 uncompressedDataSource = uncompressedDto.createUnitTestDataSource();
|
||||
|
||||
long uncompressedDtoSize = uncompressedRepo.getDataSizeInBytes(pos);
|
||||
minUncompressedDtoSizeInBytes = Math.min(uncompressedDtoSize, minUncompressedDtoSizeInBytes);
|
||||
maxUncompressedDtoSizeInBytes = Math.max(uncompressedDtoSize, maxUncompressedDtoSizeInBytes);
|
||||
avgUncompressedDtoSizeInBytes += uncompressedDtoSize;
|
||||
|
||||
|
||||
|
||||
// compress file //
|
||||
|
||||
long startWriteNanoTime = System.nanoTime();
|
||||
|
||||
FullDataSourceV2DTO compressedDto = FullDataSourceV2DTO.CreateFromDataSource(uncompressedDataSource, compressionMode);
|
||||
compressedRepo.save(compressedDto);
|
||||
|
||||
long endWriteNanoTime = System.nanoTime();
|
||||
totalWriteTimeInNano += (endWriteNanoTime - startWriteNanoTime);
|
||||
|
||||
|
||||
long compressedDtoSize = compressedRepo.getDataSizeInBytes(pos);
|
||||
minCompressedDtoSizeInBytes = Math.min(compressedDtoSize, minCompressedDtoSizeInBytes);
|
||||
maxCompressedDtoSizeInBytes = Math.max(compressedDtoSize, maxCompressedDtoSizeInBytes);
|
||||
avgCompressedDtoSizeInBytes += compressedDtoSize;
|
||||
|
||||
|
||||
|
||||
// read compressed file //
|
||||
|
||||
long startReadNanoTime = System.nanoTime();
|
||||
|
||||
compressedDto = compressedRepo.getByKey(pos);
|
||||
FullDataSourceV2 compressedDataSource = compressedDto.createUnitTestDataSource();
|
||||
|
||||
long endReadMsTime = System.nanoTime();
|
||||
totalReadTimeInNano += (endReadMsTime - startReadNanoTime);
|
||||
|
||||
|
||||
processedDtoCount++;
|
||||
}
|
||||
catch (Exception | Error e)
|
||||
{
|
||||
@@ -361,18 +371,6 @@ public class CompressionTest
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if(uncompressedRepo != null)
|
||||
{
|
||||
uncompressedRepo.close();
|
||||
}
|
||||
|
||||
if(compressedRepo != null)
|
||||
{
|
||||
compressedRepo.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.apache.logging.log4j.core.config.Configurator;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@Deprecated
|
||||
public class SquareIntersectTest
|
||||
{
|
||||
private static final Logger LOGGER = DhLoggerBuilder.getLogger();
|
||||
|
||||
Reference in New Issue
Block a user