This commit is contained in:
mcrcortex
2025-10-12 15:38:33 +10:00
parent 2f49d03953
commit ddbc1c27e4
3 changed files with 23 additions and 13 deletions

View File

@@ -136,7 +136,7 @@ public class NodeManager {
z <<= lvl;
long p2 = WorldEngine.getWorldSectionId(0, x, y, z);
if (WorldEngine.getLevel(p2) != 0 || WorldEngine.getX(p2) != x || WorldEngine.getY(p2) != y || WorldEngine.getZ(p2) != z) {
throw new IllegalStateException("Position not valid at all levels");
throw new IllegalStateException("Position not valid at all levels: " + pos + "-"+WorldEngine.pprintPos(pos) + ":"+WorldEngine.pprintPos(p2));
}
}

View File

@@ -39,9 +39,15 @@ public class TestNodeManager {
this.removeSection(oldId);
}
int newId = this.allocation.allocateNext();
if (newId == -1) {
Logger.error("Allocator full: "+this.allocation.getCount()+" " +section, new Throwable());
section.free();
return -1;
}
var entry = new Entry(section.position, section.geometryBuffer.size);
if (this.sections.put(newId, entry) != null) {
throw new IllegalStateException();
var old = this.sections.put(newId, entry);
if (old != null) {
throw new IllegalStateException(oldId + ","+newId+" "+old+","+entry);
}
this.memoryInUse += entry.size;
section.free();
@@ -282,22 +288,24 @@ public class TestNodeManager {
int ITER_COUNT = 5_000;
int INNER_ITER_COUNT = 1_000_000;
boolean GEO_REM = true;
boolean LIMIT_REQUEST_SEC_ALLOCATION = true;
AtomicInteger finished = new AtomicInteger();
HashSet<List<StackTraceElement>> seenTraces = new HashSet<>();
Logger.SHUTUP_INFO = true;
Logger.SHUTUP = true;
if (true) {
if (false) {
for (int q = 0; q < ITER_COUNT; q++) {
//Logger.info("Iteration "+ q);
if (runTest(INNER_ITER_COUNT, q, seenTraces, GEO_REM)) {
if (runTest(INNER_ITER_COUNT, q, seenTraces, GEO_REM, LIMIT_REQUEST_SEC_ALLOCATION)) {
finished.incrementAndGet();
}
}
} else {
IntStream.range(0, ITER_COUNT).parallel().forEach(i->{
if (runTest(INNER_ITER_COUNT, i, seenTraces, GEO_REM)) {
if (runTest(INNER_ITER_COUNT, i, seenTraces, GEO_REM, LIMIT_REQUEST_SEC_ALLOCATION)) {
finished.incrementAndGet();
}
});
@@ -314,7 +322,7 @@ public class TestNodeManager {
return WorldEngine.getWorldSectionId(lvl, r.nextInt(bound)+(WorldEngine.getX(top)<<4), r.nextInt(bound)+(WorldEngine.getY(top)<<4), r.nextInt(bound)+(WorldEngine.getZ(top)<<4));
}
private static boolean runTest(int ITERS, int testIdx, Set<List<StackTraceElement>> traces, boolean geoRemoval) {
private static boolean runTest(int ITERS, int testIdx, Set<List<StackTraceElement>> traces, boolean geoRemoval, boolean requestLimiter) {
Random r = new Random(testIdx * 1234L);
try {
var test = new TestBase();
@@ -334,7 +342,7 @@ public class TestNodeManager {
//Fuzzy bruteforce everything
for (int x = -R; x<=R; x++) {
for (int z = -R; z<=R; z++) {
for (int y = -8; y<=7; y++) {
for (int y = -1; y<=0; y++) {
tops.add(WorldEngine.getWorldSectionId(4, x, y, z));
}
}
@@ -351,28 +359,29 @@ public class TestNodeManager {
long pos = rPos(r, tops);
int op = r.nextInt(5);
int extra = r.nextInt(256);
boolean geoAddOk = ((!requestLimiter)||(test.geometryManager.allocation.getLimit()-test.geometryManager.allocation.getCount())>1000);
boolean hasGeometry = r.nextBoolean();
boolean addRemTLN = r.nextInt(64) == 0;
boolean extraBool = r.nextBoolean();
if (op == 0 && addRemTLN) {
pos = WorldEngine.getWorldSectionId(4, r.nextInt(5)-2, r.nextInt(32)-16, r.nextInt(5)-2);
pos = WorldEngine.getWorldSectionId(4, r.nextInt(5)-2, r.nextInt(2)-1, r.nextInt(5)-2);//r.nextInt(16)-8//for y
boolean cont = tops.contains(pos);
if (cont&&extraBool&&tops.size()>1) {
extraBool = true;
test.remTopPos(pos);
tops.rem(pos);
} else if (!cont) {
} else if ((!cont)&&geoAddOk) {
extraBool = false;
test.putTopPos(pos);
tops.add(pos);
}
} else if (op == 0) {
} else if (op == 0&&geoAddOk) {
test.request(pos);
}
if (op == 1) {
test.childUpdate(pos, extra);
}
if (op == 2) {
if (op == 2&&((!hasGeometry)||geoAddOk)) {
test.meshUpdate(pos, extra, hasGeometry ? 100 : 0);
}
if (op == 3 && geoRemoval) {

View File

@@ -12,6 +12,7 @@ import java.util.stream.Stream;
public class Logger {
public static boolean INSERT_CLASS = true;
public static boolean SHUTUP = false;
public static boolean SHUTUP_INFO = false;
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger("Voxy");
@@ -76,7 +77,7 @@ public class Logger {
}
public static void info(Object... args) {
if (SHUTUP) {
if (SHUTUP||SHUTUP_INFO) {
return;
}
Throwable throwable = null;