[Ur] little benchmark on querying a table only

Adam Chlipala adamc at impredicative.com
Mon Dec 20 09:42:54 EST 2010


Marc Weber wrote:
> urweb (http):
>
>    benchmark PHP (run by apache) (5.3):
>      ab -n 100 -c1 http://l/pg_speed.php  0.01s user 0.03s system 3% cpu 1.242 total
>
>    benchmark ur (http):
>      ab -n 100 -c1 http://l:8090/St/list  0.01s user 0.02s system 1% cpu 2.147 total
>
>    benchmark ur (fastcgi):
>      ab -n 100 -c1 http://l/fcgid/pg_fcgi.fcgi/St/list  0.01s user 0.02s system 1% cpu 2.522 total
>
>    -c1 means no threading.
>    data: 1000 rows
>    

Once I explain what was happening here, you will probably agree that 
these numbers reflect very favorably on Ur/Web.  A certain key 
optimization was being omitted, yet Ur/Web still came within about a 
factor of 2 of PHP. ;-D

The comparison was kind of unfair to begin with, as you used a function 
[page] in Ur/Web to implement a standard page template, while you 
inlined all HTML in the PHP version.  If you had done that inlining 
manually in Ur/Web, too, you would have seen very different results.

The compiler is designed to figure out where such inlining is profitable 
and do it automatically.  This is based on a threshold on the size of 
the function to inline.  I had the threshold set too conservatively, so 
[page] calls weren't being inlined.  I've now pushed a tiny compiler 
change which increases the threshold modestly, which is enough to get 
this example to compile properly.

Your benchmarks seem to be single-threaded.  In that setting, I observe 
about a factor of 7 throughput improvement after the compiler change.

It would also be interesting to see some concurrent benchmarks.  You 
would want to start the Ur/Web server binary with the command-line 
argument '-t N', where 'N' is twice your number of cores.  You'd also 
obviously need to tweak the 'ab' command line.  With 4 threads on my 
old-ish 2-core machine, I observe about a factor of 10 throughput 
improvement after the compiler change.

It's also worth pointing out that you can often speed up the Ur/Web 
server processes significantly by piping their stdouts to /dev/null.



More information about the Ur mailing list