提交 0e15d614 authored 作者: Thomas Mueller's avatar Thomas Mueller

Auto-scale MAX_MEMORY_ROWS and CACHE_SIZE settings

上级 6f10091a
...@@ -1057,7 +1057,8 @@ SET AUTOCOMMIT OFF ...@@ -1057,7 +1057,8 @@ SET AUTOCOMMIT OFF
SET CACHE_SIZE int SET CACHE_SIZE int
"," ","
Sets the size of the cache in KB (each KB being 1024 bytes) for the current database. Sets the size of the cache in KB (each KB being 1024 bytes) for the current database.
The default value is = 65536 * available_RAM_in_G, i.e. 64 MB per G. The value is rounded to the next higher power of two. The default is 65536 per available GB of RAM, i.e. 64 MB per GB.
The value is rounded to the next higher power of two.
Depending on the virtual machine, the actual memory required may be higher. Depending on the virtual machine, the actual memory required may be higher.
This setting is persistent and affects all connections as there is only one cache per database. This setting is persistent and affects all connections as there is only one cache per database.
...@@ -1359,7 +1360,7 @@ SET MAX_MEMORY_ROWS int ...@@ -1359,7 +1360,7 @@ SET MAX_MEMORY_ROWS int
"," ","
The maximum number of rows in a result set that are kept in-memory. If more rows The maximum number of rows in a result set that are kept in-memory. If more rows
are read, then the rows are buffered to disk. are read, then the rows are buffered to disk.
The default value is 40000 per G of available RAM. The default is 40000 per GB of available RAM.
Admin rights are required to execute this command, as it affects all connections. Admin rights are required to execute this command, as it affects all connections.
This command commits an open transaction. This command commits an open transaction.
......
...@@ -17,9 +17,10 @@ Change Log ...@@ -17,9 +17,10 @@ Change Log
<h1>Change Log</h1> <h1>Change Log</h1>
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>Cchange default value of PAGE_SIZE from 2048 to 4096 to more closely match most filesystems block size. <ul><li>Change default value of PAGE_SIZE from 2048 to 4096 to more closely match most filesystems block size
(PageStore only; the MVStore already used 4096).
</li><li>Auto-scale MAX_MEMORY_ROWS and CACHE_SIZE settings by the amount of available RAM. Gives a better </li><li>Auto-scale MAX_MEMORY_ROWS and CACHE_SIZE settings by the amount of available RAM. Gives a better
out of box experience for people with more powerful machines. out of box experience for people with more powerful machines.
</li></ul> </li></ul>
<h2>Version 1.4.180 Beta (2014-07-13)</h2> <h2>Version 1.4.180 Beta (2014-07-13)</h2>
......
...@@ -254,7 +254,7 @@ public class SysProperties { ...@@ -254,7 +254,7 @@ public class SysProperties {
Utils.getProperty("h2.maxReconnect", 3); Utils.getProperty("h2.maxReconnect", 3);
/** /**
* System property <code>h2.maxMemoryRows</code> (default: 40000 per G of available RAM).<br /> * System property <code>h2.maxMemoryRows</code> (default: 40000 per GB of available RAM).<br />
* The default maximum number of rows to be kept in memory in a result set. * The default maximum number of rows to be kept in memory in a result set.
*/ */
public static final int MAX_MEMORY_ROWS = public static final int MAX_MEMORY_ROWS =
...@@ -561,21 +561,17 @@ public class SysProperties { ...@@ -561,21 +561,17 @@ public class SysProperties {
// we are limited by an -XmX parameter // we are limited by an -XmX parameter
return (int) (defaultValue * maxMemory / (1024 * 1024 * 1024)); return (int) (defaultValue * maxMemory / (1024 * 1024 * 1024));
} }
try {
OperatingSystemMXBean mxBean = ManagementFactory OperatingSystemMXBean mxBean = ManagementFactory
.getOperatingSystemMXBean(); .getOperatingSystemMXBean();
try {
// this method is only available on the class com.sun.management.OperatingSystemMXBean, which mxBean // this method is only available on the class com.sun.management.OperatingSystemMXBean, which mxBean
// is an instance of under the Oracle JDK, but it is not present on Android and other JDK's // is an instance of under the Oracle JDK, but it is not present on Android and other JDK's
Method method = mxBean.getClass().getMethod("getTotalPhysicalMemorySize"); Method method = Class.forName(
"com.sun.management.OperatingSystemMXBean").
getMethod("getTotalPhysicalMemorySize");
long physicalMemorySize = ((Number) method.invoke(mxBean)).longValue(); long physicalMemorySize = ((Number) method.invoke(mxBean)).longValue();
return (int) (defaultValue * physicalMemorySize / (1024 * 1024 * 1024)); return (int) (defaultValue * physicalMemorySize / (1024 * 1024 * 1024));
} catch (NoSuchMethodException e) { } catch (Exception e) {
// ignore
} catch (IllegalArgumentException e) {
// ignore
} catch (IllegalAccessException e) {
// ignore
} catch (InvocationTargetException e) {
// ignore // ignore
} }
return defaultValue; return defaultValue;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论