Skip to content

Conversation

@jnewbery
Copy link
Contributor

@jnewbery jnewbery commented Mar 28, 2019

This commit makes the pruning.py much faster.

Key insights to do this:

  • pruning.py doesn't care what kind of transactions make up the big
    blocks that are pruned in the test. Instead of making blocks with
    several large, expensive to construct and validate transactions,
    instead make the large blocks contain a single coinbase transaction with
    a huge OP_RETURN txout.
  • avoid stop-starting nodes where possible.

@practicalswift
Copy link
Contributor

Very nice! Do you have any numbers to share? :-)

@jnewbery
Copy link
Contributor Author

Very nice! Do you have any numbers to share? :-)

~30 minutes -> ~4 minutes on my machine.

(I should have mentioned that this is #10591 resurrected)

Copy link
Member

Choose a reason for hiding this comment

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

one hand clapping: can a coinbase tx ever be "non-standard"? :)

Copy link
Member

Choose a reason for hiding this comment

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

I think all coinbases are "non-standard", since we never relay them. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Heh. Would you prefer "A transaction containing this scriptPubKey would be non-standard in a non-coinbase transaction, but is consensus valid"?

I also notice that the comment incorrectly says 'scriptsig' instead of 'scriptPubKey'. I'll update.

Copy link
Member

Choose a reason for hiding this comment

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

just a joke :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needed to fix other comments, so I've fixed this too. Thanks.

Copy link
Member

@instagibbs instagibbs left a comment

Choose a reason for hiding this comment

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

tACK 3ce84d7 with non-blocking nits.

2019-03-28T18:08:04.929000Z TestFramework (INFO): Warning! This test requires 4GB of disk space and takes over 30 mins (up to 2 hours) no longer true as well for me, took far less than 5 minutes on my debug build.

Copy link
Member

Choose a reason for hiding this comment

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

block_hex? I also think a simple .hex() is kosher on master now(or at least I see many incantations of it!)

Copy link
Member

Choose a reason for hiding this comment

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

Also just as test belt and suspenders, make sure the blocks you are making are actually the size you think they are:

assert_greater_than(len(block_hex), len(big_script)*2)

or there abouts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I've changed this to use ToHex() to match other tests.

@jnewbery jnewbery force-pushed the 2019_03_faster_pruning_test branch from 3ce84d7 to ba39546 Compare March 28, 2019 19:41
@jnewbery
Copy link
Contributor Author

Force pushed some minor fixups. I also tested sending the blocks over P2P, and it's actually slower, so I've removed the comment saying we should do that.

@instagibbs
Copy link
Member

reACK ba39546

@DrahtBot DrahtBot added the Tests label Mar 28, 2019
@sipa
Copy link
Member

sipa commented Mar 28, 2019

Concept ACK

@maflcko
Copy link
Member

maflcko commented Mar 28, 2019

~30 minutes -> ~4 minutes on my machine.

That's impressive. Mind to move it to the non-extended tests?

@DrahtBot
Copy link
Contributor

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #15680 ([WIP] Remove resendwallettransactions RPC method by jnewbery)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@jnewbery
Copy link
Contributor Author

Mind to move it to the non-extended tests?

Sadly, I think this still won't run on travis. Here's my comment on the original PR:

Unfortunately, pruning.py still isn't able to run on Travis. It appears that disk access is very slow for in the Travis environment, and this test still times out/fails. Unfortunately, it's not possible to run this test without very heavy disk access - the whole point of pruning is to remove block files when disk usage goes over a certain threshold.

You've also asked that I split out the style changes into a separate commit, which is a fair request. I'll do that tomorrow.

Minor style fixups. No functional change.
This commit makes the pruning.py much faster.

Key insights to do this:

- pruning.py doesn't care what kind of transactions make up the big
blocks that are pruned in the test. Instead of making blocks with
several large, expensive to construct and validate transactions,
instead make the large blocks contain a single coinbase transaction with
a huge OP_RETURN txout.
- avoid stop-starting nodes where possible.

