Improved thread safety logs to help diagnosis
This commit is contained in:
parent
561d0b3d6e
commit
4721d92db6
3 changed files with 17 additions and 3 deletions
|
@ -47,7 +47,15 @@ public class LocalProfiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printCallStats() {
|
public static void printCallStats() {
|
||||||
|
if (!WarpDriveConfig.LOGGING_PROFILING_THREAD_SAFETY) {
|
||||||
|
WarpDrive.logger.info("Consider enabling thread safety profiling to get more details next time");
|
||||||
|
return;
|
||||||
|
}
|
||||||
WarpDrive.logger.info("Dumping chunk stats:");
|
WarpDrive.logger.info("Dumping chunk stats:");
|
||||||
|
if (stats.isEmpty()) {
|
||||||
|
WarpDrive.logger.info("-none-");
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (final Entry<String, Integer> entryStat : stats.entrySet()) {
|
for (final Entry<String, Integer> entryStat : stats.entrySet()) {
|
||||||
WarpDrive.logger.info(String.format("%10d x %s",
|
WarpDrive.logger.info(String.format("%10d x %s",
|
||||||
entryStat.getValue(),
|
entryStat.getValue(),
|
||||||
|
|
|
@ -359,14 +359,17 @@ public class ChunkHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int countLoaded = 0;
|
int countLoaded = 0;
|
||||||
|
int countRemoved = 0;
|
||||||
final long timeForRemoval = System.currentTimeMillis() - CHUNK_HANDLER_UNLOADED_CHUNK_MAX_AGE_MS;
|
final long timeForRemoval = System.currentTimeMillis() - CHUNK_HANDLER_UNLOADED_CHUNK_MAX_AGE_MS;
|
||||||
final long timeForThrottle = System.currentTimeMillis() + 200;
|
final long timeForThrottle = System.currentTimeMillis() + 200;
|
||||||
final long sizeBefore = mapRegistryItems.size();
|
final long sizeBefore = mapRegistryItems.size();
|
||||||
|
long indexCurrent = 0L;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
for (final Iterator<Entry<Long, ChunkData>> entryIterator = mapRegistryItems.entrySet().iterator(); entryIterator.hasNext(); ) {
|
for (final Iterator<Entry<Long, ChunkData>> entryIterator = mapRegistryItems.entrySet().iterator(); entryIterator.hasNext(); ) {
|
||||||
final Map.Entry<Long, ChunkData> entryChunkData = entryIterator.next();
|
final Map.Entry<Long, ChunkData> entryChunkData = entryIterator.next();
|
||||||
|
indexCurrent = entryChunkData.getKey();
|
||||||
final ChunkData chunkData = entryChunkData.getValue();
|
final ChunkData chunkData = entryChunkData.getValue();
|
||||||
// update loaded chunks, remove old unloaded chunks
|
// update loaded chunks, remove old unloaded chunks
|
||||||
if (chunkData.isLoaded()) {
|
if (chunkData.isLoaded()) {
|
||||||
|
@ -383,14 +386,16 @@ public class ChunkHandler {
|
||||||
mapRegistryItems.size()));
|
mapRegistryItems.size()));
|
||||||
}
|
}
|
||||||
entryIterator.remove();
|
entryIterator.remove();
|
||||||
|
countRemoved++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (final ConcurrentModificationException exception) {
|
} catch (final ConcurrentModificationException exception) {
|
||||||
WarpDrive.logger.error(String.format("%s world %s had some chunks changed outside main thread? (size %d -> %d)",
|
WarpDrive.logger.error(String.format("%s world %s had some chunks changed outside main thread? (size %d -> %d, loaded %d, removed %d, index 0x%X x %d z %d)",
|
||||||
world.isRemote ? "Client" : "Server",
|
world.isRemote ? "Client" : "Server",
|
||||||
Commons.format(world),
|
Commons.format(world),
|
||||||
sizeBefore, mapRegistryItems.size()));
|
sizeBefore, mapRegistryItems.size(), countLoaded, countRemoved,
|
||||||
|
indexCurrent, indexCurrent & 0xFFFFFFFFL, (indexCurrent >> 32) & 0xFFFFFFFFL));
|
||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
LocalProfiler.printCallStats();
|
LocalProfiler.printCallStats();
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@ public class EMPReceiver implements IEMPReceiver, ICapabilityProvider {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
@Optional.Method(modid = "icbmclassic")
|
@Optional.Method(modid = "icbmclassic")
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public <T> T getCapability(@Nonnull final Capability<T> capability, @Nullable final EnumFacing facing) {
|
public <T> T getCapability(@Nonnull final Capability<T> capability, @Nullable final EnumFacing facing) {
|
||||||
return capability == CapabilityEMP.EMP ? (T) this : null;
|
return capability == CapabilityEMP.EMP ? (T) this : null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue