Author

Topic: 🖤 (Read 118 times)

copper member
Activity: 1330
Merit: 899
🖤😏
April 05, 2023, 11:33:34 AM
#7
Do any of you know which operation is the most expensive one? It appears that each one of them perform different and depend on software and hardware, knowing which one of them is the heaviest would suffice. Thanks.
copper member
Activity: 821
Merit: 1992
April 05, 2023, 12:05:39 PM
#6
Quote
Do any of you know which operation is the most expensive one?
Probably ECDSA-related things, so going from private to public key. Hashing is usually fast, because that part is heavily optimized for speed. However, you cannot optimize ECDSA that easily. And also there are reasons why OP_CHECKSIG alone (without hashing public keys) is costly, and there is "sigops limit", but you have no "hashops limit". Even recently we had a block that exceeded those limits, and was rejected for that reason: https://bitcointalksearch.org/topic/error-connectblock-too-many-sigops-invalidchainfound-invalid-block-5447129
legendary
Activity: 1512
Merit: 7340
Farewell, Leo
April 04, 2023, 07:38:27 AM
#5
It depends on your algorithm.
It also depends on the programming language you used to implement the algorithm. sha256sum is written in C, so you should expect maximum performance. Other implementations require more time.

For NVIDIA GPUs, you can start by using nvbench: https://github.com/NVIDIA/nvbench
Not sure if it's the same, but for measuring GPU performance, NVIDEA recommends Visual Profiler: https://docs.alliancecan.ca/wiki/Nvprof
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
April 04, 2023, 05:30:20 AM
#4
Quote
Could anyone please be so kind and provide the information needed?
It depends on your algorithm. Those values can be different, it depends for example if you use CPU, GPU, FPGA or ASIC, and what is your software.

--snip--

FWIW newer x86[1] and ARMv8[2] CPU also have instruction set specifically set for SHA algorithm.

--snip--
if there is a formula to calculate them, I'd appreciate it.

By any chance, do you mean something like this https://stackoverflow.com/a/11005919 ?

[1] https://en.wikipedia.org/wiki/Intel_SHA_extensions
[2] https://en.wikichip.org/wiki/arm/armv8
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
April 04, 2023, 03:32:50 AM
#3
It depends on your algorithm. Those values can be different, it depends for example if you use CPU, GPU, FPGA or ASIC, and what is your software. Because in case of SHA-256, there are ASICs that can compute 2^32 hashes in seconds, but on CPUs it will take something between 10 minutes and 1 hour (if you use fast enough implementation). But in general, if you have some program for doing that, then you can measure it with "time" command.
Code:
$ time sha256sum empty.txt
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  empty.txt

real 0m0,001s
user 0m0,001s
sys 0m0,000s

You actually should not be using time to benchmark these operations if you're running them on GPUs and other specialized silicon, because (and you probably know this as well) it only logs CPU time, whereas these operations when used on CPUs are limited to verifying other transactions and blocks.

Ok, thanks for the reply, to make it easier, software is the fastest vanity search engine, and hardware is the latest GPU/ fastest.

For NVIDIA GPUs, you can start by using nvbench: https://github.com/NVIDIA/nvbench
copper member
Activity: 821
Merit: 1992
April 04, 2023, 12:20:05 AM
#2
Quote
Could anyone please be so kind and provide the information needed?
It depends on your algorithm. Those values can be different, it depends for example if you use CPU, GPU, FPGA or ASIC, and what is your software. Because in case of SHA-256, there are ASICs that can compute 2^32 hashes in seconds, but on CPUs it will take something between 10 minutes and 1 hour (if you use fast enough implementation). But in general, if you have some program for doing that, then you can measure it with "time" command.
Code:
$ time sha256sum empty.txt
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  empty.txt

real 0m0,001s
user 0m0,001s
sys 0m0,000s
But usually, you don't want to measure a single operation, but N operations instead.
Code:
$ cat counter.sh
#!/bin/bash
for ((i = 0 ; i < 100000 ; i++)); do
    echo $i > empty.txt
    sha256sum empty.txt > empty.txt
done

$ time ./counter.sh

real 2m6,745s
user 1m21,960s
sys 0m41,309s
As you can see, this bash script is very slow, it can do 100k hashes in 2 minutes, so it cannot even mine blocks at difficulty one. And those numbers for other hashes and algorithms will be different, because it depends on your hardware, and your implementation.
copper member
Activity: 1330
Merit: 899
🖤😏
April 03, 2023, 11:22:37 PM
#1
🖤
Jump to: