Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Commit

Permalink
Disable Affinitylocking by default
Browse files Browse the repository at this point in the history
  • Loading branch information
robotia committed Mar 5, 2016
1 parent 7f2ea59 commit fd0b4d5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 27 deletions.
60 changes: 34 additions & 26 deletions patches/net/minecraft/server/MinecraftServer.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@
public void run()
{
try
@@ -392,45 +638,47 @@
@@ -392,45 +638,55 @@
this.field_147147_p.func_151315_a(new ChatComponentText(this.motd));
this.field_147147_p.func_151321_a(new ServerStatusResponse.MinecraftProtocolVersionIdentifier("1.7.10", 5));
this.func_147138_a(this.field_147147_p);
Expand All @@ -478,10 +478,18 @@
+ // Spigot start
+ Arrays.fill(recentTps, 20);
+ long lastTick = 0, catchupTime = 0, curTime, wait;
+ AffinityLock al = AffinityLock.acquireCore();
+ if(al.isAllocated())
+ logger.log(org.apache.logging.log4j.Level.INFO, "[Thermos] We're locked in! " + AffinityLock.dumpLocks());
+ else logger.log(org.apache.logging.log4j.Level.WARN, "[Thermos] Couldn't bind to a CPU core!");
+ AffinityLock al = null;
+ if(CauldronConfig.instance.affinity.getValue())
+ {
+ al = AffinityLock.acquireCore();
+ if(al.isAllocated())
+ logger.log(org.apache.logging.log4j.Level.INFO, "[Thermos] We're locked in! " + AffinityLock.dumpLocks());
+ else logger.log(org.apache.logging.log4j.Level.WARN, "[Thermos] Couldn't bind to a CPU core!");
+ }
+ else
+ {
+ logger.log(org.apache.logging.log4j.Level.INFO, "[Thermos] Refusing to lock affinity, disabled in cauldron.yml");
+ }
+ try {
while (this.serverRunning)
{
Expand Down Expand Up @@ -537,13 +545,13 @@
this.serverIsRunning = true;
}
+ }
+ finally { al.release(); }
+ finally { if(al != null) { al.release(); } }
+
+ // Spigot end
FMLCommonHandler.instance().handleServerStopping();
FMLCommonHandler.instance().expectServerStopped(); // has to come before finalTick to avoid race conditions
}
@@ -448,6 +696,14 @@
@@ -448,6 +704,14 @@
catch (Throwable throwable1)
{
logger.error("Encountered an unexpected exception", throwable1);
Expand All @@ -558,15 +566,15 @@
CrashReport crashreport = null;

if (throwable1 instanceof ReportedException)
@@ -477,6 +733,7 @@
@@ -477,6 +741,7 @@
{
try
{
+ org.spigotmc.WatchdogThread.doStop(); // Spigot
this.stopServer();
this.serverStopped = true;
}
@@ -486,6 +743,16 @@
@@ -486,6 +751,16 @@
}
finally
{
Expand All @@ -583,7 +591,7 @@
FMLCommonHandler.instance().handleServerStopped();
this.serverStopped = true;
this.systemExitNow();
@@ -497,6 +764,11 @@
@@ -497,6 +772,11 @@
{
File file1 = this.getFile("server-icon.png");

Expand All @@ -595,7 +603,7 @@
if (file1.isFile())
{
ByteBuf bytebuf = Unpooled.buffer();
@@ -532,8 +804,12 @@
@@ -532,8 +812,12 @@

public void tick()
{
Expand All @@ -608,7 +616,7 @@
++this.tickCounter;

if (this.startProfiling)
@@ -562,12 +838,21 @@
@@ -562,12 +846,21 @@
this.field_147147_p.func_151318_b().func_151330_a(agameprofile);
}

Expand All @@ -632,7 +640,7 @@
}

this.theProfiler.startSection("tallying");
@@ -575,25 +860,57 @@
@@ -575,25 +868,57 @@
this.theProfiler.endSection();
this.theProfiler.startSection("snooper");

Expand Down Expand Up @@ -692,7 +700,7 @@
int i;

Integer[] ids = DimensionManager.getIDs(this.tickCounter % 200 == 0);
@@ -602,19 +919,21 @@
@@ -602,19 +927,21 @@
int id = ids[x];
long j = System.nanoTime();

Expand All @@ -717,7 +725,7 @@

this.theProfiler.startSection("tick");
FMLCommonHandler.instance().onPreWorldTick(worldserver);
@@ -622,22 +941,46 @@
@@ -622,22 +949,46 @@

try
{
Expand Down Expand Up @@ -766,7 +774,7 @@
worldserver.addWorldInfoToCrashReport(crashreport);
throw new ReportedException(crashreport);
}
@@ -645,10 +988,12 @@
@@ -645,10 +996,12 @@
FMLCommonHandler.instance().onPostWorldTick(worldserver);
this.theProfiler.endSection();
this.theProfiler.startSection("tracker");
Expand All @@ -780,7 +788,7 @@

worldTickTimes.get(id)[this.tickCounter % 100] = System.nanoTime() - j;
}
@@ -656,15 +1001,21 @@
@@ -656,15 +1009,21 @@
this.theProfiler.endStartSection("dim_unloading");
DimensionManager.unloadWorlds(worldTickTimes);
this.theProfiler.endStartSection("connection");
Expand All @@ -802,7 +810,7 @@

this.theProfiler.endSection();
}
@@ -699,6 +1050,13 @@
@@ -699,6 +1058,13 @@

public WorldServer worldServerForDimension(int p_71218_1_)
{
Expand All @@ -816,7 +824,7 @@
WorldServer ret = DimensionManager.getWorld(p_71218_1_);
if (ret == null)
{
@@ -784,13 +1142,14 @@
@@ -784,13 +1150,14 @@

public List getPossibleCompletions(ICommandSender p_71248_1_, String p_71248_2_)
{
Expand All @@ -835,7 +843,7 @@

if (list != null)
{
@@ -798,40 +1157,25 @@
@@ -798,40 +1165,25 @@

while (iterator.hasNext())
{
Expand Down Expand Up @@ -884,7 +892,7 @@
}

public static MinecraftServer getServer()
@@ -1034,7 +1378,7 @@
@@ -1034,7 +1386,7 @@

public boolean isServerInOnlineMode()
{
Expand All @@ -893,7 +901,7 @@
}

public void setOnlineMode(boolean p_71229_1_)
@@ -1124,7 +1468,7 @@
@@ -1124,7 +1476,7 @@

public NetworkSystem func_147137_ag()
{
Expand All @@ -902,7 +910,7 @@
}

@SideOnly(Side.CLIENT)
@@ -1259,8 +1603,11 @@
@@ -1259,8 +1611,11 @@
{
Bootstrap.func_151354_b();

Expand All @@ -914,7 +922,7 @@
boolean flag = true;
String s = null;
String s1 = ".";
@@ -1356,16 +1703,34 @@
@@ -1356,16 +1711,34 @@
{
dedicatedserver.setGuiEnabled();
}
Expand Down Expand Up @@ -955,7 +963,7 @@
}
catch (Exception exception)
{
@@ -1400,15 +1765,70 @@
@@ -1400,15 +1773,70 @@
@SideOnly(Side.SERVER)
public String getPlugins()
{
Expand Down Expand Up @@ -1031,7 +1039,7 @@
}

@SideOnly(Side.SERVER)
@@ -1455,9 +1875,213 @@
@@ -1455,9 +1883,213 @@
return this.serverStopped;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public class CauldronConfig extends ConfigBase
// Optimization options
public final IntSetting repeaterL = new IntSetting(this, "optimized.redstone-repeater-update-speed", -1, "how many milliseconds the server must ignore before trying repeater updates");
public final IntSetting redstoneTorchL = new IntSetting(this, "optimized.redstone-redstoneTorch-update-speed", -1, "how many milliseconds the server must ignore before trying redstoneTorch updates");

public final BoolSetting affinity = new BoolSetting(this, "optimized.affinity-locking", false, "Whether to enable affinity locking. Very technical usage, recommended for dedicated hosts only. Ask on Discord or GitHub for info on how to set this up properly.");

// World Protection options
public final BoolSetting protectSP = new BoolSetting(this, "protection.spawn-protect", true, "Whether to enable Thermos' all-seeing protection in the spawn world");

Expand Down Expand Up @@ -120,6 +121,7 @@ public void init()
settings.put(redstoneTorchL.path, redstoneTorchL);
settings.put(protectSP.path, protectSP);
settings.put(realNames.path, realNames);
settings.put(affinity.path, affinity);
load();
}

Expand Down

2 comments on commit fd0b4d5

@Yive
Copy link
Contributor

@Yive Yive commented on fd0b4d5 Mar 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the Cauldron config instead of Thermos?

@sameer
Copy link
Member

@sameer sameer commented on fd0b4d5 Mar 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yive I dunno I just ended up putting it in there. I put stuff in there in the past so I decided to just use it.

Please sign in to comment.