Skip to content

Conversation

JeremyRubin
Copy link
Contributor

@JeremyRubin JeremyRubin commented Mar 27, 2017

This PR is in response to #10026 and some feedback on #9938.

Locally, all the checkqueue tests ran 3.2X faster on my machine. The worst offender, test_CheckQueue_Correct_Random ran 3.4X faster.

  1. Removes GetRand() and replaces it with a single deterministic FastRandomContext instance. Use FastRandomContext for all tests #10321 replicated this

  2. Exposes more parallelism with relaxed atomics, increasing chance of catching a bug. This does not change performance on my machine.

  3. Makes one test case more restrictive (xor instead of or, see Lock-Free CheckQueue #9938).

@maflcko maflcko added the Tests label Mar 27, 2017
@laanwj
Copy link
Member

laanwj commented Mar 29, 2017

Great!

Removes GetRand() and replaces it with a single deterministic FastRandomContext instance.

I'd prefer to create a deterministic FastRandomContext per test case, and pass that in where necessary instead of using a global helper function. Otherwise determinism depends on the order in which test cases are run, which might change if e.g. new ones are added.

@JeremyRubin JeremyRubin force-pushed the speedup-checkqueue-tests branch 2 times, most recently from 18b4830 to 690acd1 Compare March 29, 2017 15:03
@fanquake
Copy link
Member

Tested with src/test/test_bitcoin --log_level=all --run_test=checkqueue_tests

5 runs of master (edc62c9):

Leaving test suite "checkqueue_tests"; testing time: 54747669us
Leaving test suite "checkqueue_tests"; testing time: 56930968us
Leaving test suite "checkqueue_tests"; testing time: 54294643us
Leaving test suite "checkqueue_tests"; testing time: 51370752us
Leaving test suite "checkqueue_tests"; testing time: 50775172us

avg = ~53623841us

vs 5 runs of this PR (5004e46):

Leaving test suite "checkqueue_tests"; testing time: 39590527us
Leaving test suite "checkqueue_tests"; testing time: 39301795us
Leaving test suite "checkqueue_tests"; testing time: 40510899us
Leaving test suite "checkqueue_tests"; testing time: 40516578us
Leaving test suite "checkqueue_tests"; testing time: 39856853us

avg = ~39955330us

= ~1.3times speed increase

@JeremyRubin
Copy link
Contributor Author

@fanquake what architecture are you running on? How many cores?

Anyways, on my system I clock the original test suite (e.g., still getrand) as taking 0.3s after my queue improvements, so I think it's safe to just wait until those make it in for a performance gain.

@@ -160,7 +161,7 @@ void Correct_Queue_range(std::vector<size_t> range)
FakeCheckCheckCompletion::n_calls = 0;
CCheckQueueControl<FakeCheckCheckCompletion> control(small_queue.get());
while (total) {
vChecks.resize(std::min(total, (size_t) GetRand(10)));
vChecks.resize(std::min(total, (size_t) (insecure_rand.rand32() % 10)));
Copy link
Member

Choose a reason for hiding this comment

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

This was already replaced in #10321. Needs rebase.

@JeremyRubin JeremyRubin force-pushed the speedup-checkqueue-tests branch from abfcd05 to 7831902 Compare August 9, 2017 09:00
…). Fix a test to check the exclusive or of two properties rather than just or.
@JeremyRubin JeremyRubin force-pushed the speedup-checkqueue-tests branch from 7831902 to 8c2f4b8 Compare August 9, 2017 09:07
@JeremyRubin JeremyRubin changed the title Speedup & Slightly Improve Unit Tests for Checkqueue Slightly Improve Unit Tests for Checkqueue Aug 9, 2017
@maflcko
Copy link
Member

maflcko commented Oct 5, 2017

utACK 8c2f4b8

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

utACK 8c2f4b8. Looks good.

fails = queue->ControlMutex.try_lock();
}
{
// Unfreeze (we need lock n case of spurious wakeup)
Copy link
Contributor

Choose a reason for hiding this comment

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

s/n/in/

}
// Unfreeze
}
// Try to get control of the queue a bunch of times
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add "must always fail" or "should always fail."

