Skip to content
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

Don't keep double vote information in blockNode #575

Merged
merged 1 commit into from Feb 20, 2017

Conversation

marcopeereboom
Copy link
Member

@marcopeereboom marcopeereboom commented Feb 16, 2017

In order to keep the HF work as separate as possible, a new array was introduced in blockNode that keeps track of the version:bits tuple. With the HF work completed, we can now get rid of the voterVersion array and reuse the tuple in the stake version code.

This PR is purely mechanical.

Fixes #576

@marcopeereboom marcopeereboom added this to the v0.9.0 milestone Feb 16, 2017
@marcopeereboom marcopeereboom self-assigned this Feb 16, 2017
@marcopeereboom
Copy link
Member Author

$ go test $(glide nv) -timeout 30m
ok github.com/decred/dcrd/addrmgr 0.272s
ok github.com/decred/dcrd/blockchain 611.579s
ok github.com/decred/dcrd/blockchain/chaingen 0.107s
? github.com/decred/dcrd/blockchain/fullblocktests [no test files]
ok github.com/decred/dcrd/blockchain/indexers 0.113s
? github.com/decred/dcrd/blockchain/internal/dbnamespace [no test files]
? github.com/decred/dcrd/blockchain/internal/progresslog [no test files]
ok github.com/decred/dcrd/blockchain/stake 7.813s
? github.com/decred/dcrd/blockchain/stake/internal/dbnamespace [no test files]
ok github.com/decred/dcrd/blockchain/stake/internal/ticketdb 0.116s
ok github.com/decred/dcrd/blockchain/stake/internal/tickettreap 2.760s
ok github.com/decred/dcrd/chaincfg 0.015s
ok github.com/decred/dcrd/chaincfg/chainec 0.143s
ok github.com/decred/dcrd/chaincfg/chainhash 0.014s
? github.com/decred/dcrd/cmd/addblock [no test files]
? github.com/decred/dcrd/cmd/checkdevpremine [no test files]
? github.com/decred/dcrd/cmd/dcrctl [no test files]
? github.com/decred/dcrd/cmd/findcheckpoint [no test files]
? github.com/decred/dcrd/cmd/gencerts [no test files]
ok github.com/decred/dcrd/database 0.129s
? github.com/decred/dcrd/database/cmd/dbtool [no test files]
ok github.com/decred/dcrd/database/ffldb 2.498s
ok github.com/decred/dcrd/database/internal/treap 0.029s
ok github.com/decred/dcrd/dcrec/edwards 19.720s
ok github.com/decred/dcrd/dcrec/secp256k1 2.751s
ok github.com/decred/dcrd/dcrec/secp256k1/schnorr 1.946s
ok github.com/decred/dcrd/dcrjson 0.133s
? github.com/decred/dcrd/limits [no test files]
ok github.com/decred/dcrd/mempool 0.099s
? github.com/decred/dcrd/mining [no test files]
ok github.com/decred/dcrd/peer 0.099s
ok github.com/decred/dcrd/txscript 2.809s
ok github.com/decred/dcrd/wire 0.353s
ok github.com/decred/dcrd 0.072s

marcopeereboom pushed a commit to marcopeereboom/dcrd that referenced this pull request Feb 16, 2017
Profiles discovered that lookups into the signature cache included an
expensive comparison to the stored `sigInfo` struct. This lookup had the
potential to be more expensive than directly verifying the signature
itself!

In addition, evictions were rather expensive because they involved
reading from /dev/urandom, or equivalent, for each eviction once the
signature cache was full as well as potentially iterating over every
item in the cache in the worst-case.

To remedy this poor performance several changes have been made:
* Change the lookup key to the fixed sized 32-byte signature hash
* Perform a full equality check only if there is a cache hit which
    results in a significant  speed up for both insertions and existence
checks
* Override entries in the case of a colliding hash on insert Add an
* .IsEqual() method to the Signature and PublicKey types in the
  btcec package to facilitate easy equivalence testing
* Allocate the signature cache map with the max number of entries in
  order to avoid unnecessary map re-sizes/allocations
* Optimize evictions from the signature cache Delete the first entry
* seen which is safe from manipulation due to
    the pre image resistance of the hash function
* Double the default maximum number of entries within the signature
  cache due to the reduction in the size of a cache entry
  * With this eviction scheme, removals are effectively O(1)

Fixes decred#575.
Copy link
Member

@davecgh davecgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@marcopeereboom marcopeereboom merged commit 5e1857e into decred:master Feb 20, 2017
@marcopeereboom marcopeereboom deleted the killvoterversions branch February 20, 2017 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants