shalldonow (OP)
Newbie
Offline
Activity: 5
Merit: 1
|
|
October 25, 2023, 06:30:20 PM |
|
Is there a reliable source of information, maybe academic work or independent analysis with statistics, on the average number of sha256 hashes a consumer-grade CPU can compute?
Otherwise, could somebody help me write a C code or Rust code with threads to run the computations in a multicore computer? So I can test it locally.
I just would like to know a rough estimate. I'd like to know the order of magnitude, such as hundreds of thousands or maybe millions of hashes per second.
|
|
|
|
|
digaran
Copper Member
Hero Member
Offline
Activity: 1330
Merit: 899
🖤😏
|
|
October 25, 2023, 07:08:03 PM Last edit: October 25, 2023, 08:52:32 PM by digaran |
|
Maybe this topic could also help you. The link on stackoverflow site is for 2012. Edit: I remember a powerful tool capable of running different hash functions and doing benchmark. It's called hashcat, from hashcat.net😉
|
🖤😏
|
|
|
seek3r
Legendary
Offline
Activity: 1274
Merit: 2014
|
|
October 25, 2023, 07:20:57 PM |
|
Otherwise, could somebody help me write a C code or Rust code with threads to run the computations in a multicore computer? So I can test it locally.
Might could help you with that. Can you give me infos about ur CPU that will be used for this test? Need to know so I can set the maximum of threads that will be used. Otherwise I will just set two variables so you can adjust it while testing. One for the number of used threads and one for the amount of hashes per thread. Rust is fine for you?
|
█████████████████████████ ████████▀▀████▀▀█▀▀██████ █████▀████▄▄▄▄██████▀████ ███▀███▄████████▄████▀███ ██▀███████████████████▀██ █████████████████████████ █████████████████████████ █████████████████████████ ██▄███████████████▀▀▄▄███ ███▄███▀████████▀███▄████ █████▄████▀▀▀▀████▄██████ ████████▄▄████▄▄█████████ █████████████████████████ | BitList | | █▀▀▀▀ █ █ █ █ █ █ █ █ █ █ █ █▄▄▄▄ | ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ . REAL-TIME DATA TRACKING CURATED BY THE COMMUNITY . ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ | ▀▀▀▀█ █ █ █ █ █ █ █ █ █ █ █ ▄▄▄▄█ | | List #kycfree Websites |
|
|
|
seoincorporation
Legendary
Offline
Activity: 3220
Merit: 3009
|
|
October 25, 2023, 10:47:00 PM |
|
I just made a script for this, that way op can verify how fast his PC can generate sha codes. time for a in $(seq 1 10); do echo "$a" | sha256sum; done The code is for linux and what it does is to generate 10 sha256 and print the time: real 0m0.019s user 0m0.015s sys 0m0.008s Now let's try with 1000 and see the time. real 0m1.501s user 0m1.413s sys 0m0.570s
And with 10,000 real 0m16.384s user 0m14.474s sys 0m5.943s
And i get these results with this CPU, maybe other users could test and post their results with a better PC: *-cpu product: Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz vendor: Intel Corp. physical id: 1 bus info: cpu@0 version: 6.94.3 size: 2660MHz capacity: 3200MHz width: 64 bits
|
|
|
|
shalldonow (OP)
Newbie
Offline
Activity: 5
Merit: 1
|
|
October 25, 2023, 11:49:47 PM |
|
Otherwise, could somebody help me write a C code or Rust code with threads to run the computations in a multicore computer? So I can test it locally.
Might could help you with that. Can you give me infos about ur CPU that will be used for this test? Need to know so I can set the maximum of threads that will be used. Otherwise I will just set two variables so you can adjust it while testing. One for the number of used threads and one for the amount of hashes per thread. Rust is fine for you? I have a linux machine, x86_64 architecture, 4-core Intel. Thank you!
|
|
|
|
shalldonow (OP)
Newbie
Offline
Activity: 5
Merit: 1
|
|
October 26, 2023, 12:11:21 AM |
|
I just made a script for this, that way op can verify how fast his PC can generate sha codes. time for a in $(seq 1 10); do echo "$a" | sha256sum; done The code is for linux and what it does is to generate 10 sha256 and print the time: real 0m0.019s user 0m0.015s sys 0m0.008s Now let's try with 1000 and see the time. real 0m1.501s user 0m1.413s sys 0m0.570s
And with 10,000 real 0m16.384s user 0m14.474s sys 0m5.943s
And i get these results with this CPU, maybe other users could test and post their results with a better PC: *-cpu product: Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz vendor: Intel Corp. physical id: 1 bus info: cpu@0 version: 6.94.3 size: 2660MHz capacity: 3200MHz width: 64 bits
Thanks for the code! However, it understimates the computations because it runs shell commands each time. For every hash, the operating system will load the SHA256SUM binary into memory, make the proper system calls, then execute. There is a lot of CPU cycles there which are not used for computing the hashes. I think it the proper way is to compute millions of hashes within a C or Rust program (maybe C++ too) and also measure the time within the program itself, using the languages libraries. That's because running the `time` command line ulitiy also takes into account the time to load the program into memory, setup the main function, exit the program, which is a lot of system calls and numerous CPU cycles that are not used for the computation of the hashes and they do take some miliseconds.
|
|
|
|
pooya87
Legendary
Offline
Activity: 3514
Merit: 10712
|
|
October 26, 2023, 04:25:28 AM Merited by DaveF (2), ABCbits (1) |
|
It depends on the message you want to compute the hash for. The smaller the size of the message the lower the number of blocks (internally used in SHA256) hence the faster it will compute. For example computing hash for 10 bytes is faster than 33 bytes and faster than 80 bytes and faster than 200 bytes. It is slower if you want to compute double SHA256 hash. In the context of bitcoin we almost always compute double SHA256. 33 bytes is size of majority of public keys that are hashed in the most common OP_HASH160 scripts. 80 byte is the header size that is hashed in mining and you can easily find stats for both CPUs and GPUs hashrates on the internet like [1]. [1] https://en.bitcoin.it/wiki/Non-specialized_hardware_comparison
|
. .BLACKJACK ♠ FUN. | | | ███▄██████ ██████████████▀ ████████████ █████████████████ ████████████████▄▄ ░█████████████▀░▀▀ ██████████████████ ░██████████████ █████████████████▄ ░██████████████▀ ████████████ ███████████████░██ ██████████ | | CRYPTO CASINO & SPORTS BETTING | | │ | | │ | ▄▄███████▄▄ ▄███████████████▄ ███████████████████ █████████████████████ ███████████████████████ █████████████████████████ █████████████████████████ █████████████████████████ ███████████████████████ █████████████████████ ███████████████████ ▀███████████████▀ ███████████████████ | | .
|
|
|
|
seek3r
Legendary
Offline
Activity: 1274
Merit: 2014
|
|
October 26, 2023, 06:10:11 AM |
|
I have a linux machine, x86_64 architecture, 4-core Intel. Thank you!
Alright thanks. Tried something on Rust. You can test around with the NUM_THREADS - set it to 8 if your cpu supports hyper-threading. You can test around and increase NUM_HASHES by every round to get a more precise result. Since I used crypto and rayon crates you have to add them as dependencies on your cargo.toml with their latest versions: [dependencies] crypto = "0.2.36" rayon = "1.8.0" After that, implement this code: extern crate crypto; extern crate rayon;
use crypto::digest::Digest; use crypto::sha2::Sha256; use rayon::prelude::*; use std::time::Instant;
const NUM_HASHES: usize = 1000000; const NUM_THREADS: usize = 4;
fn compute_hashes() { let string = "sha256_maxhash".as_bytes(); let mut sha = Sha256::new(); for _ in 0..NUM_HASHES { sha.input(string); let _ = sha.result_str(); sha.reset(); } }
fn main() { rayon::ThreadPoolBuilder::new() .num_threads(NUM_THREADS) .build_global() .unwrap();
let start = Instant::now(); (0..NUM_THREADS).into_par_iter().for_each(|_| compute_hashes()); let duration = start.elapsed();
let total_hashes = NUM_HASHES * NUM_THREADS; let hashes_per_second = total_hashes as f64 / duration.as_secs_f64(); println!("Time taken: {:?} seconds", duration); println!("Hash rate: {:.0} hashes per second", hashes_per_second); }
Save it and you are done! To run it just execute it via cargo run --release in the same directory.
|
█████████████████████████ ████████▀▀████▀▀█▀▀██████ █████▀████▄▄▄▄██████▀████ ███▀███▄████████▄████▀███ ██▀███████████████████▀██ █████████████████████████ █████████████████████████ █████████████████████████ ██▄███████████████▀▀▄▄███ ███▄███▀████████▀███▄████ █████▄████▀▀▀▀████▄██████ ████████▄▄████▄▄█████████ █████████████████████████ | BitList | | █▀▀▀▀ █ █ █ █ █ █ █ █ █ █ █ █▄▄▄▄ | ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ . REAL-TIME DATA TRACKING CURATED BY THE COMMUNITY . ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ | ▀▀▀▀█ █ █ █ █ █ █ █ █ █ █ █ ▄▄▄▄█ | | List #kycfree Websites |
|
|
|
NotATether
Legendary
Offline
Activity: 1666
Merit: 7034
In memory of o_e_l_e_o
|
As far as SHA256 performance on CPU is concerned, there are special instructions available on most CPUs for accelerating the computation of SHA256 hashes. These are available per-thread, so the performance you get from using some generic SHA-256 function is going to be slower than a specialized function that makes use of these opcodes. Having said that, someone made a performance benchmark to check how fast calculating SHA256 your CPU is, inside the browser: https://www.measurethat.net/Benchmarks/Show/1246/0/sha256
|
. .BLACKJACK ♠ FUN. | | | ███▄██████ ██████████████▀ ████████████ █████████████████ ████████████████▄▄ ░█████████████▀░▀▀ ██████████████████ ░██████████████ █████████████████▄ ░██████████████▀ ████████████ ███████████████░██ ██████████ | | CRYPTO CASINO & SPORTS BETTING | | │ | | │ | ▄▄███████▄▄ ▄███████████████▄ ███████████████████ █████████████████████ ███████████████████████ █████████████████████████ █████████████████████████ █████████████████████████ ███████████████████████ █████████████████████ ███████████████████ ▀███████████████▀ ███████████████████ | | .
|
|
|
|
DaveF
Legendary
Offline
Activity: 3542
Merit: 6417
Crypto Swap Exchange
|
|
October 26, 2023, 11:22:33 AM |
|
As far as SHA256 performance on CPU is concerned, there are special instructions available on most CPUs for accelerating the computation of SHA256 hashes. These are available per-thread, so the performance you get from using some generic SHA-256 function is going to be slower than a specialized function that makes use of these opcodes. Having said that, someone made a performance benchmark to check how fast calculating SHA256 your CPU is, inside the browser: https://www.measurethat.net/Benchmarks/Show/1246/0/sha256Not even tl;dr, just dr but isn't that going to only be able to use 1 core of a CPU? Usually most browsers will limit that. But no matter what running it in a browser although simple, will never give good results due to overhead. -Dave
|
|
|
|
|
shalldonow (OP)
Newbie
Offline
Activity: 5
Merit: 1
|
|
October 26, 2023, 01:46:08 PM |
|
I have a linux machine, x86_64 architecture, 4-core Intel. Thank you!
Alright thanks. Tried something on Rust. You can test around with the NUM_THREADS - set it to 8 if your cpu supports hyper-threading. You can test around and increase NUM_HASHES by every round to get a more precise result. Since I used crypto and rayon crates you have to add them as dependencies on your cargo.toml with their latest versions: [dependencies] crypto = "0.2.36" rayon = "1.8.0" After that, implement this code: extern crate crypto; extern crate rayon;
use crypto::digest::Digest; use crypto::sha2::Sha256; use rayon::prelude::*; use std::time::Instant;
const NUM_HASHES: usize = 1000000; const NUM_THREADS: usize = 4;
fn compute_hashes() { let string = "sha256_maxhash".as_bytes(); let mut sha = Sha256::new(); for _ in 0..NUM_HASHES { sha.input(string); let _ = sha.result_str(); sha.reset(); } }
fn main() { rayon::ThreadPoolBuilder::new() .num_threads(NUM_THREADS) .build_global() .unwrap();
let start = Instant::now(); (0..NUM_THREADS).into_par_iter().for_each(|_| compute_hashes()); let duration = start.elapsed();
let total_hashes = NUM_HASHES * NUM_THREADS; let hashes_per_second = total_hashes as f64 / duration.as_secs_f64(); println!("Time taken: {:?} seconds", duration); println!("Hash rate: {:.0} hashes per second", hashes_per_second); }
Save it and you are done! To run it just execute it via cargo run --release in the same directory. Thank you very much! It worked for my purposes!
|
|
|
|
seek3r
Legendary
Offline
Activity: 1274
Merit: 2014
|
|
October 26, 2023, 01:49:31 PM |
|
Thank you very much! It worked for my purposes!
Glad to hear that! Always a pleasure, especially if it means I can improve/check my Rust skills.
|
█████████████████████████ ████████▀▀████▀▀█▀▀██████ █████▀████▄▄▄▄██████▀████ ███▀███▄████████▄████▀███ ██▀███████████████████▀██ █████████████████████████ █████████████████████████ █████████████████████████ ██▄███████████████▀▀▄▄███ ███▄███▀████████▀███▄████ █████▄████▀▀▀▀████▄██████ ████████▄▄████▄▄█████████ █████████████████████████ | BitList | | █▀▀▀▀ █ █ █ █ █ █ █ █ █ █ █ █▄▄▄▄ | ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ . REAL-TIME DATA TRACKING CURATED BY THE COMMUNITY . ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ | ▀▀▀▀█ █ █ █ █ █ █ █ █ █ █ █ ▄▄▄▄█ | | List #kycfree Websites |
|
|
|
shalldonow (OP)
Newbie
Offline
Activity: 5
Merit: 1
|
|
October 26, 2023, 01:53:22 PM |
|
Using the code provided by seek3r, with some adaptions (such as using more recent package versions for the sha2 and digests crates) I was able to obtain around over 3 million double sha256 hashes per second with 2 threads. I actually computed double sha256 hashes (the output of the first digest being the input for the second), so it would be 6 million single hashes. The tests were done in a x86_64 architecture machine, running 2 threads, and each thread ran on a Intel CPU with 2.60 GHz (upper bound 4GHz).
|
|
|
|
NotFuzzyWarm
Legendary
Online
Activity: 3696
Merit: 2627
Evil beware: We have waffles!
|
|
October 28, 2023, 12:48:15 AM Last edit: October 30, 2023, 01:56:58 PM by NotFuzzyWarm |
|
Keep in mind that Intel, AMD,et al have had support for hardware sha256 functions since at least 2013 and the more recent generations of Intel & AMD cpu's now have said hardware built into the chip. Sorta like the early PC days when there were 1st math coprocessors for the 186, 286 & 386 cpu's followed by the 486 with the coprocessor in the CPU chip. Details of the Intel extensions is here.Thing is that they are for full data encryption & decryption functions both of which rely on knowing both the private and public keys for speedy processing - not mining where we only try to randomly find the right key.
|
|
|
|
odolvlobo
Legendary
Offline
Activity: 4382
Merit: 3289
|
|
October 29, 2023, 06:03:55 PM |
|
A long time ago, the Bitcoin mining hash rate on a CPU was up to 3 MH/s, and up to 1 GH/s on a GPU. They may be somewhat higher now, but still the same order of magnitude. Here is a chart: https://en.bitcoin.it/wiki/Non-specialized_hardware_comparison
|
Join an anti-signature campaign: Click ignore on the members of signature campaigns. PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
|
|
|
ymgve2
|
|
October 30, 2023, 08:39:10 PM |
|
This seems to be an example of the XY problem https://en.wikipedia.org/wiki/XY_problemIt would be easier if you told us why you need the number of hashes a consumer grade CPU can do, so we can better aid with the underlying problem you've encountered.
|
|
|
|
philipma1957
Legendary
Offline
Activity: 4186
Merit: 8162
'The right to privacy matters'
|
|
November 07, 2023, 01:17:54 PM |
|
Core i5 2500K 4/4 20.6mh from your chart is accurate as I used to mine just a tiny bit with an i5 2500 on the pool bitminter back in 2012
|
|
|
|
|