Bitcoin Core mirror and no, I don't give a fuck about Monero.
Find a file
Andrew Chow 5cce4d293e
Merge bitcoin/bitcoin#27334: util: implement noexcept move assignment & move ctor for prevector
bfb9291a86 util: implement prevector's move ctor & move assignment (Martin Leitner-Ankerl)
fffc86f49f test: CScriptCheck is used a lot in std::vector, make sure that's efficient (Martin Leitner-Ankerl)
81f67977f5 util: prevector's move ctor and move assignment is `noexcept` (Martin Leitner-Ankerl)
d380d2877e bench: Add benchmark for prevector usage in std::vector (Martin Leitner-Ankerl)

Pull request description:

  `prevector`'s move assignment and move constructor were not `noexcept`, which makes it inefficient to use inside STL containers like `std::vector`. That's the case e.g. for `CScriptCheck`. This PR adds `noexcept`, and also implements the move assignment & ctor, which makes it quite a bit more efficient to use prevector in an std::vector.

  The PR also adds a benchmark which grows an `std::vector` by adding `prevector` objects to it.

  merge-base:
  |               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |            6,440.29 |          155,272.42 |    0.2% |       40,713.01 |       20,473.84 |  1.989 |       7,132.01 |    0.2% |      0.44 | `PrevectorFillVectorDirectNontrivial`
  |            3,213.19 |          311,217.35 |    0.7% |       35,373.01 |       10,214.07 |  3.463 |       6,945.00 |    0.2% |      0.43 | `PrevectorFillVectorDirectTrivial`
  |           34,749.70 |           28,777.23 |    0.1% |      364,396.05 |      110,521.94 |  3.297 |      78,568.37 |    0.1% |      0.43 | `PrevectorFillVectorIndirectNontrivial`
  |           32,535.05 |           30,736.09 |    0.4% |      353,823.31 |      103,464.53 |  3.420 |      79,871.80 |    0.2% |      0.40 | `PrevectorFillVectorIndirectTrivial`

  util: prevector's move ctor and move assignment is `noexcept`:
  |               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |            6,603.87 |          151,426.40 |    0.2% |       23,734.01 |       21,009.63 |  1.130 |       2,445.01 |    0.3% |      0.44 | `PrevectorFillVectorDirectNontrivial`
  |            1,980.93 |          504,813.15 |    0.1% |       13,784.00 |        6,304.32 |  2.186 |       2,258.00 |    0.3% |      0.44 | `PrevectorFillVectorDirectTrivial`
  |           19,110.54 |           52,327.15 |    0.1% |      139,816.41 |       51,987.72 |  2.689 |      28,512.18 |    0.1% |      0.43 | `PrevectorFillVectorIndirectNontrivial`
  |           12,334.37 |           81,074.27 |    0.7% |      125,655.12 |       39,253.58 |  3.201 |      27,854.46 |    0.2% |      0.44 | `PrevectorFillVectorIndirectTrivial`

  util: implement prevector's move ctor & move assignment
  |               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |         bra/op |   miss% |     total | benchmark
  |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
  |            5,262.66 |          190,018.01 |    0.2% |       20,157.01 |       16,745.26 |  1.204 |       2,445.01 |    0.3% |      0.44 | `PrevectorFillVectorDirectNontrivial`
  |            1,687.07 |          592,744.35 |    0.2% |       12,742.00 |        5,368.02 |  2.374 |       2,258.00 |    0.3% |      0.44 | `PrevectorFillVectorDirectTrivial`
  |           17,930.80 |           55,769.95 |    0.1% |      136,237.69 |       47,903.31 |  2.844 |      28,512.02 |    0.2% |      0.42 | `PrevectorFillVectorIndirectNontrivial`
  |           11,893.75 |           84,077.78 |    0.2% |      126,182.02 |       37,852.91 |  3.333 |      28,152.01 |    0.1% |      0.44 | `PrevectorFillVectorIndirectTrivial`

  As can be seen, mostly thanks to just `noexcept` the benchmark becomes about 2 times faster because `std::vector` can now use move operations instead of having to fall back to copy everything

  I had a look at how this change affects the other benchmarks, and they are all pretty much the same, the only noticable difference is `CCheckQueueSpeedPrevectorJob` goes from 364.56ns down to 346.21ns.

ACKs for top commit:
  achow101:
    ACK bfb9291a86
  jonatack:
    > Tested Approach ACK [bfb9291](bfb9291a86), ~ACK modulo re-verifying the implementation of the last commit.
  john-moffett:
    Approach ACK bfb9291a86
  theStack:
    Tested and light code-review ACK bfb9291a86

