-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
blockchain: Introduce slice of maps for the cache map
A standard map in the go library only allocates 2^N buckets. Bucket size is a fixed value (16+(keysize*8)+(valuesize*8)). This means that a map will always double in size when allocating more key/value pairs to fit into the map. This breaks the utxomaxcachesize promise that we make to the user and for bigger sizes, the bigger the difference is. For example, if the user gives a utxomaxcache size of 18,000MiB, the map size will be around 13,000MiB. However, when this map gets filled up, the next size is around 27,000MiB, passing the 18,000MiB memory limit that the user gave. Because of this, the commit fixes this problem by having a slice of maps. This enables us to keep the size of the maps under the limit that the user gave us as we can allcate many maps at different sizes.
- Loading branch information
1 parent
c2bf96c
commit b34a14b
Showing
2 changed files
with
194 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.