Bitcoin Forum
May 25, 2024, 10:10:24 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [PATCH] jsMiner: perf improvement  (Read 2030 times)
mrb (OP)
Legendary
*
Offline Offline

Activity: 1512
Merit: 1027


View Profile WWW
May 30, 2011, 10:15:32 PM
Last edit: May 30, 2011, 11:54:58 PM by mrb
 #1

I spent 15min, for fun, looking at possible optimizations for jsMiner. My patch simply inlines some functions, pre-computes constants, and caches array values, and ends up increasing its performance by ~1.7x under V8 (benchmarked within nodejs 0.1.97) on my Core i3-i380UM (1.33GHz), from 8.3 kHash/s to 13.9 kHsh/s.

This means jsMiner is "only" between 1/38th and 1/59th the performance of cpuminer 1.0.1:
* 'cryptopp' algo: 525 kHash/s
* '4way' algo: 825 kHash/s

See http://pastie.org/1995279
1bitc0inplz
Member
**
Offline Offline

Activity: 112
Merit: 10


View Profile
May 30, 2011, 11:07:25 PM
 #2

Wow!

Thank you. I have not yet looked at your patch, but that is awesome that you were able to increase the performance like that.

I will look over this patch and post back up... But, I did want to post sooner rather than later to let you know that I saw your message.

Thanks again.

Mine @ http://pool.bitp.it - No fees, virtually 0 stales, what's not to love!
Chat with us @ #bitp.it on irc.freenode.net
Learn more about our pool @ http://forum.bitcoin.org/index.php?topic=12181.0
AngelusWebDesign
Sr. Member
****
Offline Offline

Activity: 392
Merit: 250


View Profile
May 30, 2011, 11:37:35 PM
 #3

1bitcoinplz:

Have you looked into various techniques for Javascript optimization? I did a lot of that a few years ago when I wrote a Warcraft II clone that plays in the browser. I wanted to squeeze every CPU cycle I could out of the Javascript engines/CPUs of the time.

I read up on various things you can do -- I think it helped. You can even "compile" your code using a PHP/C/VB.net program to replace constants with actual numbers. That way, your code is readable/understandable, yet you're not using "variables" when you don't have to.

I wrote my own "obfuscator" as well, which reduced the file size and made it hard to follow.
1bitc0inplz
Member
**
Offline Offline

Activity: 112
Merit: 10


View Profile
May 31, 2011, 06:04:58 AM
 #4

I've been looking over the patch. It looks like you found some performance tweaks in the SHA implementation. That is, one area of our code where we just took a literal approach to the algorithm. So, I cannot say I'm surprised it can be cleaned up a bit.

mrb, did you want to setup a pull request on github? I'd like to see about incorporating your changes.

AngelusWebDesign, I was under the impression that browsers like Chrome and Safari did JIT compilation of Javascript... I wonder if inlining constants has as much an effect in those browsers? Either way, I have not looked too much into such techniques, though I should.

On a related note, we have been doing a lot of the backend stuff with node.js, and I must say... the V8 runtime & node.js are purely amazing! The turn around time on HTTP requests is super low, even with high volume. Having used ASP.NET and Rails on numerous other projects I think it'd be safe to say the CPU time and memory footprint of node.js is half of what they normally get.

Mine @ http://pool.bitp.it - No fees, virtually 0 stales, what's not to love!
Chat with us @ #bitp.it on irc.freenode.net
Learn more about our pool @ http://forum.bitcoin.org/index.php?topic=12181.0
mrb (OP)
Legendary
*
Offline Offline

Activity: 1512
Merit: 1027


View Profile WWW
May 31, 2011, 06:40:26 AM
 #5

jsMiner actually performs even faster in Chrome than in node.js!

I am not suprised either by the performance gain I got. Some people in #bitcoin-dev wrongly claimed it was already optimized, when I knew it was not.

Don't have time to set up a pull req., sorry.
Stefan Thomas
Full Member
***
Offline Offline

Activity: 234
Merit: 100


AKA: Justmoon


View Profile WWW
July 01, 2011, 01:20:46 PM
 #6

Would this sha256 function be safe for us to use inside Webcoin? Or is it "mining-specific" in some fashion? I can't see how it would be, just making sure.

Also, do you want to have a go at optimizing Webcoin's JavaScript ECDSA stuff as well? It's the bottleneck in Webcoin at the moment. Any speedup to the elliptic curve point multiplication or big integer math would be a godsend.

Twitter: @justmoon
PGP: D16E 7B04 42B9 F02E 0660  C094 C947 3700 A4B0 8BF3
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!