PoW performance

Posted September 1, 2021 by Aravinth Manivannan ‐ 2 min read

Last Edited September 1, 2021

We are mCaptcha. We build kickass CAPTCHA systems that give (DDoS) attackers a run for their money. And we do all of this without tracking your users. Oh and did I mention our UX is great?

mCaptcha uses a proof-of-work(PoW) mechanism to rate limit users or potential bots. In order for this to be effective, the PoW should be configured properly. The difficulty requirement can’t be too high, as it could cause accessibility issues on the client-side while at the same time, it shouldn’t be too low, as it wouldn’t offer proper protection against bots.

Malicious bots(the ones that wreak havoc), run native code which is capable of running in a multi-threaded context. This creates an unfair advantage for crackers using these bots over legitimate users, who usually use browsers to access a website.

I wanted to see how much of an advantage a native program would have over our WASM library.

Benchmark tools

So I wrote these to compare native and WASM performances:

Results

The tests were run on my development machine featuring an Intel Core i7-9750h.

Native

DifficultyRealUserSys
5000000m0.220s0m0.197s0m0.006s
10000000m0.203s0m0.203s0m0.000s
15000000m0.198s0m0.198s0m0.000s
20000000m0.203s0m0.203s0m0.000s
25000000m0.758s0m0.752s0m0.003s
30000000m0.776s0m0.769s0m0.003s
35000000m2.010s0m1.998s0m0.000s
40000000m2.038s0m2.033s0m0.003s
45000000m2.014s0m2.013s0m0.000s

Browser

I ran the tests on both Firefox and Chromium to compare results

Firefox

  • User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0
  • Hardware concurrency: 12
DifficultyDuration(in ms)
500000401
1000000413
1500000398
2000000394
25000001495
30000001556
35000003971
40000004235
45000004116

To be fair, my Firefox installation is loaded with a gazillion extensions while the Chromium instance is clean, as I don’t use it much

Chromium

  • User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36
  • Hardware concurrency: 12
DifficultyDuration(in ms)
500000399.40000000037253
1000000354.6000000014901
1500000351.19999999925494
2000000353.80000000074506
25000001337.800000000745
30000001311.199999999255
35000003417.5999999996275
40000003488.800000000745
45000003458.2999999988824

Conclusion

At the highest difficulty factor, the native implementation was a almost second faster than the WASM library. But the fact that both of them were able to run to completion in under 5 seconds is impressive!

So, in my opinion, native implementation is only slightly faster than the WASM library and for all intents and purposes, this shouldn’t matter much.


P.S Work is underway to benchmark multiple platforms. A detailed report will be published when that data is available.

For this post, I asked some of my friends to run the tests on their computers. The results slightly varied but even the slowest case generated proof for 4500000 difficulty(the highest in this test), in under 15 seconds!

Edit this page on GitHub