Monday, August 17, 2009

A quick look at the Tokyo Tyrant extension for PHP

Here's a quick, rough look at the speed of the Tokyo Tyrant extension for PHP released by Mikko 2 days ago. I am using it as an on-memory hash. Profiling done with xdebug on PHP 5.3.0:

Here's the collateral userspace costs of an alternative PHP implementation by Bertrand Mansion (dependent on the sockets extension to PHP):


  1. Very interesting, thanks :)

    In my own tests, get() is more than 2 times faster with the extension. put() is ok. You should post the code you used. I have tried to optimize my code as much as I could but the extension cannot be beaten :) Unfortunately, I have had socket problems with the extension (alpha version) when inserting a lot of data in a table database.

    By the way, what did you use to generate the graphs ?

  2. The code is just a simple loop that does put() 100000 times and get() likewise using the extension and the PHP implementation, ran separately. The only difference is how the tt object is instantiated, i.e.:

    $tt = new TokyoTyrant("localhost", 1978); // use extension


    $tt = Tyrant::connect('localhost', 1978); //use PHP implementation

    The graphs are generated from cachegrind files using xdebugtoolkit.