Skip to content

Commit 3513d91

Browse files
PastaPastaPastaknst
authored andcommitted
Merge dashpay#6650: perf: optimize sizeof CBLSLazyWrapper
d70260d perf: optimize sizeof CBLSLazyWrapper (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented members of `CBLSLazyWrapper` has bad padding ## What was done? This PR reduces memory consumption for classes CBLSLazySignature and CBLSLazyPublicKey on x86_64 sizeof(CBLSLazyPublicKey)=344 down to 336 sizeof(CBLSLazySignature)=536 down to 528 During full index close to ~1Bln of CBLSLazyPublicKey objects are created and destroyed as members of CDeterministicMNState and CSimplifiedMNListEntry with peak in memory close to ~1Mln It gave a bit of RAM saving (roughly 8Mb in peak) and a bit of CPU saving by being more cache friendly. CBLSLazySignature is not used as widely as CBLSLazyPublicKey ## How Has This Been Tested? Performance improvement is unmeasurable small (expected improvement is seconds for full re-index and μseconds per a block) ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone ACKs for top commit: UdjinM6: utACK d70260d PastaPastaPasta: utACK d70260d Tree-SHA512: a3927f039d15819e01b1a0f760299651ec8336ca7ef288413a459715018407ac313612fd2c3a3ea80c135266af6ffc0784d07cc79a0f33ed532a6e109d368445
1 parent 4231c57 commit 3513d91

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/bls/bls.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,14 @@ class CBLSLazyWrapper
391391
mutable std::mutex mutex;
392392

393393
mutable std::array<uint8_t, BLSObject::SerSize> vecBytes;
394-
// Indicates if the value contained in vecBytes is valid
395-
mutable bool bufValid{false};
396-
mutable bool bufLegacyScheme{true};
397394

398395
mutable BLSObject obj;
399396
mutable bool objInitialized{false};
400397

398+
// Indicates if the value contained in vecBytes is valid
399+
mutable bool bufValid{false};
400+
mutable bool bufLegacyScheme{true};
401+
401402
mutable uint256 hash;
402403

403404
public:

0 commit comments

Comments
 (0)