forked from mCaptcha/website
414 lines
15 KiB
HTML
414 lines
15 KiB
HTML
|
<!doctype html>
|
||
|
<html lang="en-US">
|
||
|
<head>
|
||
|
<meta charset="utf-8">
|
||
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||
|
<link rel="preload" as="font" href="/fonts/vendor/jost/jost-v4-latin-regular.woff2" type="font/woff2" crossorigin>
|
||
|
<link rel="preload" as="font" href="/fonts/vendor/jost/jost-v4-latin-700.woff2" type="font/woff2" crossorigin>
|
||
|
<link rel="stylesheet" href="/main.4492eacff4110697cd6162326bce4ee59e92315bf9acc357594066968669326dc80b75b1a39e6cea81c4f8898bd1d294fcc657a9cb61baed14c7dee6f9e2b2d6.css" integrity="sha512-RJLqz/QRBpfNYWIya85O5Z6SMVv5rMNXWUBmloZpMm3IC3Wxo55s6oHE+ImL0dKU/MZXqcthuu0Ux97m+eKy1g==" crossorigin="anonymous">
|
||
|
<noscript><style>img.lazyload { display: none; }</style></noscript>
|
||
|
<meta name="robots" content="index, follow">
|
||
|
<meta name="googlebot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1">
|
||
|
<meta name="bingbot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1">
|
||
|
<title>PoW performance - mCaptcha</title>
|
||
|
<meta name="description" content="PoW performance of native and WASM implementations. Does the native implementation have and edge over the WASM library?">
|
||
|
<link rel="canonical" href="/blog/pow-performance/">
|
||
|
<meta name="twitter:card" content="summary_large_image">
|
||
|
<meta name="twitter:image" content="/blog/pow-performance/icon.png">
|
||
|
<meta name="twitter:title" content="PoW performance">
|
||
|
<meta name="twitter:description" content="PoW performance of native and WASM implementations. Does the native implementation have and edge over the WASM library?">
|
||
|
|
||
|
<meta name="twitter:site" content="@">
|
||
|
<meta name="twitter:creator" content="@">
|
||
|
|
||
|
<meta property="og:title" content="PoW performance">
|
||
|
<meta property="og:description" content="PoW performance of native and WASM implementations. Does the native implementation have and edge over the WASM library?">
|
||
|
<meta property="og:type" content="article">
|
||
|
<meta property="og:url" content="/blog/pow-performance/">
|
||
|
<meta property="og:image" content="/blog/pow-performance/icon.png">
|
||
|
<meta property="article:published_time" content="2021-09-01T00:00:00+00:00">
|
||
|
<meta property="article:modified_time" content="2023-02-13T18:00:02+05:30">
|
||
|
<meta property="og:site_name" content="mCaptcha">
|
||
|
|
||
|
<meta property="article:publisher" content="https://www.facebook.com/">
|
||
|
<meta property="article:author" content="https://www.facebook.com/">
|
||
|
<meta property="og:locale" content="en_US">
|
||
|
|
||
|
<script type="application/ld+json">
|
||
|
{
|
||
|
"@context": "http://schema.org",
|
||
|
"@type": "BreadcrumbList",
|
||
|
"itemListElement": [{
|
||
|
"@type": "ListItem",
|
||
|
"position": 1 ,
|
||
|
"name": "Home",
|
||
|
"item": "\/"
|
||
|
},{
|
||
|
"@type": "ListItem",
|
||
|
"position": 2 ,
|
||
|
"name": "Blogpow Performance",
|
||
|
"item": "\/blogpow-performance\/"
|
||
|
}]
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<meta name="theme-color" content="#fff">
|
||
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||
|
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||
|
<link rel="manifest" href="/site.webmanifest">
|
||
|
|
||
|
</head>
|
||
|
<body class="blog single">
|
||
|
|
||
|
|
||
|
<div class="header-bar fixed-top"></div>
|
||
|
<header class="navbar fixed-top navbar-expand-md navbar-light">
|
||
|
<div class="container">
|
||
|
<input class="menu-btn order-0" type="checkbox" id="menu-btn">
|
||
|
<label class="menu-icon d-md-none" for="menu-btn"><span class="navicon"></span></label>
|
||
|
<a class="navbar-brand order-1 order-md-0 me-auto" href="/">mCaptcha</a>
|
||
|
<button id="mode" class="btn btn-link order-2 order-md-4" type="button" aria-label="Toggle mode">
|
||
|
<span class="toggle-dark"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-moon"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg></span>
|
||
|
<span class="toggle-light"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-sun"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg></span>
|
||
|
</button>
|
||
|
<ul class="navbar-nav social-nav order-3 order-md-5">
|
||
|
<li class="nav-item">
|
||
|
<a class="nav-link" href="https://github.com/mCaptcha"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-github"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"></path></svg><span class="ms-2 visually-hidden">GitHub</span></a>
|
||
|
</li>
|
||
|
</ul>
|
||
|
<div class="collapse navbar-collapse order-4 order-md-1">
|
||
|
<ul class="navbar-nav main-nav me-auto order-5 order-md-2"><li class="nav-item active">
|
||
|
<a class="nav-link" href="/blog/">Blog</a>
|
||
|
</li>
|
||
|
<li class="nav-item">
|
||
|
<a class="nav-link" href="/community/">Community</a>
|
||
|
</li>
|
||
|
<li class="nav-item">
|
||
|
<a class="nav-link" href="/contact/">Contact</a>
|
||
|
</li>
|
||
|
<li class="nav-item">
|
||
|
<a class="nav-link" href="/about/">About</a>
|
||
|
</li>
|
||
|
<li class="nav-item">
|
||
|
<a class="nav-link" href="/docs/introduction/installing-captcha/">Docs</a>
|
||
|
</li>
|
||
|
</ul>
|
||
|
<div class="break order-6 d-md-none"></div>
|
||
|
<form class="navbar-form flex-grow-1 order-7 order-md-3">
|
||
|
<input id="userinput" class="form-control is-search" type="search" placeholder="Search docs..." aria-label="Search docs..." autocomplete="off">
|
||
|
<div id="suggestions" class="shadow bg-white rounded"></div>
|
||
|
</form>
|
||
|
</div>
|
||
|
</div>
|
||
|
</header>
|
||
|
|
||
|
<div class="wrap container" role="document">
|
||
|
<div class="content">
|
||
|
|
||
|
<div class="row flex-xl-nowrap">
|
||
|
<nav class="docs-toc d-none d-xl-block col-xl-3" aria-label="Secondary navigation">
|
||
|
<div class="page-links">
|
||
|
<h3>On this page</h3>
|
||
|
<nav id="TableOfContents">
|
||
|
<ul>
|
||
|
<li><a href="#benchmark-tools">Benchmark tools</a></li>
|
||
|
<li><a href="#results">Results</a>
|
||
|
<ul>
|
||
|
<li><a href="#native">Native</a></li>
|
||
|
<li><a href="#browser">Browser</a></li>
|
||
|
<li><a href="#firefox">Firefox</a></li>
|
||
|
</ul>
|
||
|
</li>
|
||
|
<li><a href="#conclusion">Conclusion</a></li>
|
||
|
</ul>
|
||
|
</nav>
|
||
|
</div>
|
||
|
|
||
|
</nav>
|
||
|
<main class="docs-content col-lg-11 col-xl-9 mx-xl-auto">
|
||
|
|
||
|
<article>
|
||
|
<div class="blog-header">
|
||
|
<h1>PoW performance</h1>
|
||
|
<p><small>Posted September 1, 2021 by <a class="stretched-link position-relative" href="/contributors/aravinth-manivannan/">Aravinth Manivannan</a> ‐ <strong>2 min read</strong></small><p>
|
||
|
<p><small>Last Edited February 13, 2023</small><p>
|
||
|
|
||
|
</div>
|
||
|
<p class="lead">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?</p>
|
||
|
<p>mCaptcha uses a
|
||
|
<a href="https://en.wikipedia.org/wiki/Proof_of_work">proof-of-work(PoW)</a> 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.</p>
|
||
|
<p>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.</p>
|
||
|
<p>I wanted to see how much of an advantage a native program would have
|
||
|
over our WASM library.</p>
|
||
|
<h2 id="benchmark-tools">Benchmark tools</h2>
|
||
|
<p>So I wrote these to compare native and WASM performances:</p>
|
||
|
<ul>
|
||
|
<li>Browser benchmark: <a href="https://mCaptcha.github.io/benches">https://mCaptcha.github.io/benches</a></li>
|
||
|
<li>Native benchmark: <a href="https://github.com/mCaptcha/cli/blob/master/scripts/bench.sh">mCaptcha/cli managed by scripts/bench.sh</a></li>
|
||
|
</ul>
|
||
|
<div class="alert alert-warning d-flex" role="alert">
|
||
|
<div class="flex-shrink-1 alert-icon">⭐</div>
|
||
|
<div class="w-100">Feel free to reproduce the results!</div>
|
||
|
</div>
|
||
|
<h2 id="results">Results</h2>
|
||
|
<p>The tests were run on my development machine featuring an Intel Core
|
||
|
i7-9750h.</p>
|
||
|
<h3 id="native">Native</h3>
|
||
|
<table>
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th>Difficulty</th>
|
||
|
<th>Real</th>
|
||
|
<th>User</th>
|
||
|
<th>Sys</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td>500000</td>
|
||
|
<td>0m0.220s</td>
|
||
|
<td>0m0.197s</td>
|
||
|
<td>0m0.006s</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>1000000</td>
|
||
|
<td>0m0.203s</td>
|
||
|
<td>0m0.203s</td>
|
||
|
<td>0m0.000s</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>1500000</td>
|
||
|
<td>0m0.198s</td>
|
||
|
<td>0m0.198s</td>
|
||
|
<td>0m0.000s</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>2000000</td>
|
||
|
<td>0m0.203s</td>
|
||
|
<td>0m0.203s</td>
|
||
|
<td>0m0.000s</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>2500000</td>
|
||
|
<td>0m0.758s</td>
|
||
|
<td>0m0.752s</td>
|
||
|
<td>0m0.003s</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>3000000</td>
|
||
|
<td>0m0.776s</td>
|
||
|
<td>0m0.769s</td>
|
||
|
<td>0m0.003s</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>3500000</td>
|
||
|
<td>0m2.010s</td>
|
||
|
<td>0m1.998s</td>
|
||
|
<td>0m0.000s</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>4000000</td>
|
||
|
<td>0m2.038s</td>
|
||
|
<td>0m2.033s</td>
|
||
|
<td>0m0.003s</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>4500000</td>
|
||
|
<td>0m2.014s</td>
|
||
|
<td>0m2.013s</td>
|
||
|
<td>0m0.000s</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<h3 id="browser">Browser</h3>
|
||
|
<p>I ran the tests on both Firefox and Chromium to compare results</p>
|
||
|
<h3 id="firefox">Firefox</h3>
|
||
|
<ul>
|
||
|
<li><strong>User Agent:</strong> <code>Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0</code></li>
|
||
|
<li><strong>Hardware concurrency:</strong> 12</li>
|
||
|
</ul>
|
||
|
<table>
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th>Difficulty</th>
|
||
|
<th>Duration(in ms)</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td>500000</td>
|
||
|
<td>401</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>1000000</td>
|
||
|
<td>413</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>1500000</td>
|
||
|
<td>398</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>2000000</td>
|
||
|
<td>394</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>2500000</td>
|
||
|
<td>1495</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>3000000</td>
|
||
|
<td>1556</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>3500000</td>
|
||
|
<td>3971</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>4000000</td>
|
||
|
<td>4235</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>4500000</td>
|
||
|
<td>4116</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<blockquote>
|
||
|
<p>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</p>
|
||
|
</blockquote>
|
||
|
<h4 id="chromium">Chromium</h4>
|
||
|
<ul>
|
||
|
<li><strong>User Agent:</strong> <code>Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36</code></li>
|
||
|
<li><strong>Hardware concurrency:</strong> 12</li>
|
||
|
</ul>
|
||
|
<table>
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th>Difficulty</th>
|
||
|
<th>Duration(in ms)</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td>500000</td>
|
||
|
<td>399.40000000037253</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>1000000</td>
|
||
|
<td>354.6000000014901</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>1500000</td>
|
||
|
<td>351.19999999925494</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>2000000</td>
|
||
|
<td>353.80000000074506</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>2500000</td>
|
||
|
<td>1337.800000000745</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>3000000</td>
|
||
|
<td>1311.199999999255</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>3500000</td>
|
||
|
<td>3417.5999999996275</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>4000000</td>
|
||
|
<td>3488.800000000745</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>4500000</td>
|
||
|
<td>3458.2999999988824</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<h2 id="conclusion">Conclusion</h2>
|
||
|
<p>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!</p>
|
||
|
<p>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>
|
||
|
<hr>
|
||
|
<p>P.S Work is underway to benchmark multiple platforms. A detailed report
|
||
|
will be published when that data is available.</p>
|
||
|
<p>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!</p>
|
||
|
|
||
|
</article>
|
||
|
<div class="docs-navigation d-flex justify-content-between">
|
||
|
|
||
|
<a href="/blog/survey/">
|
||
|
<div class="card my-1">
|
||
|
<div class="card-body py-2">
|
||
|
← Survey
|
||
|
</div>
|
||
|
</div>
|
||
|
</a>
|
||
|
<a class="ms-auto" href="/blog/say-hello-to-mcaptcha/">
|
||
|
<div class="card my-1">
|
||
|
<div class="card-body py-2">
|
||
|
Say hello to mCaptcha →
|
||
|
</div>
|
||
|
</div>
|
||
|
</a>
|
||
|
</div>
|
||
|
|
||
|
<p class="edit-page"><a href="https://github.com/mCaptcha/website/blob/master/content/blog/pow-performance/index.md"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-2"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path></svg>Edit this page on GitHub</a></p>
|
||
|
|
||
|
</main>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<footer class="footer text-muted">
|
||
|
<div class="container">
|
||
|
<div class="row">
|
||
|
<div class="col-lg-8 order-last order-lg-first">
|
||
|
<ul class="list-inline">
|
||
|
<li class="list-inline-item">Powered by <a href="https://gohugo.io/">Hugo</a>, and <a href="https://getdoks.org/">Doks</a></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<div class="col-lg-8 order-first order-lg-last text-lg-end">
|
||
|
<ul class="list-inline">
|
||
|
<li class="list-inline-item"><a href="/about/">About</a></li>
|
||
|
<li class="list-inline-item"><a href="/donate">Donate</a></li>
|
||
|
<li class="list-inline-item"><a href="/privacy-policy/">Privacy</a></li>
|
||
|
<li class="list-inline-item"><a href="/security">Security</a></li>
|
||
|
<li class="list-inline-item"><a href="https://stats.uptimerobot.com/GK7VLFJnBl">Status</a></li>
|
||
|
<li class="list-inline-item"><a href="/support/">Support</a></li>
|
||
|
<li class="list-inline-item"><a href="/thanks">Thanks</a></li>
|
||
|
<li class="list-inline-item"><a href="/tos">ToS</a></li>
|
||
|
</ul>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</footer>
|
||
|
|
||
|
<script src="/main.min.fc14a6a9dceb7093b6984e33583a45c79e3c960959d75df6b62753b4d1c63a97d25af2b0ca924ed12675f1de34f3fce9ec81668f2d3bee114b9b6357dd2e92cd.js" integrity="sha512-/BSmqdzrcJO2mE4zWDpFx548lglZ1132tidTtNHGOpfSWvKwypJO0SZ18d408/zp7IFmjy077hFLm2NX3S6SzQ==" crossorigin="anonymous" defer></script>
|
||
|
<script src="/index.min.f24b6e33dac74771476dda67fe905af998983abef17f74f74d71228ac8f40f87af8b15bcd9f0da775c90a41395c3d153fb0067cc75ff642c520b3607340014c0.js" integrity="sha512-8ktuM9rHR3FHbdpn/pBa+ZiYOr7xf3T3TXEiisj0D4evixW82fDad1yQpBOVw9FT+wBnzHX/ZCxSCzYHNAAUwA==" crossorigin="anonymous" defer></script>
|
||
|
|
||
|
</body>
|
||
|
</html>
|