Title: How to add multihreading to a continuous SECP256K1 Python function? Post by: SamYezi on November 06, 2022, 08:57:29 AM I have an infinite loop Python function for measuring how fast are SECP256K1 public Keys are generated.
The script: Code: from time import time Whenever I am launching the script on Pycharm, it outputs aroud 100 c/s on Windows and 300 c/s on Ubuntu. When it happens, on both os, only 1 core out ouf 4 gets loaded with this task for 100%, hence only 25% of CPU power is allocated to this. The CPU: intel core i5-4440 cpu @ 3.10ghz I'd like to allocate 2-3 cores to the task, so it gets loaded like: 50-75%. The truth is I've read documentation and watched tutorials on Python Parallelism/Multithreading and it's confusing. Not really sure how to allocate a single job across the cores. May be you could help out? Title: Re: How to add multihreading to a continuous SECP256K1 Python function? Post by: ABCbits on November 06, 2022, 09:50:22 AM Simple multiporcessing pool should do the job, although i don't know if it's good approach for multithread programming. Here's an example
Code: from multiprocessing import Pool Code: $ python3 example,py You just need to replace 2 with total thread/core you want to use and parameter inside p.map with your own function/data. Title: Re: How to add multihreading to a continuous SECP256K1 Python function? Post by: alexeyneu on November 06, 2022, 05:47:08 PM best approach to python multithreading is to use c++ instead. that's from my secp tool
Code: void brough(unsigned long long f); https://github.com/alexeyneu/secp256k1-cxx/blob/master/main.cpp#L33-L54 Title: Re: How to add multihreading to a continuous SECP256K1 Python function? Post by: NotATether on November 07, 2022, 05:31:48 PM best approach to python multithreading is to use c++ instead. Exactly what I was going to say! I wrote a secp256k1 python tool for my friend - it was dog-slow so he asked me to rewrite it in C++. Python was never really made for parallel computing anyway, that's why all the python packages that do all the scientific heavy-lifting such as numpy are written in C. Title: Re: How to add multihreading to a continuous SECP256K1 Python function? Post by: SamYezi on November 12, 2022, 06:49:16 PM best approach to python multithreading is to use c++ instead. that's from my secp tool Code: void brough(unsigned long long f); https[Suspicious link removed]yneu/secp256k1-cxx/blob/master/main.cpp#L33-L54 I see your tool over here: https[Suspicious link removed]yneu/secp256k1-cxx Unfortunatelly, there's a question, how do you compile that? You just need to have Visual Studio with Cmake and Boost installed and hit the "debug/release" button on main.cpp? Title: Re: How to add multihreading to a continuous SECP256K1 Python function? Post by: NotATether on November 12, 2022, 07:38:47 PM Code: void brough(unsigned long long f); https://github.com/alexeyneu/secp256k1-cxx/blob/master/main.cpp#L33-L54 Just wondering, does your repo support private key modular inverse? It seems to be lacking in libsecp256k1, which is a shame... breaks many applications. I'm busy making an EGCD algorithm with my shiny new brass (https://github.com/ZenulAbidin/xFD), but it would be nice if a 256-bit implementation was available as it would be *much* faster. |