Tree-SHA512: 242995d7cb2f8ebfa73177aa690a505f189d91edeb8cea3e34a41ca507c8cb17c65fe2a4e196fdafc5c6e89b2b2222627bfc9f5c316517de0857b7b5e9c58225
2023-06-27 15:42:51 -04:00
.github github: Switch to yaml issue templates 2023-02-21 11:31:16 +00:00
.tx qt: Bump Transifex slug for 25.x 2023-02-27 14:01:14 +00:00
build-aux/m4 Squashed 'src/secp256k1/' changes from 4258c54f4e..705ce7ed8c 2023-06-21 11:04:00 -04:00
build_msvc Enable ellswift module in libsecp256k1 2023-06-23 14:15:49 -04:00
ci Merge bitcoin/bitcoin#27798: depends: modernize clang flags for Darwin 2023-06-22 09:47:30 +01:00
contrib contrib: remove macOS lazy_bind check 2023-06-22 15:28:47 +00:00
depends depends: Bump MacOS minimum runtime requirement to 11.0 2023-06-22 15:28:47 +00:00
doc depends: Bump MacOS minimum runtime requirement to 11.0 2023-06-22 15:28:47 +00:00
share depends: Bump MacOS minimum runtime requirement to 11.0 2023-06-22 15:28:47 +00:00
src Merge bitcoin/bitcoin#27334: util: implement noexcept move assignment & move ctor for prevector 2023-06-27 15:42:51 -04:00
test Merge bitcoin/bitcoin#27940: test: Add implicit-signed-integer-truncation:*/include/c++/ suppression 2023-06-27 15:52:33 +01:00
.cirrus.yml depends: Bump MacOS minimum runtime requirement to 11.0 2023-06-22 15:28:47 +00:00
.editorconfig ci: Drop AppVeyor CI integration 2021-09-07 06:12:53 +03:00
.gitattributes Separate protocol versioning from clientversion 2014-10-29 00:24:40 -04:00
.gitignore Squashed 'src/secp256k1/' changes from 4258c54f4e..705ce7ed8c 2023-06-21 11:04:00 -04:00
.python-version Bump python minimum version to 3.8 2023-04-21 10:18:19 +02:00
.style.yapf Update .style.yapf 2023-06-01 23:35:10 +05:30
autogen.sh build: make sure we can overwrite config.{guess,sub} 2023-06-13 14:58:43 +02:00
configure.ac build: explicitly opt-in to new fixup_chains functionality for darwin 2023-06-22 15:28:47 +00:00
CONTRIBUTING.md doc: Explain squashing with merge commits 2022-05-24 08:17:41 +02:00
COPYING doc: Update license year range to 2023 2022-12-24 11:40:16 +01:00
INSTALL.md doc: Added hyperlink for doc/build 2021-09-09 19:53:12 +05:30
libbitcoinconsensus.pc.in build: remove libcrypto as internal dependency in libbitcoinconsensus.pc 2019-11-19 15:03:44 +01:00
Makefile.am Squashed 'src/secp256k1/' changes from 4258c54f4e..705ce7ed8c 2023-06-21 11:04:00 -04:00
README.md doc: Explain Bitcoin Core in README.md 2022-05-10 07:49:09 +02:00
SECURITY.md doc: Add my key to SECURITY.md 2022-08-23 16:57:46 -04:00

Bitcoin Core integration/staging tree

https://bitcoincore.org

For an immediately usable, binary version of the Bitcoin Core software, see https://bitcoincore.org/en/download/.

What is Bitcoin Core?

Bitcoin Core connects to the Bitcoin peer-to-peer network to download and fully validate blocks and transactions. It also includes a wallet and graphical user interface, which can be optionally built.

Further information about Bitcoin Core is available in the doc folder.

License

Bitcoin Core is released under the terms of the MIT license. See COPYING for more information or see https://opensource.org/licenses/MIT.

Development Process

The master branch is regularly built (see doc/build-*.md for instructions) and tested, but it is not guaranteed to be completely stable. Tags are created regularly from release branches to indicate new official, stable release versions of Bitcoin Core.

The https://github.com/bitcoin-core/gui repository is used exclusively for the development of the GUI. Its master branch is identical in all monotree repositories. Release branches and tags do not exist, so please do not fork that repository unless it is for development reasons.

The contribution workflow is described in CONTRIBUTING.md and useful hints for developers can be found in doc/developer-notes.md.

Testing

Testing and code review is the bottleneck for development; we get more pull requests than we can review and test on short notice. Please be patient and help out by testing other people's pull requests, and remember this is a security-critical project where any mistake might cost people lots of money.

Automated Testing

Developers are strongly encouraged to write unit tests for new code, and to submit new unit tests for old code. Unit tests can be compiled and run (assuming they weren't disabled in configure) with: make check. Further details on running and extending unit tests can be found in /src/test/README.md.

There are also regression and integration tests, written in Python. These tests can be run (if the test dependencies are installed) with: test/functional/test_runner.py

The CI (Continuous Integration) systems make sure that every pull request is built for Windows, Linux, and macOS, and that unit/sanity tests are run automatically.

Manual Quality Assurance (QA) Testing

Changes should be tested by somebody other than the developer who wrote the code. This is especially important for large or high-risk changes. It is useful to add a test plan to the pull request description if testing the changes is not straightforward.

Translations

Changes to translations as well as new translations can be submitted to Bitcoin Core's Transifex page.

Translations are periodically pulled from Transifex and merged into the git repository. See the translation process for details on how this works.

Important: We do not accept translation changes as GitHub pull requests because the next pull from Transifex would automatically overwrite them again.