This test could probably be made even faster by using the P2P interface
for submitting blocks instead of the submitblock RPC.
@jnewbery jnewbery force-pushed the 2019_03_faster_pruning_test branch from ba39546 to 03d6d23 Compare March 29, 2019 15:44
@jnewbery
Copy link
Contributor Author

I've split style-only changes into their own commit, to make review easier. Pushed branch should be identical to previous.

@maflcko
Copy link
Member

maflcko commented Mar 29, 2019

utACK 03d6d23

@maflcko
Copy link
Member

maflcko commented Mar 29, 2019

Time: Less than 3 minutes on ssd and about 4 minutes on hdd. 🚀

maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Mar 29, 2019
03d6d23 [tests] make pruning test faster (John Newbery)
1c29ac4 [tests] style fixes in feature_pruning.py (John Newbery)

Pull request description:

  This commit makes the pruning.py much faster.

  Key insights to do this:

  - pruning.py doesn't care what kind of transactions make up the big
  blocks that are pruned in the test. Instead of making blocks with
  several large, expensive to construct and validate transactions,
  instead make the large blocks contain a single coinbase transaction with
  a huge OP_RETURN txout.
  - avoid stop-starting nodes where possible.

ACKs for commit 03d6d2:
  MarcoFalke:
    utACK 03d6d23

Tree-SHA512: 511642ce0fa294319dce3486fe06d75970d8ab66deda7f692be081d3056b4ce5b4cf91a7b5762eefbba224ba6c848750016454ff1e5d564acc507b1c41213628
@instagibbs
Copy link
Member

re-ACK 03d6d23

@maflcko maflcko merged commit 03d6d23 into bitcoin:master Mar 29, 2019
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.

ACK 03d6d23. Test also took ~3 minutes for me (on ssd)

WARNING:
This test uses 4GB of disk space.
This test takes 30 mins or more (up to 2 hours)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could update this comment

block.nVersion = best_block["version"]
block.hashPrevBlock = previousblockhash
block.nTime = mine_large_blocks.nTime
block.nBits = int('207fffff', 16)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could write 0x207fffff

@jnewbery
Copy link
Contributor Author

Thanks for the review @ryanofsky . This has been merged so I'm not intending to make further changes (happy to review your PR if you want to make the changes though).

vijaydasmp pushed a commit to vijaydasmp/dash that referenced this pull request Oct 19, 2021
03d6d23 [tests] make pruning test faster (John Newbery)
1c29ac4 [tests] style fixes in feature_pruning.py (John Newbery)

Pull request description:

  This commit makes the pruning.py much faster.

  Key insights to do this:

  - pruning.py doesn't care what kind of transactions make up the big
  blocks that are pruned in the test. Instead of making blocks with
  several large, expensive to construct and validate transactions,
  instead make the large blocks contain a single coinbase transaction with
  a huge OP_RETURN txout.
  - avoid stop-starting nodes where possible.

ACKs for commit 03d6d2:
  MarcoFalke:
    utACK 03d6d23

Tree-SHA512: 511642ce0fa294319dce3486fe06d75970d8ab66deda7f692be081d3056b4ce5b4cf91a7b5762eefbba224ba6c848750016454ff1e5d564acc507b1c41213628
pravblockc pushed a commit to pravblockc/dash that referenced this pull request Nov 18, 2021
03d6d23 [tests] make pruning test faster (John Newbery)
1c29ac4 [tests] style fixes in feature_pruning.py (John Newbery)

Pull request description:

  This commit makes the pruning.py much faster.

  Key insights to do this:

  - pruning.py doesn't care what kind of transactions make up the big
  blocks that are pruned in the test. Instead of making blocks with
  several large, expensive to construct and validate transactions,
  instead make the large blocks contain a single coinbase transaction with
  a huge OP_RETURN txout.
  - avoid stop-starting nodes where possible.

ACKs for commit 03d6d2:
  MarcoFalke:
    utACK 03d6d23

Tree-SHA512: 511642ce0fa294319dce3486fe06d75970d8ab66deda7f692be081d3056b4ce5b4cf91a7b5762eefbba224ba6c848750016454ff1e5d564acc507b1c41213628
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 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.

8 participants