Browse Source

Merge pull request #6530

c33c11e Improve addrman Select() performance when buckets are nearly empty (Pieter Wuille)
0.13
Wladimir J. van der Laan 9 years ago
parent
commit
ea19c2bc3f
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
  1. 12
      src/addrman.cpp

12
src/addrman.cpp

@ -341,8 +341,10 @@ CAddrInfo CAddrMan::Select_() @@ -341,8 +341,10 @@ CAddrInfo CAddrMan::Select_()
while (1) {
int nKBucket = GetRandInt(ADDRMAN_TRIED_BUCKET_COUNT);
int nKBucketPos = GetRandInt(ADDRMAN_BUCKET_SIZE);
if (vvTried[nKBucket][nKBucketPos] == -1)
continue;
while (vvTried[nKBucket][nKBucketPos] == -1) {
nKBucket = (nKBucket + insecure_rand()) % ADDRMAN_TRIED_BUCKET_COUNT;
nKBucketPos = (nKBucketPos + insecure_rand()) % ADDRMAN_BUCKET_SIZE;
}
int nId = vvTried[nKBucket][nKBucketPos];
assert(mapInfo.count(nId) == 1);
CAddrInfo& info = mapInfo[nId];
@ -356,8 +358,10 @@ CAddrInfo CAddrMan::Select_() @@ -356,8 +358,10 @@ CAddrInfo CAddrMan::Select_()
while (1) {
int nUBucket = GetRandInt(ADDRMAN_NEW_BUCKET_COUNT);
int nUBucketPos = GetRandInt(ADDRMAN_BUCKET_SIZE);
if (vvNew[nUBucket][nUBucketPos] == -1)
continue;
while (vvNew[nUBucket][nUBucketPos] == -1) {
nUBucket = (nUBucket + insecure_rand()) % ADDRMAN_NEW_BUCKET_COUNT;
nUBucketPos = (nUBucketPos + insecure_rand()) % ADDRMAN_BUCKET_SIZE;
}
int nId = vvNew[nUBucket][nUBucketPos];
assert(mapInfo.count(nId) == 1);
CAddrInfo& info = mapInfo[nId];

Loading…
Cancel
Save