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

Select orphan transaction uniformly for eviction #14626

Merged
merged 1 commit into from Feb 14, 2019

Conversation

Projects
None yet
@sipa
Copy link
Member

commented Nov 1, 2018

The previous code was biased towards evicting transactions whose txid has a larger gap (lexicographically) with the previous txid in the orphan pool.

@fanquake fanquake added the P2P label Nov 1, 2018

@DrahtBot

This comment has been minimized.

Copy link
Contributor

commented Nov 1, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

No conflicts as of last run.

@gmaxwell

This comment has been minimized.

Copy link
Member

commented Nov 3, 2018

Concept ACK.

Show resolved Hide resolved src/net_processing.cpp Outdated
Show resolved Hide resolved src/net_processing.cpp
Show resolved Hide resolved src/net_processing.cpp Outdated
Select orphan transaction uniformly for eviction
The previous code was biased towards evicting transactions whose txid has
a larger gap (lexicographically) with the previous txid in the orphan pool.

@sipa sipa force-pushed the sipa:201810_uniform_orphan_eviction branch to 7257353 Dec 13, 2018

@sipa

This comment has been minimized.

Copy link
Member Author

commented Dec 13, 2018

Rebased.

@@ -170,6 +171,8 @@ namespace {
};
std::map<COutPoint, std::set<std::map<uint256, COrphanTx>::iterator, IteratorComparator>> mapOrphanTransactionsByPrev GUARDED_BY(g_cs_orphans);

std::vector<std::map<uint256, COrphanTx>::iterator> g_orphan_list GUARDED_BY(g_cs_orphans); //! For random eviction

This comment has been minimized.

Copy link
@Empact

Empact Jan 31, 2019

Member

//!< for in-line doxygen

This comment has been minimized.

Copy link
@sipa

sipa Feb 3, 2019

Author Member

It's not storing a COrphanTx inside. It's storing a list of iterators to entries in a map from uint256 to COrphanTx.

Such iterators are only as large as one pointer.

@Empact

This comment has been minimized.

Copy link
Member

commented Jan 31, 2019

utACK 7257353

@sipa

This comment has been minimized.

Copy link
Member Author

commented Feb 2, 2019

@sdaftuar @naumenkogs Feel like reviewing this?

@naumenkogs
Copy link
Contributor

left a comment

Concept ACK, will look closer.

First of all, we either should remove this comment or do what it says?
struct COrphanTx { // When modifying, adapt the copy of this definition in tests/DoS_tests.

@@ -170,6 +171,8 @@ namespace {
};
std::map<COutPoint, std::set<std::map<uint256, COrphanTx>::iterator, IteratorComparator>> mapOrphanTransactionsByPrev GUARDED_BY(g_cs_orphans);

std::vector<std::map<uint256, COrphanTx>::iterator> g_orphan_list GUARDED_BY(g_cs_orphans); //! For random eviction

This comment has been minimized.

Copy link
@naumenkogs

naumenkogs Feb 3, 2019

Contributor

Is there any benefit of having COrphanTx inside, why not just using a hash?

This comment has been minimized.

Copy link
@naumenkogs

naumenkogs Feb 3, 2019

Contributor

Right, I guess it's cleaner this way. Feel free to resolve this one.

@sdaftuar

This comment has been minimized.

Copy link
Member

commented Feb 4, 2019

utACK 7257353

@gmaxwell

This comment has been minimized.

Copy link
Member

commented Feb 14, 2019

ACK

@MarcoFalke MarcoFalke merged commit 7257353 into bitcoin:master Feb 14, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

MarcoFalke added a commit that referenced this pull request Feb 14, 2019

Merge #14626: Select orphan transaction uniformly for eviction
7257353 Select orphan transaction uniformly for eviction (Pieter Wuille)

Pull request description:

  The previous code was biased towards evicting transactions whose txid has a larger gap (lexicographically) with the previous txid in the orphan pool.

Tree-SHA512: e35f700aea5ed79d1bc57f64bffcb623424b40156fd0a12f05f74f981a8aa4175d5c18d042989243f7559242bdf1d6d720bcf588d28f43d74a798a4843f09c70
// Unless we're deleting the last entry in g_orphan_list, move the last
// entry to the position we're deleting.
auto it_last = g_orphan_list.back();
g_orphan_list[old_pos] = it_last;

This comment has been minimized.

Copy link
@MarcoFalke

MarcoFalke Feb 14, 2019

Member

style-nit: Looks odd to assign an iterator. (The code is still correct, since back() returns a reference, but the naming might be wrong)

@MarcoFalke

This comment has been minimized.

Copy link
Member

commented Feb 14, 2019

ACK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.