Skip to content

Instantly share code, notes, and snippets.

@timxor
Last active August 23, 2017 22:07
Show Gist options
  • Save timxor/87f5fff7e7e1d3966a40b7bc2fc7344a to your computer and use it in GitHub Desktop.
Save timxor/87f5fff7e7e1d3966a40b7bc2fc7344a to your computer and use it in GitHub Desktop.
tims_geth_benchmarks_august

August 23rd *** macbook *** results:

➜  vm git:(master) ✗ go test -bench BenchmarkPrecompiled -benchtime 5s
BenchmarkPrecompiledEcrecover/-Gas=3000-8         	   50000	    144319 ns/op
BenchmarkPrecompiledSha256/128-Gas=108-8          	20000000	       578 ns/op
BenchmarkPrecompiledRipeMD/128-Gas=1080-8         	 5000000	      1662 ns/op
BenchmarkPrecompiledIdentity/128-Gas=27-8         	500000000	        15.3 ns/op
BenchmarkPrecompiledModExp/eip_example1-Gas=2611-8         	  300000	     29852 ns/op
BenchmarkPrecompiledModExp/eip_example2-Gas=2611-8         	 1000000	      7569 ns/op
BenchmarkPrecompiledModExp/nagydani-1-square-Gas=40-8      	 3000000	      2236 ns/op
BenchmarkPrecompiledModExp/nagydani-1-qube-Gas=40-8        	 3000000	      2997 ns/op
BenchmarkPrecompiledModExp/nagydani-1-pow0x10001-Gas=655-8 	  500000	     11987 ns/op
BenchmarkPrecompiledModExp/nagydani-2-square-Gas=133-8     	 2000000	      3717 ns/op
BenchmarkPrecompiledModExp/nagydani-2-qube-Gas=133-8       	 1000000	      5468 ns/op
BenchmarkPrecompiledModExp/nagydani-2-pow0x10001-Gas=2129-8         	  300000	     28191 ns/op
BenchmarkPrecompiledModExp/nagydani-3-square-Gas=378-8              	 1000000	      7345 ns/op
BenchmarkPrecompiledModExp/nagydani-3-qube-Gas=378-8                	  500000	     12177 ns/op
BenchmarkPrecompiledModExp/nagydani-3-pow0x10001-Gas=6062-8         	  100000	     69323 ns/op
BenchmarkPrecompiledModExp/nagydani-4-square-Gas=1116-8             	  500000	     15967 ns/op
BenchmarkPrecompiledModExp/nagydani-4-qube-Gas=1116-8               	  200000	     30117 ns/op
BenchmarkPrecompiledModExp/nagydani-4-pow0x10001-Gas=17858-8        	   50000	    187924 ns/op
BenchmarkPrecompiledModExp/nagydani-5-square-Gas=3573-8             	  200000	     39178 ns/op
BenchmarkPrecompiledModExp/nagydani-5-qube-Gas=3573-8               	  100000	     81914 ns/op
BenchmarkPrecompiledModExp/nagydani-5-pow0x10001-Gas=57180-8        	   10000	    564070 ns/op
BenchmarkPrecompiledBn256Add/chfast1-Gas=500-8                      	  200000	     40977 ns/op
BenchmarkPrecompiledBn256Add/chfast2-Gas=500-8                      	  200000	     43206 ns/op
BenchmarkPrecompiledBn256Add/cdetrio1-Gas=500-8                     	 5000000	      1332 ns/op
BenchmarkPrecompiledBn256Add/cdetrio2-Gas=500-8                     	 5000000	      1365 ns/op
BenchmarkPrecompiledBn256Add/cdetrio3-Gas=500-8                     	 5000000	      1361 ns/op
BenchmarkPrecompiledBn256Add/cdetrio4-Gas=500-8                     	 5000000	      1393 ns/op
BenchmarkPrecompiledBn256Add/cdetrio5-Gas=500-8                     	 5000000	      1337 ns/op
BenchmarkPrecompiledBn256Add/cdetrio6-Gas=500-8                     	 5000000	      1442 ns/op
BenchmarkPrecompiledBn256Add/cdetrio7-Gas=500-8                     	 5000000	      1449 ns/op
BenchmarkPrecompiledBn256Add/cdetrio8-Gas=500-8                     	 5000000	      1474 ns/op
BenchmarkPrecompiledBn256Add/cdetrio9-Gas=500-8                     	 5000000	      1454 ns/op
BenchmarkPrecompiledBn256Add/cdetrio10-Gas=500-8                    	 5000000	      1452 ns/op
BenchmarkPrecompiledBn256Add/cdetrio11-Gas=500-8                    	 1000000	      6221 ns/op
BenchmarkPrecompiledBn256Add/cdetrio12-Gas=500-8                    	 1000000	      6182 ns/op
BenchmarkPrecompiledBn256Add/cdetrio13-Gas=500-8                    	  200000	     40954 ns/op
BenchmarkPrecompiledBn256Add/cdetrio14-Gas=500-8                    	 1000000	      6039 ns/op
BenchmarkPrecompiledBn256ScalarMul/chfast1-Gas=2000-8               	   20000	    420845 ns/op
BenchmarkPrecompiledBn256ScalarMul/chfast2-Gas=2000-8               	    5000	   1634706 ns/op
BenchmarkPrecompiledBn256ScalarMul/chfast3-Gas=2000-8               	    5000	   1612314 ns/op
BenchmarkPrecompiledBn256Pairing/jeff1-Gas=260000-8                 	     500	  17302458 ns/op
BenchmarkPrecompiledBn256Pairing/jeff2-Gas=260000-8                 	     500	  17160573 ns/op
BenchmarkPrecompiledBn256Pairing/jeff3-Gas=260000-8                 	     500	  17041258 ns/op
BenchmarkPrecompiledBn256Pairing/jeff4-Gas=340000-8                 	     300	  21977570 ns/op
BenchmarkPrecompiledBn256Pairing/jeff5-Gas=340000-8                 	     300	  21854866 ns/op
BenchmarkPrecompiledBn256Pairing/jeff6-Gas=260000-8                 	     500	  17257593 ns/op
BenchmarkPrecompiledBn256Pairing/empty_data-Gas=100000-8            	    5000	   1451992 ns/op
BenchmarkPrecompiledBn256Pairing/one_point-Gas=180000-8             	     500	  11918127 ns/op
BenchmarkPrecompiledBn256Pairing/two_point_match_2-Gas=260000-8     	    1000	  10355579 ns/op
BenchmarkPrecompiledBn256Pairing/two_point_match_3-Gas=260000-8     	     500	  16730228 ns/op
BenchmarkPrecompiledBn256Pairing/two_point_match_4-Gas=260000-8     	     500	  16751615 ns/op
BenchmarkPrecompiledBn256Pairing/ten_point_match_1-Gas=900000-8     	     200	  45620049 ns/op
BenchmarkPrecompiledBn256Pairing/ten_point_match_2-Gas=900000-8     	     100	  53389117 ns/op
BenchmarkPrecompiledBn256Pairing/ten_point_match_3-Gas=260000-8     	     500	  16783709 ns/op
PASS
ok  	_/Users/tim.siwula/Dropbox/Projects/go-ethereum/core/vm	478.468s
➜  vm git:(master) ✗ git rev-parse HEAD
3c48a25762dfab9382791c33a2f5832466077ac3

