Attempt at even more agressive optimizations
This commit is contained in:
@@ -46,7 +46,7 @@ public class ModelBakerySubsystem {
|
|||||||
|
|
||||||
|
|
||||||
//There should be a method to access the frame time IIRC, if the user framecap is unlimited lock it to like 60 fps for computation
|
//There should be a method to access the frame time IIRC, if the user framecap is unlimited lock it to like 60 fps for computation
|
||||||
int BUDGET = 10;//TODO: make this computed based on the remaining free time in a frame (and like div by 2 to reduce overhead) (with a min of 1)
|
int BUDGET = 16;//TODO: make this computed based on the remaining free time in a frame (and like div by 2 to reduce overhead) (with a min of 1)
|
||||||
if (!this.blockIdQueue.isEmpty()) {
|
if (!this.blockIdQueue.isEmpty()) {
|
||||||
int[] est = new int[Math.min(this.blockIdQueue.size(), BUDGET)];
|
int[] est = new int[Math.min(this.blockIdQueue.size(), BUDGET)];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|||||||
@@ -134,8 +134,8 @@ public class RenderService<T extends AbstractSectionRenderer<J, ?>, J extends Vi
|
|||||||
this.sectionUpdateQueue.consume(128);
|
this.sectionUpdateQueue.consume(128);
|
||||||
|
|
||||||
//Cap the number of consumed sections per frame to 40 + 2% of the queue size, cap of 200
|
//Cap the number of consumed sections per frame to 40 + 2% of the queue size, cap of 200
|
||||||
int geoUpdateCap = Math.max(100, Math.min((int)(0.15*this.geometryUpdateQueue.count()), 260));
|
//int geoUpdateCap = 20;//Math.max(100, Math.min((int)(0.15*this.geometryUpdateQueue.count()), 260));
|
||||||
this.geometryUpdateQueue.consume(geoUpdateCap);
|
this.geometryUpdateQueue.consumeMillis(2);
|
||||||
if (this.nodeManager.writeChanges(this.traversal.getNodeBuffer())) {//TODO: maybe move the node buffer out of the traversal class
|
if (this.nodeManager.writeChanges(this.traversal.getNodeBuffer())) {//TODO: maybe move the node buffer out of the traversal class
|
||||||
UploadStream.INSTANCE.commit();
|
UploadStream.INSTANCE.commit();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ public class MessageQueue <T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int consume(int max) {
|
public int consume(int max) {
|
||||||
|
if (this.count.get() == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < max) {
|
while (i < max) {
|
||||||
var entry = this.queue.poll();
|
var entry = this.queue.poll();
|
||||||
@@ -36,6 +39,24 @@ public class MessageQueue <T> {
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int consumeMillis(int millis) {
|
||||||
|
if (this.count.get() == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int i = 0;
|
||||||
|
long nano = System.nanoTime();
|
||||||
|
do {
|
||||||
|
var entry = this.queue.poll();
|
||||||
|
if (entry == null) break;
|
||||||
|
i++;
|
||||||
|
this.consumer.accept(entry);
|
||||||
|
} while ((System.nanoTime()-nano) < millis*1000_000L);
|
||||||
|
if (i != 0) {
|
||||||
|
this.count.addAndGet(-i);
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
public final void clear(Consumer<T> cleaner) {
|
public final void clear(Consumer<T> cleaner) {
|
||||||
while (!this.queue.isEmpty()) {
|
while (!this.queue.isEmpty()) {
|
||||||
cleaner.accept(this.queue.pop());
|
cleaner.accept(this.queue.pop());
|
||||||
|
|||||||
Reference in New Issue
Block a user