Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

Thanks Forward!

Slide 3

Slide 3 text

Felix Geisendörfer

Slide 4

Slide 4 text

(@)felixge(.de)

Slide 5

Slide 5 text

core contributor

Slide 6

Slide 6 text

transloadit.com

Slide 7

Slide 7 text

~50 npm modules

Slide 8

Slide 8 text

node-formidable

Slide 9

Slide 9 text

node-mysql

Slide 10

Slide 10 text

Parser Geeks?

Slide 11

Slide 11 text

As fast as C?

Slide 12

Slide 12 text

Dubious Benchmarks Ahead!

Slide 13

Slide 13 text

Selecting 100k blog post rows

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

Pure node.js parsers can compete with C Addons

Slide 19

Slide 19 text

Lessons Learned

Slide 20

Slide 20 text

Practice

Slide 21

Slide 21 text

Benchmark First

Slide 22

Slide 22 text

Buffering can be good!

Slide 23

Slide 23 text

Code!

Slide 24

Slide 24 text

it

Slide 25

Slide 25 text

Sponsors

Slide 26

Slide 26 text

They’re hiring! @dan_jenkins

Slide 27

Slide 27 text

Also hiring!

Slide 28

Slide 28 text

Questions? ” http://felixge.de/ felix@debuggable.com @felixge

Slide 29

Slide 29 text

Algorithms

Slide 30

Slide 30 text

------------------------------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)

Slide 31

Slide 31 text

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