Upgrade to Pro — share decks privately, control downloads, hide ads and more …

As fast as C?

As fast as C?

Talk given at the London Node.js User Group.

Felix Geisendörfer

June 27, 2012
Tweet

More Decks by Felix Geisendörfer

Other Decks in Programming

Transcript

  1. As fast as C?
    Writing high performance stream parsers in JS.
    Felix Geisendörfer June 27, 2012 - London Node.js User Group

    View full-size slide

  2. Thanks Forward!

    View full-size slide

  3. Felix Geisendörfer

    View full-size slide

  4. (@)felixge(.de)

    View full-size slide

  5. core contributor

    View full-size slide

  6. transloadit.com

    View full-size slide

  7. ~50 npm modules

    View full-size slide

  8. node-formidable

    View full-size slide

  9. Parser Geeks?

    View full-size slide

  10. As fast as C?

    View full-size slide

  11. Dubious Benchmarks Ahead!

    View full-size slide

  12. Selecting 100k blog
    post rows

    View full-size slide

  13. 0
    15000
    30000
    45000
    60000
    node-mysql-0.9.6 node-mysql-libmysqlclient-1.3.3 node-mysql-2.0.0-alpha3
    53966
    36429
    20968
    Rows per Second
    node-mysql-0.9.6 node-mysql-libmysqlclient-1.3.3
    node-mysql-2.0.0-alpha3
    https://github.com/felixge/mysql-client-benchmarks

    View full-size slide

  14. 0
    17500
    35000
    52500
    70000
    node-mysql-0.9.6 node-mysql-libmysqlclient-1.3.3 node-mysql-2.0.0-alpha3 php-mysqlnd-5.13
    68097
    53966
    36429
    20968
    Rows per Second
    node-mysql-0.9.6 node-mysql-libmysqlclient-1.3.3
    node-mysql-2.0.0-alpha3 php-mysqlnd-5.13
    https://github.com/felixge/mysql-client-benchmarks

    View full-size slide

  15. Pure node.js parsers
    can compete with
    C Addons

    View full-size slide

  16. Lessons Learned

    View full-size slide

  17. Benchmark First

    View full-size slide

  18. Buffering can be good!

    View full-size slide

  19. They’re hiring!
    @dan_jenkins

    View full-size slide

  20. Also hiring!

    View full-size slide

  21. Questions?

    http://felixge.de/
    [email protected]
    @felixge

    View full-size slide

  22. ------------------------------4a62195680a6
    Content-Disposition: form-data; name="upload1"; filename="file1.txt"
    Content-Type: text/plain
    file 1 data ...
    ------------------------------4a62195680a6
    Content-Disposition: form-data; name="upload2"; filename="file2.txt"
    Content-Type: text/plain
    file 2 data ...
    ------------------------------4a62195680a6--
    Example: Multipart (File Uploads)

    View full-size slide

  23. Lots and lots of file data ...
    ------------------------------4a62195680a6
    Naive Boundary Search: One byte at a time

    View full-size slide