Skip to content

Conversation

@maflcko
Copy link
Member

@maflcko maflcko commented Mar 14, 2020

Get gitian builds for two revisions, with and without #16902

@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 14, 2020

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

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.

@DrahtBot
Copy link
Contributor

Gitian builds

File commit 67dfd18
(master)
commit d622e3d68c68469cd73c29e05f84770a8f9702b1
(master and this pull)
bitcoin-0.19.99-aarch64-linux-gnu-debug.tar.gz 2a8f73aeb5c13752... 986d23604353f7c7...
bitcoin-0.19.99-aarch64-linux-gnu.tar.gz ff068319a9e46aa4... f5b8416ea3d9955e...
bitcoin-0.19.99-arm-linux-gnueabihf-debug.tar.gz a707188d3822b963... 54c22b01a20afaef...
bitcoin-0.19.99-arm-linux-gnueabihf.tar.gz 57c2972bae73eb6d... b947af8230f49fa7...
bitcoin-0.19.99-osx-unsigned.dmg 61f4694b65f2fcfa... 05dd7289b0877914...
bitcoin-0.19.99-osx64.tar.gz f9e740828f11f0b0... 15f8ae161f1a66c2...
bitcoin-0.19.99-riscv64-linux-gnu-debug.tar.gz 99dcdb32f68d93ac... 289f18c2619c76a1...
bitcoin-0.19.99-riscv64-linux-gnu.tar.gz ce7287fb7d6291d0... 93944b7ea4d0bb85...
bitcoin-0.19.99-win64-debug.zip d34b8c96ab2b5b7c... 1e976977348cddc5...
bitcoin-0.19.99-win64-setup-unsigned.exe d4d3ada682e5f876... 4973394339b02606...
bitcoin-0.19.99-win64.zip 02d580f9a33cd7bb... ecf1effa9024cb85...
bitcoin-0.19.99-x86_64-linux-gnu-debug.tar.gz ae647e3f30c5c537... 4a2269a1b83f53b0...
bitcoin-0.19.99-x86_64-linux-gnu.tar.gz e44a3ac81cfc8243... 6942e1ac36d83d34...
bitcoin-0.19.99.tar.gz 1294e333e7db1345... 3e0e55948245659d...
bitcoin-core-linux-0.20-res.yml d6aafec283db2408... dda7bc29014ae53d...
bitcoin-core-osx-0.20-res.yml e59580777ac8bda4... 41c60e64ceebb759...
bitcoin-core-win-0.20-res.yml 98b37da0cc4b66fc... f1fb48c5c7cf6d69...
linux-build.log 7963474358aebaf2... 5e90906b4ff4ec2a...
osx-build.log ed80e00b4ca0fb17... 5552b2c0af786db4...
win-build.log c7310c9b58c22cdb... f472e1b0aa5d22cc...
bitcoin-core-linux-0.20-res.yml.diff 7bc9acfbd2303a8e...
bitcoin-core-osx-0.20-res.yml.diff 1638b9afb2f81d96...
bitcoin-core-win-0.20-res.yml.diff 971c9b0a6f922817...
linux-build.log.diff ced631e32143e460...
osx-build.log.diff 4da9bb70630566ef...
win-build.log.diff 448d3d7e5c4a04de...

@maflcko
Copy link
Member Author

maflcko commented Mar 16, 2020

Tested on ARM:

Current master (with optimizations):

VerifyNestedIfScript, 5, 100, 0.25091, 0.000499568, 0.000508809, 0.000500318

This pull (without the opt):

VerifyNestedIfScript, 5, 100, 0.505166, 0.00100926, 0.0010135, 0.00100959

@maflcko
Copy link
Member Author

maflcko commented Mar 16, 2020

@fjahr , would be nice if you can test this on macOs to compare against #16902 (comment)

The bench_bitcoin binary is contained in the bitcoin-0.19.99-osx64.tar.gz archive.

@maflcko
Copy link
Member Author

maflcko commented Mar 18, 2020