@ryanofsky
Copy link
Contributor

Can this be merged? It's a simple test improvement with two acks.

@sipa
Copy link
Member

sipa commented Oct 12, 2017

utACK 8c2f4b8

@sipa sipa merged commit 8c2f4b8 into bitcoin:master Oct 12, 2017
sipa added a commit that referenced this pull request Oct 12, 2017
8c2f4b8 Expose more parallelism with relaxed atomics (suggested in #9938). Fix a test to check the exclusive or of two properties rather than just or. (Jeremy Rubin)

Pull request description:

  This PR is in response to #10026 and some feedback on #9938.

  ~Locally, all the checkqueue tests ran 3.2X faster on my machine. The worst offender, `test_CheckQueue_Correct_Random` ran 3.4X faster.~

  1. ~Removes `GetRand()` and replaces it with a single deterministic FastRandomContext instance.~ #10321 replicated this

  1. Exposes more parallelism with relaxed atomics, increasing chance of catching a bug. This does not change performance on my machine.

  1. Makes one test case more restrictive (xor instead of or, see #9938).

Tree-SHA512: a59dfbee0273c713525a130dfedc1c7ff26f50c2aaca1e94ef5d759b1d6ea6338ffbd97f863b9f6209750d8a788a15fa8ae1bf26774ed2473c520811337e6b00
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Dec 22, 2019
8c2f4b8 Expose more parallelism with relaxed atomics (suggested in bitcoin#9938). Fix a test to check the exclusive or of two properties rather than just or. (Jeremy Rubin)

Pull request description:

  This PR is in response to bitcoin#10026 and some feedback on bitcoin#9938.

  ~Locally, all the checkqueue tests ran 3.2X faster on my machine. The worst offender, `test_CheckQueue_Correct_Random` ran 3.4X faster.~

  1. ~Removes `GetRand()` and replaces it with a single deterministic FastRandomContext instance.~ bitcoin#10321 replicated this

  1. Exposes more parallelism with relaxed atomics, increasing chance of catching a bug. This does not change performance on my machine.

  1. Makes one test case more restrictive (xor instead of or, see bitcoin#9938).

Tree-SHA512: a59dfbee0273c713525a130dfedc1c7ff26f50c2aaca1e94ef5d759b1d6ea6338ffbd97f863b9f6209750d8a788a15fa8ae1bf26774ed2473c520811337e6b00
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 2, 2020
8c2f4b8 Expose more parallelism with relaxed atomics (suggested in bitcoin#9938). Fix a test to check the exclusive or of two properties rather than just or. (Jeremy Rubin)

Pull request description:

  This PR is in response to bitcoin#10026 and some feedback on bitcoin#9938.

  ~Locally, all the checkqueue tests ran 3.2X faster on my machine. The worst offender, `test_CheckQueue_Correct_Random` ran 3.4X faster.~

  1. ~Removes `GetRand()` and replaces it with a single deterministic FastRandomContext instance.~ bitcoin#10321 replicated this

  1. Exposes more parallelism with relaxed atomics, increasing chance of catching a bug. This does not change performance on my machine.

  1. Makes one test case more restrictive (xor instead of or, see bitcoin#9938).

Tree-SHA512: a59dfbee0273c713525a130dfedc1c7ff26f50c2aaca1e94ef5d759b1d6ea6338ffbd97f863b9f6209750d8a788a15fa8ae1bf26774ed2473c520811337e6b00
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 4, 2020
8c2f4b8 Expose more parallelism with relaxed atomics (suggested in bitcoin#9938). Fix a test to check the exclusive or of two properties rather than just or. (Jeremy Rubin)

Pull request description:

  This PR is in response to bitcoin#10026 and some feedback on bitcoin#9938.

  ~Locally, all the checkqueue tests ran 3.2X faster on my machine. The worst offender, `test_CheckQueue_Correct_Random` ran 3.4X faster.~

  1. ~Removes `GetRand()` and replaces it with a single deterministic FastRandomContext instance.~ bitcoin#10321 replicated this

  1. Exposes more parallelism with relaxed atomics, increasing chance of catching a bug. This does not change performance on my machine.

  1. Makes one test case more restrictive (xor instead of or, see bitcoin#9938).

Tree-SHA512: a59dfbee0273c713525a130dfedc1c7ff26f50c2aaca1e94ef5d759b1d6ea6338ffbd97f863b9f6209750d8a788a15fa8ae1bf26774ed2473c520811337e6b00
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 12, 2020
8c2f4b8 Expose more parallelism with relaxed atomics (suggested in bitcoin#9938). Fix a test to check the exclusive or of two properties rather than just or. (Jeremy Rubin)

Pull request description:

  This PR is in response to bitcoin#10026 and some feedback on bitcoin#9938.

  ~Locally, all the checkqueue tests ran 3.2X faster on my machine. The worst offender, `test_CheckQueue_Correct_Random` ran 3.4X faster.~

  1. ~Removes `GetRand()` and replaces it with a single deterministic FastRandomContext instance.~ bitcoin#10321 replicated this

  1. Exposes more parallelism with relaxed atomics, increasing chance of catching a bug. This does not change performance on my machine.

  1. Makes one test case more restrictive (xor instead of or, see bitcoin#9938).

Tree-SHA512: a59dfbee0273c713525a130dfedc1c7ff26f50c2aaca1e94ef5d759b1d6ea6338ffbd97f863b9f6209750d8a788a15fa8ae1bf26774ed2473c520811337e6b00
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 12, 2020
8c2f4b8 Expose more parallelism with relaxed atomics (suggested in bitcoin#9938). Fix a test to check the exclusive or of two properties rather than just or. (Jeremy Rubin)

Pull request description:

  This PR is in response to bitcoin#10026 and some feedback on bitcoin#9938.

  ~Locally, all the checkqueue tests ran 3.2X faster on my machine. The worst offender, `test_CheckQueue_Correct_Random` ran 3.4X faster.~

  1. ~Removes `GetRand()` and replaces it with a single deterministic FastRandomContext instance.~ bitcoin#10321 replicated this

  1. Exposes more parallelism with relaxed atomics, increasing chance of catching a bug. This does not change performance on my machine.

  1. Makes one test case more restrictive (xor instead of or, see bitcoin#9938).

Tree-SHA512: a59dfbee0273c713525a130dfedc1c7ff26f50c2aaca1e94ef5d759b1d6ea6338ffbd97f863b9f6209750d8a788a15fa8ae1bf26774ed2473c520811337e6b00
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 12, 2020
8c2f4b8 Expose more parallelism with relaxed atomics (suggested in bitcoin#9938). Fix a test to check the exclusive or of two properties rather than just or. (Jeremy Rubin)

Pull request description:

  This PR is in response to bitcoin#10026 and some feedback on bitcoin#9938.

  ~Locally, all the checkqueue tests ran 3.2X faster on my machine. The worst offender, `test_CheckQueue_Correct_Random` ran 3.4X faster.~

  1. ~Removes `GetRand()` and replaces it with a single deterministic FastRandomContext instance.~ bitcoin#10321 replicated this

  1. Exposes more parallelism with relaxed atomics, increasing chance of catching a bug. This does not change performance on my machine.

  1. Makes one test case more restrictive (xor instead of or, see bitcoin#9938).

Tree-SHA512: a59dfbee0273c713525a130dfedc1c7ff26f50c2aaca1e94ef5d759b1d6ea6338ffbd97f863b9f6209750d8a788a15fa8ae1bf26774ed2473c520811337e6b00
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 12, 2020
8c2f4b8 Expose more parallelism with relaxed atomics (suggested in bitcoin#9938). Fix a test to check the exclusive or of two properties rather than just or. (Jeremy Rubin)

Pull request description:

  This PR is in response to bitcoin#10026 and some feedback on bitcoin#9938.

  ~Locally, all the checkqueue tests ran 3.2X faster on my machine. The worst offender, `test_CheckQueue_Correct_Random` ran 3.4X faster.~

  1. ~Removes `GetRand()` and replaces it with a single deterministic FastRandomContext instance.~ bitcoin#10321 replicated this

  1. Exposes more parallelism with relaxed atomics, increasing chance of catching a bug. This does not change performance on my machine.

  1. Makes one test case more restrictive (xor instead of or, see bitcoin#9938).

Tree-SHA512: a59dfbee0273c713525a130dfedc1c7ff26f50c2aaca1e94ef5d759b1d6ea6338ffbd97f863b9f6209750d8a788a15fa8ae1bf26774ed2473c520811337e6b00
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 12, 2020
8c2f4b8 Expose more parallelism with relaxed atomics (suggested in bitcoin#9938). Fix a test to check the exclusive or of two properties rather than just or. (Jeremy Rubin)

Pull request description:

  This PR is in response to bitcoin#10026 and some feedback on bitcoin#9938.

  ~Locally, all the checkqueue tests ran 3.2X faster on my machine. The worst offender, `test_CheckQueue_Correct_Random` ran 3.4X faster.~

  1. ~Removes `GetRand()` and replaces it with a single deterministic FastRandomContext instance.~ bitcoin#10321 replicated this

  1. Exposes more parallelism with relaxed atomics, increasing chance of catching a bug. This does not change performance on my machine.

  1. Makes one test case more restrictive (xor instead of or, see bitcoin#9938).

Tree-SHA512: a59dfbee0273c713525a130dfedc1c7ff26f50c2aaca1e94ef5d759b1d6ea6338ffbd97f863b9f6209750d8a788a15fa8ae1bf26774ed2473c520811337e6b00
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 12, 2020
8c2f4b8 Expose more parallelism with relaxed atomics (suggested in bitcoin#9938). Fix a test to check the exclusive or of two properties rather than just or. (Jeremy Rubin)

Pull request description:

  This PR is in response to bitcoin#10026 and some feedback on bitcoin#9938.

  ~Locally, all the checkqueue tests ran 3.2X faster on my machine. The worst offender, `test_CheckQueue_Correct_Random` ran 3.4X faster.~

  1. ~Removes `GetRand()` and replaces it with a single deterministic FastRandomContext instance.~ bitcoin#10321 replicated this

  1. Exposes more parallelism with relaxed atomics, increasing chance of catching a bug. This does not change performance on my machine.

  1. Makes one test case more restrictive (xor instead of or, see bitcoin#9938).

Tree-SHA512: a59dfbee0273c713525a130dfedc1c7ff26f50c2aaca1e94ef5d759b1d6ea6338ffbd97f863b9f6209750d8a788a15fa8ae1bf26774ed2473c520811337e6b00
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Jan 16, 2020
8c2f4b8 Expose more parallelism with relaxed atomics (suggested in bitcoin#9938). Fix a test to check the exclusive or of two properties rather than just or. (Jeremy Rubin)

Pull request description:

  This PR is in response to bitcoin#10026 and some feedback on bitcoin#9938.

  ~Locally, all the checkqueue tests ran 3.2X faster on my machine. The worst offender, `test_CheckQueue_Correct_Random` ran 3.4X faster.~

  1. ~Removes `GetRand()` and replaces it with a single deterministic FastRandomContext instance.~ bitcoin#10321 replicated this

  1. Exposes more parallelism with relaxed atomics, increasing chance of catching a bug. This does not change performance on my machine.

  1. Makes one test case more restrictive (xor instead of or, see bitcoin#9938).

Tree-SHA512: a59dfbee0273c713525a130dfedc1c7ff26f50c2aaca1e94ef5d759b1d6ea6338ffbd97f863b9f6209750d8a788a15fa8ae1bf26774ed2473c520811337e6b00
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants