thor
thor copied to clipboard
Darren/feat/add subscription cache
Description
This PR leverages an LRU cache for beat
, beat2
and block
subscription endpoints. It generates the messages, marshals them and caches the bytes against thor block ID.
This improves CPU performance a lot when:
- There are a high amount of transactions, eg 90% gas utilization
- There are high number of beat/ beat2 websocket connections
How Has This Been Tested?
- [x] Performance tested using https://github.com/darrenvechain/toolchain & a simple k6 script to create 10,000 websockets with an isolated node on testnet.
- [ ] Unit tests
Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my feature works
- [x] New and existing unit tests pass locally with my changes
- [x] New and existing E2E tests pass locally with my changes
- [x] Any dependent changes have been merged and published in downstream modules
- [x] I have not added any vulnerable dependencies to my code