@fjahr Alternatively, it would be nice to know what optimization flags you used to compile #16902 (comment)

@fjahr
Copy link
Contributor

fjahr commented Mar 18, 2020

@fjahr Alternatively, it would be nice to know what optimization flags you used to compile #16902 (comment)

Just the defaults of ./configure but I am also compiling this PR right now and will post results soon.

@maflcko
Copy link
Member Author

maflcko commented Mar 18, 2020

compiling this PR right now

The pr was mostly to get two gitian builds for osx (bitcoin-0.19.99-osx64.tar.gz). They are using the release compile flags and a cross compiler.

@fjahr
Copy link
Contributor

fjahr commented Mar 18, 2020

The pr was mostly to get two gitian builds for osx (bitcoin-0.19.99-osx64.tar.gz). They are using the release compile flags and a cross compiler.

Sorry, misread at first, here are results for bitcoin-0.19.99-osx64.tar.gz.

Master:

$ bin/bench_bitcoin -filter=VerifyNestedIfScript -evals=50
# Benchmark, evals, iterations, total, min, max, median
VerifyNestedIfScript, 50, 100, 1.88564, 0.000253594, 0.00063017, 0.000371099
VerifyNestedIfScript, 50, 100, 1.89325, 0.000237669, 0.000570061, 0.000369836
VerifyNestedIfScript, 50, 100, 1.94918, 0.000245143, 0.000753701, 0.000398808

Master and this PR:

$ bin/bench_bitcoin -filter=VerifyNestedIfScript -evals=50
# Benchmark, evals, iterations, total, min, max, median
VerifyNestedIfScript, 50, 100, 1.47942, 0.000233691, 0.000447447, 0.000285911
VerifyNestedIfScript, 50, 100, 1.52134, 0.000252425, 0.000506466, 0.000287488
VerifyNestedIfScript, 50, 100, 1.49092, 0.000252439, 0.000458893, 0.000286676

@maflcko
Copy link
Member Author

maflcko commented Mar 18, 2020

Hmmm 🤔 Now it seems to even slow it down by a bit. (Master should be the faster one)

@fjahr
Copy link
Contributor

fjahr commented Mar 18, 2020

Hmmm 🤔 Now it seems to even slow it down by a bit. (Master should be the faster one)

Yeah, I had some direct exchanges with @ajtowns as well after my results on #16902 but we could not figure it out. Let me know if you want me to do more specific testing or investigate my system aside from the information I shared so far.

@maflcko
Copy link
Member Author

maflcko commented Mar 18, 2020

The hardware you are using and the version of the operating system would help to check if this can be reproduced or if it is only happening on your end.

@fjahr
Copy link
Contributor

fjahr commented Mar 19, 2020

I think the most relevant info is:

  • MacBook Pro (13-inch, 2016)
  • Intel(R) Core(TM) i5-6287U CPU @ 3.10GHz
  • macOS 10.15.3 (latest stable)

@maflcko
Copy link
Member Author

maflcko commented Mar 19, 2020

Testing on a mac-mini shows the same result: Slower on master (the optimized version) and faster with the old code:

mac-mini:~ marco$ ./master/bitcoin-0.19.99/bin/bench_bitcoin -filter=VerifyNestedIfScript -evals=50 
# Benchmark, evals, iterations, total, min, max, median
VerifyNestedIfScript, 50, 100, 0.884273, 0.000143609, 0.000295676, 0.000151077

mac-mini:~ marco$ ./old/bitcoin-0.19.99/bin/bench_bitcoin -filter=VerifyNestedIfScript -evals=50 
# Benchmark, evals, iterations, total, min, max, median
VerifyNestedIfScript, 50, 100, 0.782465, 0.000150363, 0.000179858, 0.000153508

@ajtowns
Copy link
Contributor

ajtowns commented Mar 24, 2020

Testing on a mac-mini shows the same result:

