aboutsummaryrefslogtreecommitdiffstats
path: root/ethdb
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
parent05c86c2c9fa14ea03fdc5d0cd77cdecc34e4f164 (diff)
downloaddexon-e90958cd29a228b051faeaa25d66e053cf9d2228.tar
dexon-e90958cd29a228b051faeaa25d66e053cf9d2228.tar.gz
dexon-e90958cd29a228b051faeaa25d66e053cf9d2228.tar.bz2
dexon-e90958cd29a228b051faeaa25d66e053cf9d2228.tar.lz
dexon-e90958cd29a228b051faeaa25d66e053cf9d2228.tar.xz
dexon-e90958cd29a228b051faeaa25d66e053cf9d2228.tar.zst
dexon-e90958cd29a228b051faeaa25d66e053cf9d2228.zip
cmd, eth, ethdb, node: prioritise chaindata for resources, bump cache
Diffstat (limited to 'ethdb')
-rw-r--r--ethdb/database.go23
-rw-r--r--ethdb/database_test.go2
2 files changed, 18 insertions, 7 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
})
diff --git a/ethdb/database_test.go b/ethdb/database_test.go
index ae4906166..0e69a1218 100644
--- a/ethdb/database_test.go
+++ b/ethdb/database_test.go
@@ -28,7 +28,7 @@ func newDb() *LDBDatabase {
if common.FileExist(file) {
os.RemoveAll(file)
}
- db, _ := NewLDBDatabase(file, 0)
+ db, _ := NewLDBDatabase(file, 0, 0)
return db
}