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 Slide

  2. Thanks Forward!

    View Slide

  3. Felix Geisendörfer

    View Slide

  4. (@)felixge(.de)

    View Slide

  5. core contributor

    View Slide

  6. transloadit.com

    View Slide

  7. ~50 npm modules

    View Slide

  8. node-formidable

    View Slide

  9. node-mysql

    View Slide

  10. Parser Geeks?

    View Slide

  11. As fast as C?

    View Slide

  12. Dubious Benchmarks Ahead!

    View Slide

  13. Selecting 100k blog
    post rows

    View Slide

  14. View Slide

  15. View Slide

  16. 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 Slide

  17. 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 Slide

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

    View Slide

  19. Lessons Learned

    View Slide

  20. Practice

    View Slide

  21. Benchmark First

    View Slide

  22. Buffering can be good!

    View Slide

  23. Code!

    View Slide

  24. it

    View Slide

  25. Sponsors

    View Slide

  26. They’re hiring!
    @dan_jenkins

    View Slide

  27. Also hiring!

    View Slide

  28. Questions?

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

    View Slide

  29. Algorithms

    View Slide

  30. ------------------------------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 Slide

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

    View Slide