Super weird. Maybe try setting nOpCount = 0; prior to the ++nOpCount > MAX_OPS_PER_SCRIPT check in script/interpreter.cpp and check to see what the behaviour is with much larger numbers of OP_IFs or OP_1s in bench/verify_script.cpp? If your script is {1 IF}*x NOP*y ENDIF*x 1 your runtime should be O(3x+y) in master, but O(3x+y+xy) with the revert, which ought to be noticible at the some point. (You need to change the 1000 OP_1's to OP_NOP's or you'll also violate the stack.size() + altstack.size() > MAX_STACK_SIZE test)

martinus and others added 9 commits March 28, 2020 08:31
This replaces the current benchmarking framework with nanobench [1], an
MIT licensed single-header benchmarking library, of which I am the
autor. This has in my opinion several advantages, especially on Linux:

* fast: Running all benchmarks takes ~6 seconds instead of 4m13s on
  an Intel i7-8700 CPU @ 3.20GHz.

* accurate: I ran e.g. the benchmark for SipHash_32b 10 times and
  calculate standard deviation / mean = coefficient of variation:

  * 0.57% CV for old benchmarking framework
  * 0.20% CV for nanobench

  So the benchmark results with nanobench seem to vary less than with
  the old framework.

* It automatically determines runtime based on clock precision, no need
  to specify number of evaluations.

* measure instructions, cycles, branches, instructions per cycle,
  branch misses (only Linux, when performance counters are available)

* output in markdown table format.

* Warn about unstable environment (frequency scaling, turbo, ...)

* For better profiling, it is possible to set the environment variable
  NANOBENCH_ENDLESS to force endless running of a particular benchmark
  without the need to recompile. This makes it to e.g. run "perf top"
  and look at hotspots.

Here is an example copy & pasted from the terminal output:

|             ns/byte |              byte/s |    err% |        ins/byte |        cyc/byte |    IPC |       bra/byte |   miss% |     total | benchmark
|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:----------
|                2.52 |      396,529,415.94 |    0.6% |           25.42 |            8.02 |  3.169 |           0.06 |    0.0% |      0.03 | `bench/crypto_hash.cpp RIPEMD160`
|                1.87 |      535,161,444.83 |    0.3% |           21.36 |            5.95 |  3.589 |           0.06 |    0.0% |      0.02 | `bench/crypto_hash.cpp SHA1`
|                3.22 |      310,344,174.79 |    1.1% |           36.80 |           10.22 |  3.601 |           0.09 |    0.0% |      0.04 | `bench/crypto_hash.cpp SHA256`
|                2.01 |      496,375,796.23 |    0.0% |           18.72 |            6.43 |  2.911 |           0.01 |    1.0% |      0.00 | `bench/crypto_hash.cpp SHA256D64_1024`
|                7.23 |      138,263,519.35 |    0.1% |           82.66 |           23.11 |  3.577 |           1.63 |    0.1% |      0.00 | `bench/crypto_hash.cpp SHA256_32b`
|                3.04 |      328,780,166.40 |    0.3% |           35.82 |            9.69 |  3.696 |           0.03 |    0.0% |      0.03 | `bench/crypto_hash.cpp SHA512`

[1] https://github.com/martinus/nanobench
This adds support to calculate asymptotic complexity of a benchmark.
This is similar to bitcoin#17375, but currently only one asymptote is
supported, and I have added support in the benchmark `ComplexMemPool`
as an example.

Usage is e.g. like this:

```
./bench_bitcoin -filter=ComplexMemPool -asymptote=25,50,100,200,400,600,800
```

This runs the benchmark `ComplexMemPool` several times but with
different complexityN settings. The benchmark can extract that number
and use it accordingly. Here, it's used for `childTxs`. The output is
this:

| complexityN |               ns/op |                op/s |    err% |          ins/op |          cyc/op |    IPC |     total | benchmark
|------------:|--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|----------:|:----------
|          25 |        1,064,241.00 |              939.64 |    1.4% |    3,960,279.00 |    2,829,708.00 |  1.400 |      0.01 | `ComplexMemPool`
|          50 |        1,579,530.00 |              633.10 |    1.0% |    6,231,810.00 |    4,412,674.00 |  1.412 |      0.02 | `ComplexMemPool`
|         100 |        4,022,774.00 |              248.58 |    0.6% |   16,544,406.00 |   11,889,535.00 |  1.392 |      0.04 | `ComplexMemPool`
|         200 |       15,390,986.00 |               64.97 |    0.2% |   63,904,254.00 |   47,731,705.00 |  1.339 |      0.17 | `ComplexMemPool`
|         400 |       69,394,711.00 |               14.41 |    0.1% |  272,602,461.00 |  219,014,691.00 |  1.245 |      0.76 | `ComplexMemPool`
|         600 |      168,977,165.00 |                5.92 |    0.1% |  639,108,082.00 |  535,316,887.00 |  1.194 |      1.86 | `ComplexMemPool`
|         800 |      310,109,077.00 |                3.22 |    0.1% |1,149,134,246.00 |  984,620,812.00 |  1.167 |      3.41 | `ComplexMemPool`

|   coefficient |   err% | complexity
|--------------:|-------:|------------
|   4.78486e-07 |   4.5% | O(n^2)
|   6.38557e-10 |  21.7% | O(n^3)
|   3.42338e-05 |  38.0% | O(n log n)
|   0.000313914 |  46.9% | O(n)
|     0.0129823 | 114.4% | O(log n)
|     0.0815055 | 133.8% | O(1)

The best fitting curve is O(n^2), so the algorithm seems to scale
quadratic with `childTxs` in the range 25 to 800.
Instead of `using namespace ankerl::nanobench`, just pull in ankerl::nanobench::Bench. This is the only class needed in the benchmarks anyways.
-output_cvs produces the (legacy) CSV format, and -output_json produces a big JSON file all the data that has been gathered.

Put all args into a separate struct to prevent argument explosion of BenchRunner::RunAll.
@maflcko maflcko force-pushed the 2003-benchGitianOPIF branch from 6895fba to 991966f Compare March 28, 2020 16:43
@DrahtBot
Copy link
Contributor

Gitian builds

File commit 27a82d3
(master)
commit 71ede6f8080660f3ead41b985a9d06d77d22970c
(master and this pull)
bitcoin-0.19.99-aarch64-linux-gnu-debug.tar.gz ad1ec03659569853... 34f6241dae2cef42...
bitcoin-0.19.99-aarch64-linux-gnu.tar.gz 5089797fd9a583bf... b29448e70155ad6b...
bitcoin-0.19.99-arm-linux-gnueabihf-debug.tar.gz 60300e24c9ca405b... 8c439396a2b24055...
bitcoin-0.19.99-arm-linux-gnueabihf.tar.gz 0ee586254245075a... 98f88af872f43bfc...
bitcoin-0.19.99-osx-unsigned.dmg a33b4524614c9080... 0bce971031f6bda0...
bitcoin-0.19.99-osx64.tar.gz b71b775bfd6f4f41... 9f5eda508f2049cb...
bitcoin-0.19.99-riscv64-linux-gnu-debug.tar.gz bcf14b2564bc16f9... d2d1183d1de05cb6...
bitcoin-0.19.99-riscv64-linux-gnu.tar.gz 06ae9547b089b0c8... 2914d1724b71ab94...
bitcoin-0.19.99-win64-debug.zip 628c9ecca66a231e... 1540956088d44971...
bitcoin-0.19.99-win64-setup-unsigned.exe dbbb8776c6fb98f0... ffba6abbcc2da1ff...
bitcoin-0.19.99-win64.zip 07a8a14315a79561... 56784a521238676d...
bitcoin-0.19.99-x86_64-linux-gnu-debug.tar.gz e87328e592187294... d362486c3a717f1a...
bitcoin-0.19.99-x86_64-linux-gnu.tar.gz 00867ee2b9cba802... bfc3ad62c6533581...
bitcoin-0.19.99.tar.gz a767bd5af81be41d... 51a364765a9efe51...
bitcoin-core-linux-0.20-res.yml b73d8723ec1f874c... 838c6d30b7c3d0c8...
bitcoin-core-osx-0.20-res.yml 261a24bb1f6fa1f9... 8928d2ca8272dcad...
bitcoin-core-win-0.20-res.yml 61556603241be0cf... 6f70cf660064b109...
linux-build.log 23a8d94233423c08... 7f59f0be1d229241...
osx-build.log cd2ccb82220021bb... 8447cf2eb010ea91...
win-build.log f3299bed9bb746ba... 45e8e423bf5bff6a...
bitcoin-core-linux-0.20-res.yml.diff bda903084067b66a...
bitcoin-core-osx-0.20-res.yml.diff 5970450160fce12e...
bitcoin-core-win-0.20-res.yml.diff f9da8367709b21af...
linux-build.log.diff 059f44d5da8b25a9...
osx-build.log.diff 513600f41413e92a...
win-build.log.diff 0ec42e479df98d0f...

@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 9, 2020

🐙 This pull request conflicts with the target branch and needs rebase.

@maflcko
Copy link
Member Author

maflcko commented Apr 9, 2020

With the new bench framwork I get this:

This pull with the last two commits dropped:

mac-mini:bitcoin-core marco$ ./src/bench/bench_bitcoin --filter=VerifyNestedIfScript
Warning, results might be unstable:
* NDEBUG not defined, assert() macros are evaluated

Recommendations
* Make sure you compile for Release

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          154,373.00 |            6,477.82 |    9.4% |      0.00 | :wavy_dash: `VerifyNestedIfScript` (Unstable with ~1.0 iters. Increase `minEpochIterations` to e.g. 10)
mac-mini:bitcoin-core marco$ ./src/bench/bench_bitcoin --filter=VerifyNestedIfScript
Warning, results might be unstable:
* NDEBUG not defined, assert() macros are evaluated

Recommendations
* Make sure you compile for Release

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          141,380.00 |            7,073.14 |    0.5% |      0.00 | `VerifyNestedIfScript`
mac-mini:bitcoin-core marco$ ./src/bench/bench_bitcoin --filter=VerifyNestedIfScript
Warning, results might be unstable:
* NDEBUG not defined, assert() macros are evaluated

Recommendations
* Make sure you compile for Release

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          141,859.00 |            7,049.25 |    0.4% |      0.00 | `VerifyNestedIfScript`

This pull:

mac-mini:bitcoin-core marco$ ./src/bench/bench_bitcoin --filter=VerifyNestedIfScript
Warning, results might be unstable:
* NDEBUG not defined, assert() macros are evaluated

Recommendations
* Make sure you compile for Release

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          201,531.00 |            4,962.02 |   26.1% |      0.00 | :wavy_dash: `VerifyNestedIfScript` (Unstable with ~1.0 iters. Increase `minEpochIterations` to e.g. 10)
mac-mini:bitcoin-core marco$ ./src/bench/bench_bitcoin --filter=VerifyNestedIfScript
Warning, results might be unstable:
* NDEBUG not defined, assert() macros are evaluated

Recommendations
* Make sure you compile for Release

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          148,760.00 |            6,722.24 |    0.3% |      0.00 | `VerifyNestedIfScript`
mac-mini:bitcoin-core marco$ ./src/bench/bench_bitcoin --filter=VerifyNestedIfScript
Warning, results might be unstable:
* NDEBUG not defined, assert() macros are evaluated

Recommendations
* Make sure you compile for Release

|               ns/op |                op/s |    err% |     total | benchmark
|--------------------:|--------------------:|--------:|----------:|:----------
|          149,385.00 |            6,694.11 |    0.3% |      0.00 | `VerifyNestedIfScript`

@maflcko
Copy link
Member Author

maflcko commented Apr 9, 2020

So it does seem to get slightly faster, which might point to a problem with the current bench framework.

@maflcko maflcko closed this May 7, 2020
@maflcko maflcko deleted the 2003-benchGitianOPIF branch May 7, 2020 23:20
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants