Talk given at the London Node.js User Group.
As fast as C?Writing high performance stream parsers in JS.Felix Geisendörfer June 27, 2012 - London Node.js User Group
View Slide
Thanks Forward!
Felix Geisendörfer
(@)felixge(.de)
core contributor
transloadit.com
~50 npm modules
node-formidable
node-mysql
Parser Geeks?
As fast as C?
Dubious Benchmarks Ahead!
Selecting 100k blogpost rows
015000300004500060000node-mysql-0.9.6 node-mysql-libmysqlclient-1.3.3 node-mysql-2.0.0-alpha3539663642920968Rows per Secondnode-mysql-0.9.6 node-mysql-libmysqlclient-1.3.3node-mysql-2.0.0-alpha3https://github.com/felixge/mysql-client-benchmarks
017500350005250070000node-mysql-0.9.6 node-mysql-libmysqlclient-1.3.3 node-mysql-2.0.0-alpha3 php-mysqlnd-5.1368097539663642920968Rows per Secondnode-mysql-0.9.6 node-mysql-libmysqlclient-1.3.3node-mysql-2.0.0-alpha3 php-mysqlnd-5.13https://github.com/felixge/mysql-client-benchmarks
Pure node.js parserscan compete withC Addons
Lessons Learned
Practice
Benchmark First
Buffering can be good!
Code!
it
Sponsors
They’re hiring!@dan_jenkins
Also hiring!
Questions?”http://felixge.de/[email protected]@felixge
Algorithms
------------------------------4a62195680a6Content-Disposition: form-data; name="upload1"; filename="file1.txt"Content-Type: text/plainfile 1 data ...------------------------------4a62195680a6Content-Disposition: form-data; name="upload2"; filename="file2.txt"Content-Type: text/plainfile 2 data ...------------------------------4a62195680a6--Example: Multipart (File Uploads)
Lots and lots of file data ...------------------------------4a62195680a6Naive Boundary Search: One byte at a time