Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 04:20:04 +01:00
526795bacd
* Update patches to handle vineflower decompiler * update patches again to handle inlined simple lambdas * update vf again and re-apply/rebuild patches * update patches after removal of verify-merges flag * fix compile issue * remove maven local * fix some issues * address more issues * fix collision patch * use paperweight release * more fixes * update fineflower and fix patches again * add missing comment descriptor --------- Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
119 Zeilen
6.5 KiB
Diff
119 Zeilen
6.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Tue, 5 Apr 2016 21:38:58 -0400
|
|
Subject: [PATCH] Optimize DataBits
|
|
|
|
Remove Debug checks as these are super hot and causing noticeable hits
|
|
|
|
Before: http://i.imgur.com/nQsMzAE.png
|
|
After: http://i.imgur.com/nJ46crB.png
|
|
|
|
Optimize redundant converting of static fields into an unsigned long each call by precomputing it in ctor
|
|
|
|
diff --git a/src/main/java/net/minecraft/util/SimpleBitStorage.java b/src/main/java/net/minecraft/util/SimpleBitStorage.java
|
|
index b0fc31f8fdf96c5b595b04fe4208963a33de8a2a..dafb714706107a9e83a7c0b808ba795a78eb7b52 100644
|
|
--- a/src/main/java/net/minecraft/util/SimpleBitStorage.java
|
|
+++ b/src/main/java/net/minecraft/util/SimpleBitStorage.java
|
|
@@ -204,8 +204,8 @@ public class SimpleBitStorage implements BitStorage {
|
|
private final long mask;
|
|
private final int size;
|
|
private final int valuesPerLong;
|
|
- private final int divideMul;
|
|
- private final int divideAdd;
|
|
+ private final int divideMul; private final long divideMulUnsigned; // Paper - Perf: Optimize SimpleBitStorage; referenced in b(int) with 2 Integer.toUnsignedLong calls
|
|
+ private final int divideAdd; private final long divideAddUnsigned; // Paper - Perf: Optimize SimpleBitStorage
|
|
private final int divideShift;
|
|
|
|
public SimpleBitStorage(int elementBits, int size, int[] data) {
|
|
@@ -248,8 +248,8 @@ public class SimpleBitStorage implements BitStorage {
|
|
this.mask = (1L << elementBits) - 1L;
|
|
this.valuesPerLong = (char)(64 / elementBits);
|
|
int i = 3 * (this.valuesPerLong - 1);
|
|
- this.divideMul = MAGIC[i + 0];
|
|
- this.divideAdd = MAGIC[i + 1];
|
|
+ this.divideMul = MAGIC[i + 0]; this.divideMulUnsigned = Integer.toUnsignedLong(this.divideMul); // Paper - Perf: Optimize SimpleBitStorage
|
|
+ this.divideAdd = MAGIC[i + 1]; this.divideAddUnsigned = Integer.toUnsignedLong(this.divideAdd); // Paper - Perf: Optimize SimpleBitStorage
|
|
this.divideShift = MAGIC[i + 2];
|
|
int j = (size + this.valuesPerLong - 1) / this.valuesPerLong;
|
|
if (data != null) {
|
|
@@ -264,15 +264,15 @@ public class SimpleBitStorage implements BitStorage {
|
|
}
|
|
|
|
private int cellIndex(int index) {
|
|
- long l = Integer.toUnsignedLong(this.divideMul);
|
|
- long m = Integer.toUnsignedLong(this.divideAdd);
|
|
- return (int)(index * l + m >> 32 >> this.divideShift);
|
|
+ //long l = Integer.toUnsignedLong(this.divideMul); // Paper - Perf: Optimize SimpleBitStorage
|
|
+ //long m = Integer.toUnsignedLong(this.divideAdd); // Paper - Perf: Optimize SimpleBitStorage
|
|
+ return (int) (index * this.divideMulUnsigned + this.divideAddUnsigned >> 32 >> this.divideShift); // Paper - Perf: Optimize SimpleBitStorage
|
|
}
|
|
|
|
@Override
|
|
- public int getAndSet(int index, int value) {
|
|
- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index);
|
|
- Validate.inclusiveBetween(0L, this.mask, (long)value);
|
|
+ public final int getAndSet(int index, int value) { // Paper - Perf: Optimize SimpleBitStorage
|
|
+ //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper - Perf: Optimize SimpleBitStorage
|
|
+ //Validate.inclusiveBetween(0L, this.mask, (long)value); // Paper - Perf: Optimize SimpleBitStorage
|
|
int i = this.cellIndex(index);
|
|
long l = this.data[i];
|
|
int j = (index - i * this.valuesPerLong) * this.bits;
|
|
@@ -282,9 +282,9 @@ public class SimpleBitStorage implements BitStorage {
|
|
}
|
|
|
|
@Override
|
|
- public void set(int index, int value) {
|
|
- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index);
|
|
- Validate.inclusiveBetween(0L, this.mask, (long)value);
|
|
+ public final void set(int index, int value) { // Paper - Perf: Optimize SimpleBitStorage
|
|
+ //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper - Perf: Optimize SimpleBitStorage
|
|
+ //Validate.inclusiveBetween(0L, this.mask, (long)value); // Paper - Perf: Optimize SimpleBitStorage
|
|
int i = this.cellIndex(index);
|
|
long l = this.data[i];
|
|
int j = (index - i * this.valuesPerLong) * this.bits;
|
|
@@ -292,8 +292,8 @@ public class SimpleBitStorage implements BitStorage {
|
|
}
|
|
|
|
@Override
|
|
- public int get(int index) {
|
|
- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index);
|
|
+ public final int get(int index) { // Paper - Perf: Optimize SimpleBitStorage
|
|
+ //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper - Perf: Optimize SimpleBitStorage
|
|
int i = this.cellIndex(index);
|
|
long l = this.data[i];
|
|
int j = (index - i * this.valuesPerLong) * this.bits;
|
|
diff --git a/src/main/java/net/minecraft/util/ZeroBitStorage.java b/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
|
index 8dd5a5899e9b5d8b3f1a6064dd7c1580313da69e..50040c497a819cd1229042ab3cb057d34a32cacc 100644
|
|
--- a/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
|
+++ b/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
|
@@ -13,21 +13,21 @@ public class ZeroBitStorage implements BitStorage {
|
|
}
|
|
|
|
@Override
|
|
- public int getAndSet(int index, int value) {
|
|
- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index);
|
|
- Validate.inclusiveBetween(0L, 0L, (long)value);
|
|
+ public final int getAndSet(int index, int value) { // Paper - Perf: Optimize SimpleBitStorage
|
|
+ //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper - Perf: Optimize SimpleBitStorage
|
|
+ //Validate.inclusiveBetween(0L, 0L, (long)value); // Paper - Perf: Optimize SimpleBitStorage
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
- public void set(int index, int value) {
|
|
- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index);
|
|
- Validate.inclusiveBetween(0L, 0L, (long)value);
|
|
+ public final void set(int index, int value) { // Paper - Perf: Optimize SimpleBitStorage
|
|
+ //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper - Perf: Optimize SimpleBitStorage
|
|
+ //Validate.inclusiveBetween(0L, 0L, (long)value); // Paper - Perf: Optimize SimpleBitStorage
|
|
}
|
|
|
|
@Override
|
|
- public int get(int index) {
|
|
- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index);
|
|
+ public final int get(int index) { // Paper - Perf: Optimize SimpleBitStorage
|
|
+ //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper - Perf: Optimize SimpleBitStorage
|
|
return 0;
|
|
}
|
|
|