August 22nd *** macbook *** results:

➜  go-ethereum git:(master) git rev-parse HEAD
8d6a5a3581ce6221786eb464bfef7e8c31e7ad95
➜  go-ethereum git:(master) cd core/vm
➜  vm git:(master) go test -bench BenchmarkPrecompiled -benchtime 5s
BenchmarkPrecompiledEcdsa-8      	   50000	    153764 ns/op
BenchmarkPrecompiledSha256-8     	^[^[^C%                                                                                                                                                                                               ➜  vm git:(master) go test -bench BenchmarkPrecompiled -benchtime 5s
BenchmarkPrecompiledEcdsa-8      	   50000	    159277 ns/op
BenchmarkPrecompiledSha256-8     	10000000	       637 ns/op
BenchmarkPrecompiledRipeMD-8     	 3000000	      1982 ns/op
BenchmarkPrecompiledIdentity-8   	500000000	        16.3 ns/op
PASS
ok  	github.com/ethereum/go-ethereum/core/vm	34.428s
➜  vm git:(master) git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working tree clean
➜  vm git:(master) go test -bench BenchmarkPrecompiled -benchtime 5s
BenchmarkPrecompiledEcdsa-8      	   50000	    142948 ns/op
BenchmarkPrecompiledSha256-8     	20000000	       605 ns/op
BenchmarkPrecompiledRipeMD-8     	 5000000	      1806 ns/op
BenchmarkPrecompiledIdentity-8   	500000000	        15.3 ns/op
PASS
ok  	github.com/ethereum/go-ethereum/core/vm	41.468s
➜  vm git:(master)

August 21st:

*** macbook ***

August 19th *** macbook *** results:

=> go test -bench BenchmarkPrecompiled -benchtime 5s
BenchmarkPrecompiledEcdsa/-Gas=3000-8  	   50000	    163069 ns/op
BenchmarkPrecompiledSha256/128-Gas=108-8         	10000000	       645 ns/op
BenchmarkPrecompiledRipeMD/128-Gas=1080-8        	 5000000	      1877 ns/op
BenchmarkPrecompiledIdentity/128-Gas=27-8        	500000000	        17.3 ns/op
BenchmarkPrecompiledModexp/eip_example1-Gas=4197376-8         	  200000	     33746 ns/op
BenchmarkPrecompiledModexp/eip_example2-Gas=4459488-8         	 1000000	      7438 ns/op
BenchmarkPrecompiledBn256Add/chfast1-Gas=0-8                  	  200000	     45821 ns/op
BenchmarkPrecompiledBn256Add/chfast2-Gas=0-8                  	  200000	     48056 ns/op
BenchmarkPrecompiledBn256ScalarMul/chfast1-Gas=0-8            	   20000	    471451 ns/op
BenchmarkPrecompiledBn256ScalarMul/chfast2-Gas=0-8            	    5000	   1765534 ns/op
BenchmarkPrecompiledBn256ScalarMul/chfast3-Gas=0-8            	    5000	   1764253 ns/op
BenchmarkPrecompiledPairing/jeff1-Gas=160000-8                	     500	  18605464 ns/op
BenchmarkPrecompiledPairing/jeff2-Gas=160000-8                	     500	  18702602 ns/op
BenchmarkPrecompiledPairing/jeff3-Gas=160000-8                	     500	  18771734 ns/op
BenchmarkPrecompiledPairing/jeff4-Gas=220000-8                	     300	  23876686 ns/op
BenchmarkPrecompiledPairing/jeff5-Gas=220000-8                	     300	  23989863 ns/op
BenchmarkPrecompiledPairing/jeff6-Gas=160000-8                	     500	  18586363 ns/op
BenchmarkPrecompiledPairing/empty_data-Gas=40000-8            	500000000	        13.6 ns/op
BenchmarkPrecompiledPairing/one_point-Gas=100000-8            	     500	  12694421 ns/op
BenchmarkPrecompiledPairing/two_point_match_2-Gas=160000-8    	    1000	  10988584 ns/op
BenchmarkPrecompiledPairing/two_point_match_3-Gas=160000-8    	     500	  19651165 ns/op
BenchmarkPrecompiledPairing/two_point_match_4-Gas=160000-8    	     500	  19152084 ns/op
BenchmarkPrecompiledPairing/ten_point_match_1-Gas=640000-8    	     100	  52055717 ns/op
BenchmarkPrecompiledPairing/ten_point_match_2-Gas=640000-8    	     100	  58129981 ns/op
BenchmarkPrecompiledPairing/ten_point_match_3-Gas=160000-8    	     500	  17919238 ns/op
PASS
ok  	github.com/ethereum/go-ethereum/core/vm	242.833s
=>

Ran on:

  Model Name:	MacBook Pro
  Model Identifier:	MacBookPro14,3
  Processor Name:	Intel Core i7
  Processor Speed:	3.1 GHz
  Number of Processors:	1
  Total Number of Cores:	4
  L2 Cache (per Core):	256 KB
  L3 Cache:	8 MB
  Memory:	16 GB
  System Version:	macOS 10.12.6 (16G29)
  Kernel Version:	Darwin 16.7.0
@holiman
Copy link

holiman commented Aug 21, 2017

Here are the post-processed values for the run above ^. Since it's not using the lastest code, I modiifed the BenchmarkPrecompiledModexp/eip_example gas calculations (they're wrong in the code you're using).

Name                                    Gascost         Time (ns)          MGas/S    Gasprice for 10MGas/S  Gas/Ideal percent
------------------------------------  ---------  ----------------  --------------  -----------------------  -------------------
PrecompiledEcdsa/                          3000  163069              18.3971                      1630.69   184.0 %
PrecompiledSha256/128                       108     645             167.442                          6.45   1674.4 %
PrecompiledRipeMD/128                      1080    1877             575.386                         18.77   5753.9 %
PrecompiledIdentity/128                      27      17.3          1560.69                           0.173  15606.9 %
PrecompiledModexp/eip_example1             2611   33746              77.3721                       337.46   773.7 %
PrecompiledModexp/eip_example2             2611    7438             351.035                         74.38   3510.4 %
PrecompiledBn256Add/chfast1                   0   45821               0                            458.21   0.0 %
PrecompiledBn256Add/chfast2                   0   48056               0                            480.56   0.0 %
PrecompiledBn256ScalarMul/chfast1             0  471451               0                           4714.51   0.0 %
PrecompiledBn256ScalarMul/chfast2             0       1.76553e+06     0                          17655.3    0.0 %
PrecompiledBn256ScalarMul/chfast3             0       1.76425e+06     0                          17642.5    0.0 %
PrecompiledPairing/jeff1                 160000       1.86055e+07     8.59962                   186055      86.0 %
PrecompiledPairing/jeff2                 160000       1.87026e+07     8.55496                   187026      85.5 %
PrecompiledPairing/jeff3                 160000       1.87717e+07     8.52345                   187717      85.2 %
PrecompiledPairing/jeff4                 220000       2.38767e+07     9.21401                   238767      92.1 %
PrecompiledPairing/jeff5                 220000       2.39899e+07     9.17054                   239899      91.7 %
PrecompiledPairing/jeff6                 160000       1.85864e+07     8.60846                   185864      86.1 %
PrecompiledPairing/empty_data             40000      13.6             2.94118e+06                    0.136  29411764.7 %
PrecompiledPairing/one_point             100000       1.26944e+07     7.87748                   126944      78.8 %
PrecompiledPairing/two_point_match_2     160000       1.09886e+07    14.5606                    109886      145.6 %
PrecompiledPairing/two_point_match_3     160000       1.96512e+07     8.14201                   196512      81.4 %
PrecompiledPairing/two_point_match_4     160000       1.91521e+07     8.35418                   191521      83.5 %
PrecompiledPairing/ten_point_match_1     640000       5.20557e+07    12.2945                    520557      122.9 %
PrecompiledPairing/ten_point_match_2     640000       5.813e+07      11.0098                    581300      110.1 %
PrecompiledPairing/ten_point_match_3     160000       1.79192e+07     8.92895                   179192      89.3 %

Would be interesting to see the results on the lastest code, with more test vectors.

@timxor
Copy link
Author

timxor commented Aug 21, 2017

*** macbook August 21st ***
*** i will make a script to make this pretty in the future -- sorry ***

BenchmarkPrecompiledEcrecover/-Gas=3000-8         	   50000	    185022 ns/op
BenchmarkPrecompiledSha256/128-Gas=108-8          	10000000	       728 ns/op
BenchmarkPrecompiledRipeMD/128-Gas=1080-8         	 3000000	      2116 ns/op
BenchmarkPrecompiledIdentity/128-Gas=27-8         	500000000	        20.0 ns/op
BenchmarkPrecompiledModExp/eip_example1-Gas=2611-8         	  200000	     37256 ns/op
BenchmarkPrecompiledModExp/eip_example2-Gas=2611-8         	 1000000	      8308 ns/op
BenchmarkPrecompiledModExp/nagydani-1-square-Gas=40-8      	 3000000	      3183 ns/op
BenchmarkPrecompiledModExp/nagydani-1-qube-Gas=40-8        	 2000000	      3844 ns/op
BenchmarkPrecompiledModExp/nagydani-1-pow0x10001-Gas=655-8 	  500000	     15398 ns/op
BenchmarkPrecompiledModExp/nagydani-2-square-Gas=133-8     	 2000000	      4800 ns/op
BenchmarkPrecompiledModExp/nagydani-2-qube-Gas=133-8       	 1000000	      6550 ns/op
BenchmarkPrecompiledModExp/nagydani-2-pow0x10001-Gas=2129-8         	  200000	     31756 ns/op
BenchmarkPrecompiledModExp/nagydani-3-square-Gas=378-8              	 1000000	      8166 ns/op
BenchmarkPrecompiledModExp/nagydani-3-qube-Gas=378-8                	  500000	     15420 ns/op
BenchmarkPrecompiledModExp/nagydani-3-pow0x10001-Gas=6062-8         	  100000	     91049 ns/op
BenchmarkPrecompiledModExp/nagydani-4-square-Gas=1116-8             	  300000	     22666 ns/op
BenchmarkPrecompiledModExp/nagydani-4-qube-Gas=1116-8               	  200000	     48616 ns/op
BenchmarkPrecompiledModExp/nagydani-4-pow0x10001-Gas=17858-8        	   20000	    334805 ns/op
BenchmarkPrecompiledModExp/nagydani-5-square-Gas=3573-8             	  100000	     72269 ns/op
BenchmarkPrecompiledModExp/nagydani-5-qube-Gas=3573-8               	   50000	    122522 ns/op
BenchmarkPrecompiledModExp/nagydani-5-pow0x10001-Gas=57180-8        	   10000	    791423 ns/op
BenchmarkPrecompiledBn256Add/chfast1-Gas=500-8                      	  200000	     65233 ns/op
BenchmarkPrecompiledBn256Add/chfast2-Gas=500-8                      	  100000	     60019 ns/op
BenchmarkPrecompiledBn256Add/cdetrio1-Gas=500-8                     	 5000000	      1579 ns/op
BenchmarkPrecompiledBn256Add/cdetrio2-Gas=500-8                     	 5000000	      1565 ns/op
BenchmarkPrecompiledBn256Add/cdetrio3-Gas=500-8                     	 5000000	      1545 ns/op
BenchmarkPrecompiledBn256Add/cdetrio4-Gas=500-8                     	 5000000	      1523 ns/op
BenchmarkPrecompiledBn256Add/cdetrio5-Gas=500-8                     	 5000000	      1463 ns/op
BenchmarkPrecompiledBn256Add/cdetrio6-Gas=500-8                     	 5000000	      1552 ns/op
BenchmarkPrecompiledBn256Add/cdetrio7-Gas=500-8                     	 5000000	      1580 ns/op
BenchmarkPrecompiledBn256Add/cdetrio8-Gas=500-8                     	 5000000	      1623 ns/op
BenchmarkPrecompiledBn256Add/cdetrio9-Gas=500-8                     	 5000000	      1565 ns/op
BenchmarkPrecompiledBn256Add/cdetrio10-Gas=500-8                    	 5000000	      1634 ns/op
BenchmarkPrecompiledBn256Add/cdetrio11-Gas=500-8                    	 1000000	      7005 ns/op
BenchmarkPrecompiledBn256Add/cdetrio12-Gas=500-8                    	 1000000	      7139 ns/op
BenchmarkPrecompiledBn256Add/cdetrio13-Gas=500-8                    	  200000	     46273 ns/op
BenchmarkPrecompiledBn256Add/cdetrio14-Gas=500-8                    	 1000000	      6717 ns/op
BenchmarkPrecompiledBn256ScalarMul/chfast1-Gas=2000-8               	   20000	    479836 ns/op
BenchmarkPrecompiledBn256ScalarMul/chfast2-Gas=2000-8               	    3000	   1891149 ns/op
BenchmarkPrecompiledBn256ScalarMul/chfast3-Gas=2000-8               	    5000	   1839665 ns/op
BenchmarkPrecompiledBn256Pairing/jeff1-Gas=260000-8                 	     500	  19712015 ns/op
BenchmarkPrecompiledBn256Pairing/jeff2-Gas=260000-8                 	     300	  19661290 ns/op
BenchmarkPrecompiledBn256Pairing/jeff3-Gas=260000-8                 	     300	  19946803 ns/op
BenchmarkPrecompiledBn256Pairing/jeff4-Gas=340000-8                 	     300	  25342430 ns/op
BenchmarkPrecompiledBn256Pairing/jeff5-Gas=340000-8                 	     300	  24692591 ns/op
BenchmarkPrecompiledBn256Pairing/jeff6-Gas=260000-8                 	     500	  19853770 ns/op
BenchmarkPrecompiledBn256Pairing/empty_data-Gas=100000-8            	    5000	   1637240 ns/op
BenchmarkPrecompiledBn256Pairing/one_point-Gas=180000-8             	     500	  14025579 ns/op
BenchmarkPrecompiledBn256Pairing/two_point_match_2-Gas=260000-8     	    1000	  11552115 ns/op
BenchmarkPrecompiledBn256Pairing/two_point_match_3-Gas=260000-8     	     500	  19220277 ns/op
BenchmarkPrecompiledBn256Pairing/two_point_match_4-Gas=260000-8     	     300	  19088014 ns/op
BenchmarkPrecompiledBn256Pairing/ten_point_match_1-Gas=900000-8     	     200	  51894330 ns/op
BenchmarkPrecompiledBn256Pairing/ten_point_match_2-Gas=900000-8     	     100	  61992980 ns/op
BenchmarkPrecompiledBn256Pairing/ten_point_match_3-Gas=260000-8     	     500	  19563190 ns/op
PASS
ok  	_/Users/tim.siwula/Dropbox/Projects/go-ethereum/core/vm	508.788s

@holiman
Copy link

holiman commented Aug 21, 2017

Ok, post-processed:

Name                                         Gascost         Time (ns)      MGas/S    Gasprice for 10MGas/S  Gas/Ideal percent
-----------------------------------------  ---------  ----------------  ----------  -----------------------  -------------------
PrecompiledEcrecover/                           3000  185022              16.2143                   1850.22  162.1 %
PrecompiledSha256/128                            108     728             148.352                       7.28  1483.5 %
PrecompiledRipeMD/128                           1080    2116             510.397                      21.16  5104.0 %
PrecompiledIdentity/128                           27      20            1350                           0.2   13500.0 %
PrecompiledModExp/eip_example1                  2611   37256              70.0827                    372.56  700.8 %
PrecompiledModExp/eip_example2                  2611    8308             314.275                      83.08  3142.8 %
PrecompiledModExp/nagydani-1-square               40    3183              12.5668                     31.83  125.7 %
PrecompiledModExp/nagydani-1-qube                 40    3844              10.4058                     38.44  104.1 %
PrecompiledModExp/nagydani-1-pow0x10001          655   15398              42.538                     153.98  425.4 %
PrecompiledModExp/nagydani-2-square              133    4800              27.7083                     48     277.1 %
PrecompiledModExp/nagydani-2-qube                133    6550              20.3053                     65.5   203.1 %
PrecompiledModExp/nagydani-2-pow0x10001         2129   31756              67.0424                    317.56  670.4 %
PrecompiledModExp/nagydani-3-square              378    8166              46.2895                     81.66  462.9 %
PrecompiledModExp/nagydani-3-qube                378   15420              24.5136                    154.2   245.1 %
PrecompiledModExp/nagydani-3-pow0x10001         6062   91049              66.5795                    910.49  665.8 %
PrecompiledModExp/nagydani-4-square             1116   22666              49.2367                    226.66  492.4 %
PrecompiledModExp/nagydani-4-qube               1116   48616              22.9554                    486.16  229.6 %
PrecompiledModExp/nagydani-4-pow0x10001        17858  334805              53.3385                   3348.05  533.4 %
PrecompiledModExp/nagydani-5-square             3573   72269              49.4403                    722.69  494.4 %
PrecompiledModExp/nagydani-5-qube               3573  122522              29.1621                   1225.22  291.6 %
PrecompiledModExp/nagydani-5-pow0x10001        57180  791423              72.2496                   7914.23  722.5 %
PrecompiledBn256Add/chfast1                      500   65233               7.66483                   652.33  76.6 %
PrecompiledBn256Add/chfast2                      500   60019               8.3307                    600.19  83.3 %
PrecompiledBn256Add/cdetrio1                     500    1579             316.656                      15.79  3166.6 %
PrecompiledBn256Add/cdetrio2                     500    1565             319.489                      15.65  3194.9 %
PrecompiledBn256Add/cdetrio3                     500    1545             323.625                      15.45  3236.2 %
PrecompiledBn256Add/cdetrio4                     500    1523             328.299                      15.23  3283.0 %
PrecompiledBn256Add/cdetrio5                     500    1463             341.763                      14.63  3417.6 %
PrecompiledBn256Add/cdetrio6                     500    1552             322.165                      15.52  3221.6 %
PrecompiledBn256Add/cdetrio7                     500    1580             316.456                      15.8   3164.6 %
PrecompiledBn256Add/cdetrio8                     500    1623             308.071                      16.23  3080.7 %
PrecompiledBn256Add/cdetrio9                     500    1565             319.489                      15.65  3194.9 %
PrecompiledBn256Add/cdetrio10                    500    1634             305.998                      16.34  3060.0 %
PrecompiledBn256Add/cdetrio11                    500    7005              71.3776                     70.05  713.8 %
PrecompiledBn256Add/cdetrio12                    500    7139              70.0378                     71.39  700.4 %
PrecompiledBn256Add/cdetrio13                    500   46273              10.8054                    462.73  108.1 %
PrecompiledBn256Add/cdetrio14                    500    6717              74.438                      67.17  744.4 %
PrecompiledBn256ScalarMul/chfast1               2000  479836               4.16809                  4798.36  41.7 %
PrecompiledBn256ScalarMul/chfast2               2000       1.89115e+06     1.05756                 18911.5   10.6 %
PrecompiledBn256ScalarMul/chfast3               2000       1.83966e+06     1.08715                 18396.7   10.9 %
PrecompiledBn256Pairing/jeff1                 260000       1.9712e+07     13.1899                 197120     131.9 %
PrecompiledBn256Pairing/jeff2                 260000       1.96613e+07    13.224                  196613     132.2 %
PrecompiledBn256Pairing/jeff3                 260000       1.99468e+07    13.0347                 199468     130.3 %
PrecompiledBn256Pairing/jeff4                 340000       2.53424e+07    13.4162                 253424     134.2 %
PrecompiledBn256Pairing/jeff5                 340000       2.46926e+07    13.7693                 246926     137.7 %
PrecompiledBn256Pairing/jeff6                 260000       1.98538e+07    13.0957                 198538     131.0 %
PrecompiledBn256Pairing/empty_data            100000       1.63724e+06    61.0784                  16372.4   610.8 %
PrecompiledBn256Pairing/one_point             180000       1.40256e+07    12.8337                 140256     128.3 %
PrecompiledBn256Pairing/two_point_match_2     260000       1.15521e+07    22.5067                 115521     225.1 %
PrecompiledBn256Pairing/two_point_match_3     260000       1.92203e+07    13.5274                 192203     135.3 %
PrecompiledBn256Pairing/two_point_match_4     260000       1.9088e+07     13.6211                 190880     136.2 %
PrecompiledBn256Pairing/ten_point_match_1     900000       5.18943e+07    17.3429                 518943     173.4 %
PrecompiledBn256Pairing/ten_point_match_2     900000       6.1993e+07     14.5178                 619930     145.2 %
PrecompiledBn256Pairing/ten_point_match_3     260000       1.95632e+07    13.2903                 195632     132.9 %

@holiman
Copy link

holiman commented Aug 21, 2017

Here are your worst-cases

Name                                         Gascost         Time (ns)      MGas/S    Gasprice for 10MGas/S  Gas/Ideal percent
-----------------------------------------  ---------  ----------------  ----------  -----------------------  -------------------
PrecompiledEcrecover/                           3000  185022              16.2143                   1850.22  162.1 %
PrecompiledSha256/128                            108     728             148.352                       7.28  1483.5 %
PrecompiledRipeMD/128                           1080    2116             510.397                      21.16  5104.0 %
PrecompiledIdentity/128                           27      20            1350                           0.2   13500.0 %
PrecompiledModExp/nagydani-1-qube                 40    3844              10.4058                     38.44  104.1 %
PrecompiledBn256Add/chfast1                      500   65233               7.66483                   652.33  76.6 %
PrecompiledBn256ScalarMul/chfast2               2000       1.89115e+06     1.05756                 18911.5   10.6 %
PrecompiledBn256Pairing/one_point             180000       1.40256e+07    12.8337                 140256     128.3 %

@holiman
Copy link

holiman commented Aug 21, 2017

So your data points to

  • Modexp is pretty right
  • Add should be ~650
  • Scalar mul should ~20K

If they we want them to be in line with ecdsa, they should be multiplied by a factor of ~ 1.6.

@timxor
Copy link
Author

timxor commented Aug 23, 2017

@holiman any idea, why not all of them are running?

➜  go-ethereum git:(master) git rev-parse HEAD
8d6a5a3581ce6221786eb464bfef7e8c31e7ad95
➜  go-ethereum git:(master) cd core/vm
➜  vm git:(master) go test -bench BenchmarkPrecompiled -benchtime 5s
BenchmarkPrecompiledEcdsa-8      	   50000	    153764 ns/op
BenchmarkPrecompiledSha256-8     	^[^[^C%                                                                                                                                                                                               ➜  vm git:(master) go test -bench BenchmarkPrecompiled -benchtime 5s
BenchmarkPrecompiledEcdsa-8      	   50000	    159277 ns/op
BenchmarkPrecompiledSha256-8     	10000000	       637 ns/op
BenchmarkPrecompiledRipeMD-8     	 3000000	      1982 ns/op
BenchmarkPrecompiledIdentity-8   	500000000	        16.3 ns/op
PASS
ok  	github.com/ethereum/go-ethereum/core/vm	34.428s
➜  vm git:(master) git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working tree clean
➜  vm git:(master) go test -bench BenchmarkPrecompiled -benchtime 5s
BenchmarkPrecompiledEcdsa-8      	   50000	    142948 ns/op
BenchmarkPrecompiledSha256-8     	20000000	       605 ns/op
BenchmarkPrecompiledRipeMD-8     	 5000000	      1806 ns/op
BenchmarkPrecompiledIdentity-8   	500000000	        15.3 ns/op
PASS
ok  	github.com/ethereum/go-ethereum/core/vm	41.468s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment