提交 53dd15a9 编写于 作者: V Vlad Ilyushchenko

Config: increased default map key capacity from 2k to 2M - this improves...

Config: increased default map key capacity from 2k to 2M - this improves performance of group by queries
上级 0d4c0e5c
......@@ -263,7 +263,7 @@ public class PropServerConfiguration implements ServerConfiguration {
this.sqlFastMapLoadFactor = getDouble(properties, "cairo.fast.map.load.factor", 0.5);
this.sqlJoinContextPoolCapacity = getInt(properties, "cairo.sql.join.context.pool.capacity", 64);
this.sqlLexerPoolCapacity = getInt(properties, "cairo.lexer.pool.capacity", 2048);
this.sqlMapKeyCapacity = getInt(properties, "cairo.sql.map.key.capacity", 2048);
this.sqlMapKeyCapacity = getInt(properties, "cairo.sql.map.key.capacity", 2048 * 1024);
this.sqlMapPageSize = getIntSize(properties, "cairo.sql.map.page.size", 4 * 1024 * 1024);
this.sqlModelPoolCapacity = getInt(properties, "cairo.model.pool.capacity", 1024);
this.sqlSortKeyPageSize = getIntSize(properties, "cairo.sql.sort.key.page.size", 4 * 1024 * 1024);
......
......@@ -146,6 +146,45 @@ public class FastMap implements Map {
this.cursor = new FastMapCursor(record, this);
}
private static boolean eqMixed(long a, long b, long lim) {
while (b < lim - 8) {
if (Unsafe.getUnsafe().getLong(a) != Unsafe.getUnsafe().getLong(b)) {
return false;
}
a += 8;
b += 8;
}
while (b < lim) {
if (Unsafe.getUnsafe().getByte(a++) != Unsafe.getUnsafe().getByte(b++)) {
return false;
}
}
return true;
}
private static boolean eqLong(long a, long b, long lim) {
while (b < lim) {
if (Unsafe.getUnsafe().getLong(a) != Unsafe.getUnsafe().getLong(b)) {
return false;
}
a += 8;
b += 8;
}
return true;
}
private static boolean eqInt(long a, long b, long lim) {
while (b < lim) {
if (Unsafe.getUnsafe().getInt(a) != Unsafe.getUnsafe().getInt(b)) {
return false;
}
a += 4;
b += 4;
}
return true;
}
@Override
public void clear() {
kPos = kStart;
......@@ -228,20 +267,16 @@ public class FastMap implements Map {
a += keyDataOffset;
b += keyDataOffset;
while (b < lim - 8) {
if (Unsafe.getUnsafe().getLong(a) != Unsafe.getUnsafe().getLong(b)) {
return false;
}
a += 8;
b += 8;
long d = lim - b;
if (d % Long.BYTES == 0) {
return eqLong(a, b, lim);
}
while (b < lim) {
if (Unsafe.getUnsafe().getByte(a++) != Unsafe.getUnsafe().getByte(b++)) {
return false;
}
if (d % Integer.BYTES == 0) {
return eqInt(a, b, lim);
}
return true;
return eqMixed(a, b, lim);
}
long getAppendOffset() {
......
......@@ -23,8 +23,6 @@
package io.questdb.std;
import io.questdb.std.str.DirectBytes;
public final class Hash {
private Hash() {
}
......@@ -40,10 +38,6 @@ public final class Hash {
return s == null ? -1 : (Chars.hashCode(s) & 0xFFFFFFF) & max;
}
public static int boundedHash(DirectBytes s, int max) {
return s == null ? -1 : (Chars.hashCode(s) & 0xFFFFFFF) & max;
}
/**
* Calculates positive integer hash of memory pointer using Java hashcode() algorithm.
*
......@@ -53,7 +47,7 @@ public final class Hash {
*/
public static int hashMem(long p, int len) {
int hash = 0;
long hi = p + len;
final long hi = p + len;
while (hi - p > 3) {
hash = (hash << 5) - hash + Unsafe.getUnsafe().getInt(p);
p += 4;
......
......@@ -143,7 +143,7 @@ public class PropServerConfigurationTest {
Assert.assertEquals(0.5, configuration.getCairoConfiguration().getSqlFastMapLoadFactor(), 0.0000001);
Assert.assertEquals(64, configuration.getCairoConfiguration().getSqlJoinContextPoolCapacity());
Assert.assertEquals(2048, configuration.getCairoConfiguration().getSqlLexerPoolCapacity());
Assert.assertEquals(2048, configuration.getCairoConfiguration().getSqlMapKeyCapacity());
Assert.assertEquals(2097152, configuration.getCairoConfiguration().getSqlMapKeyCapacity());
Assert.assertEquals(4 * 1024 * 1024, configuration.getCairoConfiguration().getSqlMapPageSize());
Assert.assertEquals(1024, configuration.getCairoConfiguration().getSqlModelPoolCapacity());
Assert.assertEquals(4 * 1024 * 1024, configuration.getCairoConfiguration().getSqlSortKeyPageSize());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册