hexresearch / hexresearch/hschain
Reduce number of DB reads and writes
- Dominant language
- C
- Stars
- 4
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Here are number of DB queries made in semi-realistic setting (4 nodes, H=633)
```
79723 "SELECT MAX(height) FROM thm_blockchain"
9099 "INSERT OR IGNORE INTO thm_wal VALUES (NULL,?,?)"
5130 "SELECT valset FROM thm_validators WHERE height = ?"
2193 "SELECT block FROM thm_blockchain WHERE height = ?"
1660 "SELECT bid FROM thm_blockchain WHERE height = ?"
1039 "SELECT round FROM thm_blockchain WHERE height = ?"
633 "SELECT message FROM thm_wal WHERE height = ? ORDER BY id"
633 "DELETE FROM thm_wal WHERE height < ?"
632 "INSERT INTO thm_validators VALUES (?,?)"
632 "INSERT INTO thm_commits VALUES (?,?)"
632 "INSERT INTO thm_blockchain VALUES (?,?,?,?)"
310 "SELECT cmt FROM thm_commits WHERE height = ?"
```
What could we see
1. Querying blockchain height is largest number of queries by far. But it's very cheap query and relevant data is likely to sit in disk cache anyway
2. Second is writing of WAL and if . We write about 14 messages per height. Absolute minimum is `StepNewHeight` + 1 propose + 4 prevotes + 4 precommits. There's not much we can do except
- Filter duplicate messages before they hit WAL
- Do not send expired timeouts #441
3. Third is block requests. Luckily caching of block could be implemented in relatively straightforward manner thanks to BCH immutability
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.