aboutsummaryrefslogtreecommitdiffstats
path: root/ethdb/database.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-02-19 20:29:19 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-03-09 16:33:39 +0800
commite90958cd29a228b051faeaa25d66e053cf9d2228 (patch)
treedd7dd52d31628375ead8a06e681441102faf9037 /ethdb/database.go
parent05c86c2c9fa14ea03fdc5d0cd77cdecc34e4f164 (diff)
downloaddexon-e90958cd29a228b051faeaa25d66e053cf9d2228.tar.gz
dexon-e90958cd29a228b051faeaa25d66e053cf9d2228.tar.zst
dexon-e90958cd29a228b051faeaa25d66e053cf9d2228.zip
cmd, eth, ethdb, node: prioritise chaindata for resources, bump cache
Diffstat (limited to 'ethdb/database.go')
-rw-r--r--ethdb/database.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/ethdb/database.go b/ethdb/database.go
index 10dc018b0..dffb42e2b 100644
--- a/ethdb/database.go
+++ b/ethdb/database.go
@@ -39,8 +39,15 @@ var OpenFileLimit = 64
// cacheRatio specifies how the total alloted cache is distributed between the
// various system databases.
var cacheRatio = map[string]float64{
- "dapp": 2.0 / 13.0,
- "chaindata": 11.0 / 13.0,
+ "dapp": 0.0,
+ "chaindata": 1.0,
+}
+
+// handleRatio specifies how the total alloted file descriptors is distributed
+// between the various system databases.
+var handleRatio = map[string]float64{
+ "dapp": 0.0,
+ "chaindata": 1.0,
}
type LDBDatabase struct {
@@ -62,17 +69,21 @@ type LDBDatabase struct {
}
// NewLDBDatabase returns a LevelDB wrapped object.
-func NewLDBDatabase(file string, cache int) (*LDBDatabase, error) {
- // Calculate the cache allowance for this particular database
+func NewLDBDatabase(file string, cache int, handles int) (*LDBDatabase, error) {
+ // Calculate the cache and file descriptor allowance for this particular database
cache = int(float64(cache) * cacheRatio[filepath.Base(file)])
if cache < 16 {
cache = 16
}
- glog.V(logger.Info).Infof("Alloted %dMB cache to %s", cache, file)
+ handles = int(float64(handles) * handleRatio[filepath.Base(file)])
+ if handles < 16 {
+ handles = 16
+ }
+ glog.V(logger.Info).Infof("Alloted %dMB cache and %d file handles to %s", cache, handles, file)
// Open the db and recover any potential corruptions
db, err := leveldb.OpenFile(file, &opt.Options{
- OpenFilesCacheCapacity: OpenFileLimit,
+ OpenFilesCacheCapacity: handles,
BlockCacheCapacity: cache / 2 * opt.MiB,
WriteBuffer: cache / 4 * opt.MiB, // Two of these are used internally
})