-
Notifications
You must be signed in to change notification settings - Fork 172
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
refactor: [Memory optimization] Block index duplicate PoS state #1945
Merged
jamescowens
merged 3 commits into
gridcoin-community:development
from
cyrossignol:memory-block-index
Nov 2, 2020
Merged
refactor: [Memory optimization] Block index duplicate PoS state #1945
jamescowens
merged 3 commits into
gridcoin-community:development
from
cyrossignol:memory-block-index
Nov 2, 2020
Conversation
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
This adds a function that applies the proof-of-stake timestamp mask to a block or transaction timestamp to centralize and formalize the operation into an API for other areas.
This refactors the duplicate stake spam mitigation to remove the following fields from the block index: - prevoutStake - nStakeTime ...for a memory reduction of 40 bytes per block. It also replaces the setStakeSeen container with a hash table of transient staking proof hashes. The setStakeSeen container holds a copy of the block index fields described above. This saves an additional 40 bytes of memory for every block plus the administrative overhead of storing each record in a std::set container (28 bytes?). I also optimized storage for the original setStakeSeenOrphan set by consolidating outpoints seen more than once in orphan blocks. This doesn't have much of an effect under normal circumstances.
jamescowens
approved these changes
Nov 1, 2020
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.
utACK
cyrossignol
changed the title
refactor: [Memory optimization] Remove duplicate PoS state from the block index
refactor: [Memory optimization] Block index duplicate PoS state
Nov 2, 2020
jamescowens
added a commit
that referenced
this pull request
Mar 1, 2021
Added - gui: Add RAC column to wizard summary page projects table #1951 (@cyrossignol) - rpc: clean up the superblocks function and add magnitude to getmininginfo #1966 (@jamescowens) - rpc: Add transaction size to RPC output #1971 (@cyrossignol) - voting: Add user-facing support for poll response types #1976 (@cyrossignol) - gui: Port Bitcoin Intro class (implement the ability to choose a data directory via the GUI) #1978 (@jamescowens) - gui: Port Bitcoin MacOS app nap manager #1991 (@jamescowens) - mining, rpc: Implement staking efficiency measure and improve SelectCoinsForStaking and CreateCoinStake #1992 (@jamescowens) - accrual, rpc: Implement auditsnapshotaccruals #2001 (@jamescowens) - docs: add doxygen support #2000 (@div72) - beacon: Specialized beacon storage in leveldb #2009 (@jamescowens) - rpc: Add a call to dump contracts in binary form #2011 (@div72) - rpc: Add boolean option to report active beacons only in beaconreport #2013 (@jamescowens) - consensus: Set Hilda mainnet hardfork height to 2197000 #2022 (@jamescowens) Changed - refactor: [Memory optimization] Block index duplicate PoS state #1945 (@cyrossignol) - refactor: [Memory optimization] Block index superblock and contract flags #1950 (@cyrossignol) - refactor: [Memory optimization] Remove stake modifier checksums #1954 (@cyrossignol) - refactor: [Memory optimization] Block index allocation overhead #1957 (@cyrossignol) - refactor: [Memory optimization] Remove block index subsidy fields #1960 (@cyrossignol) - refactor: [Memory optimization] Separate chain trust from the block index #1961 (@cyrossignol) - refactor: [Memory optimization] Eliminate padding between block index fields #1962 (@cyrossignol) - beacon, gui: Add check for presence of beacon private key to updateBeacon() #1968 (@jamescowens) - util: Enhance ETTS calculation #1973 (@jamescowens) - refactor: Use new clamp in util.h #1975 (@jamescowens) - gui: Redo global status for overview #1983 (@jamescowens) - util: Improvements to MilliTimer class and use in the miner and init #1987 (@jamescowens) - rpc: Move rpc files to directory #1995 (@Pythonix) - rpc: Enhance consolidateunspent and fix fee calculation #1994 (@jamescowens) - contract: Double the lookback scope of contract replay #1998 (@jamescowens) - net: Don't rely on external IP resolvers #2002 (@Tetrix42) - beacon: Change beacon map to pointers #2008 (@jamescowens) - gui: Update bitcoin_sv.ts #2014 (@sweede-se) - util: Update snapshot URLs and add accrual directory #2019 (@jamescowens) - beacon: Tweak BeaconRegistry::Revert #2020 (@jamescowens) - rpc, qt: bump fees @2023 (@div72) Removed - researcher: Remove automatic legacy beacon key import #1963 (@cyrossignol) - util: Revert "Close LevelDB after loading the block index" #1969 (@cyrossignol) - ci: Fix python symlink issue & remove travis #1990 (@div72) - ci: remove python workaround #2005 (@div72) Fixed - gui: fix mandatory/leisure detection of upgrade check #1959 (@Pythonix) - voting: Fix title in "gettransaction" RPC for legacy poll contracts @1970 (@cyrossignol) - gui: Fix missing menu items on macOS #1972 (@scribblemaniac) - rpc: Fix answer offset in "votedetails" #1974 (@cyrossignol) - voting: Implement missing try-catch in VotingVoteDialog::vote #1980 (@jamescowens) - scraper: Add check for minimum housekeeping complete in scraper #1977 (@jamescowens) - voting: Fix nonsense vote weights for legacy polls #1988 (@cyrossignol) - voting: Fix incorrect field returned in ResolveMoneySupplyForPoll() #1989 (@cyrossignol) - consensus, accrual: Fix newbie accrual #2004 (@jamescowens) - log: grammar correction #2016 (@nathanielcwm) - wallet: Correct nMinFee fee calculation in CreateTransaction #2021 (@jamescowens) - rpc, miner: Correct GetLastStake #2026 (@jamescowens) - wallet: Fix bug in CreateTransaction causing insufficient fees #2029 (@jamescowens)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is part of a series of changes that optimize the memory usage of Gridcoin's block index. According to Valgrind's heap profiler (Massif), these changes will decrease memory usage of the application by over 500 MB after the final PR merges. Because these optimizations apply to every block, memory savings will continue to accrue as the chain grows. I'm breaking-up the commits into separate PRs because the branch has become too unwieldy to review in one submission.
This refactors the duplicate stake spam mitigation to remove the following fields from the block index:
prevoutStake
nStakeTime
...for a memory reduction of 40 bytes per block.
It also replaces the
setStakeSeen
container with a hash table of transient staking proof hashes. ThesetStakeSeen
container holds a copy of the block index fields described above.This saves an additional 40 bytes of memory for every block plus the administrative overhead needed to store each record in a
std::set
container (±28 bytes depending on the platform and library implementation).I also optimized storage for the original
setStakeSeenOrphan
set by consolidating outpoints seen more than once in orphan blocks. This doesn't have much of an effect under normal circumstances.