-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add get-db-stats command #3274
Conversation
783654f
to
e03d4d9
Compare
fdbb8d7
to
c2b1e10
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, ran locally, and it worked.
There is just a large discrepancy between the reported size and the size on disc.
command reported 1.4GB.
OSX: 2.7GB
Can just be an LMDB allocation issue?
c2b1e10
to
a1b8c01
Compare
a1b8c01
to
c9c12f5
Compare
Yeah saw the same, there would be some overhead for the BTrees and some "wasted" bytes (by glossing some details of LMDB overflow pages). But yeah, I can't imagine there would be this much overhead. While pruned syncing, I'm observing the real size is almost aways double the actual used data size. I've added additional info that the resizer uses |
a001e6d
to
1cf2e2a
Compare
Adds `get-db-stats` command. This returns the LMDB entry stats and the total entry sizes for each internal blockchain db.
b6bcb69
to
37bb8a4
Compare
37bb8a4
to
b02123f
Compare
UPDATE: Resizing changed in this PR: Previous approach: on every write call This approach: Monero's approach. If a write returned a MDB_FULL error, resize and retry the transaction. Pros: no write overhead, potentially more robust. Cons: Tested on syncing base node with small initial size Tested manually with config, left overnight with at least one db resize occurring during block propagation db_init_size_mb = 500
db_grow_size_mb = 100
db_resize_threshold_mb = 99 |
Regarding DB Size: At our current height, the actual stored blockchain data takes only around 55% of the total bytes used by LMDB pages. Overflow pages are 4096 bytes each (like every other page) and hold "overflow" data bigger than one page. We are seeing a lot of this data in block_accumulated_data_db which holds the deleted bitmap for a block. Comparing a bitmap serialization vs a Vec by adding 500 random u32s we see this. Output: bitmap = 4976 (This would create an extra overflow page, meaning a total of 4096 + 4096 bytes used to store this value) Perhaps we should use a simple Vec for accumulated data let mut bm = Bitmap::create();
let mut v = Vec::new();
for _ in 0..500 {
let n = OsRng.next_u32();
bm.add(n);
v.push(n);
}
let b = bm.serialize();
eprintln!("bm.run_optimize() = {:?}", bm.run_optimize());
let b2 = bm.serialize();
assert_eq!(b.len(), b2.len());
eprintln!("bitmap = {:?}", b.len());
let b = bincode::serialize(&v).unwrap();
eprintln!("vector = {:?}", b.len()); |
Interesting. Given that the aim of MW is primarily to reduce db size I would suggest storing it as a Vec then |
b02123f
to
364c0d6
Compare
Resize everytime the database indicates it has run out of space rather than checking for each and every write.
364c0d6
to
6760a60
Compare
Description
Adds
get-db-stats
command. This returns the LMDB entry stats andthe total entry sizes for each internal blockchain db.
Motivation and Context
Useful in debugging database sizes. At height 26215
How Has This Been Tested?
Manually by running
get-db-stats