Monday, December 1, 2014

Improving Parser Performance using SSE Instructions (in case of PicoHTTPParser)

PicoHTTPParser is a tiny but very fast HTTP parser library known for its use by many Perl applications. In the slides I used last month, I suggested it could be even faster if SIMD instructions were used. Now the feature is available thanks to @herumi.

The library now uses the PCMPESTRI instruction which is part of SSE 4.2, running 68% to 90% faster.

Benchmarkclang -O3clang -O3 -msse4.2Improvement
bench.c2,181,0254,140,787+90%
fukamachi.c3,213,4405,400,064+68%

PCMPxSTRx is a SIMD instruction that can be used for parsing text. In _SIDD_CMP_RANGES mode, it checks at most 16 bytes at once, if each byte is within given set of ranges. Herumi and I have created a wrapper function for the instruction named findchar_fast that iterates though every 16 bytes of a given buffer to find the first occurrence of a byte within a set of given ranges.

And the function is merged neatly into the parser; the code below at first uses the SIMD function to look for a control character (the match condition is defined as ranges1), then falls back to the non-SIMD code to handling up to 15 remaining characters (that cannot be processed by the SIMD function due to out-of-bounds access).
#ifdef __SSE4_2__
  static const char ranges1[] =
    "\0\010"
    /* allow HT */
    "\012\037"
    /* allow SP and up to but not including DEL */
    "\177\177"
    /* allow chars w. MSB set */
    ;
  int found;
  buf = findchar_fast(buf, buf_end,
                      ranges1, sizeof(ranges1) - 1,
                      &found);
  if (found)
    goto FOUND_CTL;
#endif
  /* code that handles the input byte-by-byte */
To summarize, PCMPxSTRx is an excellent instruction for performance that can be cleanly integrated into existing parsers (tokenizers). Hopefully we will see performance improvements in various parsers in the future through the use of the instruction.

This blog post has been written as part of the H2O Advent Calendar.

152 comments:

  1. Nice. This looks as if it would also be very useful for serializers - a JSON string encoder probably passes through 99%+ of its input unchanged, but still needs to check for quotes, control characters etc.

    ReplyDelete
    Replies
    1. Sounds very interesting. Had never thought of that.

      Delete
  2. Intriguing — I tried to use the STR instructions once (PCMPISTRM, to be precise), but after benchmarking it turned out that a combination of PSHUFB/MOVA/PCMPEQB was actually faster. I didn't investigate deeply why that was (and I remember little about that code now), just used the faster combination.

    ReplyDelete
  3. Replies

    1. thankyou so much! I appreciate your efforts!
      You can enjoy gaming of different level when you get access SB game hacker apk to unexplored treasures even without completing the level. For some people, it is not good, and these things don’t belong to a good gamer

      Delete
  4. Want to know regular updates of Euro Cup 2016???? Venue-France,From 10th june-10july.... 24 teams,10 stadiums... Stay updated..
    Euro Cup 2016
    Euro Cup live Streaming
    Euro Cup 2016 Live Streaming
    Euro Cup 2016 Live Score
    Euro Cup 2016 Schedule
    Euro Cup 2016 Fixture

    ReplyDelete
  5. Your blog was too good. i really appreciate with your

    ReplyDelete
  6. The blog or and best that is extremely useful to keep I can share the ideas
    of the future as this is really what I was looking for, I am very comfortable and pleased to come here. Thank you very much.
    wings io| earn to die 6
    earn to die 5| happy wheels
    |Red Ball | duck life

    ReplyDelete
  7. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share.
    dark souls 3 emoji
    slitherio diepio

    ReplyDelete
  8. Friendship Day Images 2016
    Find Happy Friendship Day 2016 HD Images, Quotes, SMS, Greetings and Songs. Also Pictures and Wishes for Best Friends. Best Wallpaper, Wishes and Pictures you can find.



    Raksha Bandhan 2016 Quotes
    Find Happy Raksha Bandhan Day 2016 Images, Quotes, Greetings and Songs. Also Pictures and Wishes for your Brother or Sister. Best Presents, Gifts Ideas and Quotes Poems.



    15 August Independence Day
    Happy Independence Day 15th of August 2016 images and pictures. Watch fireworks, events and celebrations Here

    ReplyDelete
  9. Best Friendship day
    Actually True Best Friendship day stands the test of time. Best Friendship day Celebrate Friendship Day 2016 on August 7, Sunday. You may be separated by physical boundaries and distances. However, when your best friend calls, you can transcend any physical or mental boundary.

    http://efriendshipday.com/

    http://efriendshipday.com/best-friendship-day-2016smspoems-and-picture/


    what is National Friendship Day means now!
    we look at National Friendship day, The first time I met Stoo, a cartoonist and author, he was entertaining a group of people at a cocktail party by drawing pictures of little men with huge erections. I was instantly besotted. The next time I saw him, six months later, he was hosting a gathering for our mutual friend Maria and when I walked through the front door, his face lit up like a candle; we hugged hello as if we'd known each other forever. Later that night he pulled me into his study to show me all the books and comic strips he'd published over the years. We were squished into a pair of old leather movie-theatre seats, balancing paper plates of crudités on our knees, when he blurted out, "Kate! I just adore you.

    ReplyDelete
  10. Sharp Corporation of leading international companies in the field of electronics, is a Japanese company founded in 1922, the company name is now become a symbol of confidence for everyone who is going to buy any electronic device
    One sharp products Sharpe adaptation, sharp was designed at the highest level of efficiency so you can endure hardship especially in hot climates where people need to keep your the accommodation in work mode, so it has sharp conditioner is designed to be able to work all day without stopping
    تكييف شارب العربي
    تكييف شارب العربي

    ReplyDelete
  11. I was very impressed by this post, this site has always been pleasant news. Thank you very much for such an interesting post. Keep working, great job! In my free time, I like play game: Banana Kong, Zombie Tsunami, Swords And Souls. What about you?

    ReplyDelete
  12. The blog or and best that is extremely useful to keep I can share the ideas of the future as this is really what I was looking for, I am very comfortable and pleased to come here. Thank you very much.
    animal jam | five nights at freddy's | hotmail login

    ReplyDelete
  13. First of all i am saying that i like your post very much.I am really impressed by the way in which you presented the content and also the structure of the post. Hope you can gave us more posts like this and i really appreciate your hardwork.

    Happy New Year 2018
    valentine week list
    valentine week list 2017
    happy birthday
    good morning

    ReplyDelete
  14. your information is really awesome as well as it is very excellent and i got more interesting information from your blog. Android App Development Company in Chennai

    ReplyDelete
  15. Love it love it but it's not everyone can choose the right people and treat yourself. So many girls being in love is still wondering who picked the right or wrong side of one person should not belong to her?
    baixar musicas l geometry dash l baixar snapchat l run 2 l b612 app l slither.io

    ReplyDelete
  16. This post is really nice and informative. The explanation given is really comprehensive and informative... Wifi Camera Chennai

    ReplyDelete



  17. The share your really gives us excitement. Thanks for your sharing. If you feel tired at work or study try to participate in our games to bring the most exciting feeling. Thank you!
    hotmail login | red ball | 192.168.1.1

    ReplyDelete
  18. Easter will be the best and most expected long few days of 2017 and is thusly in like manner the busiest time on our nation's boulevards. Make a point to organize your Easter run with enormous lead time – ideally months ahead of time. Various hotels, resorts and campgrounds are held out months early, even a year or more for renowned regions.
    https://en.wikipedia.org/wiki/List_of_dates_for_Easter
    Easter wishes

    ReplyDelete
  19. This is an excellent post i seen.I have to thanks to you to share it. It is really what I wanted to see hope in future you will continue for sharing such a excellent post.
    Mothers Day Images Download
    Mothers Day Images Free Download
    Happy Mothers Day Images Download
    Mothers Day Images HD

    ReplyDelete
  20. First of all i am saying that i like your post very much.I am really impressed by the way in which you presented the content and also the
    structure of the post. Hope you can gave us more posts like this and i really appreciate your hardwork.
    Pictures of Memorial Day
    Images of Memorial Day
    Memorial Day Free Pictures

    ReplyDelete

  21. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.

    Android App Development Company

    ReplyDelete



  22. great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one. And i hope this will be useful for many people..
    http://smarther.co/web-design-development-company/
    http://smarther.co/web-services/web-design-company-india/
    http://smarther.co/web-services/web-development-company-india/
    http://smarther.co/web-design-company-in-chennai/
    http://smarther.co/web-design-company-in-chennai/

    ReplyDelete
  23. great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
    web design Company
    web development Company
    web design Company in chennai
    web development Company in chennai
    web design Company in India
    web development Company in India

    ReplyDelete
  24. I am expecting more interesting topics from you. And this was nice content and definitely it will be useful for many people.

    iOS App Development Company

    ReplyDelete
  25. it is really amazing...thanks for sharing....provide more useful information...
    Mobile app development company

    ReplyDelete
  26. Windows 10 is fairly new for some users, and the rest decliningrest declining this idea or considering that they have been fix connections to bluetooth audio devices and wireless displays in windows 10 using it for a while now may want to get their facts checked with a developer.

    ReplyDelete

  27. This is what i was looking for thank you for sharing this amazing post. keep on posting these kind of nice post
    avast activation code

    ReplyDelete
  28. Leading Dubai Visa Service Provider Company
    Dubai Visa India

    ReplyDelete
  29. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..
    Fitness SMS
    Fitness Text
    Salon SMS
    Salon Text
    Investor Relation SMS
    Investor Relation Text

    ReplyDelete
  30. This is really good information I have visited this blog to read something fresh and I really admire you efforts in doing so.
    192.168.1.1

    ReplyDelete
  31. Thank you both for sharing Holy Mass with us each day FNAF Sister Location Juegos Friv Friv 2018 to make yourselves available Friv Twizl Jeux De Twizl Juegos De FNAF Sister Location when we were called out late at night and any other time and for your support and encouragement in every respect. Juegos Friv 2021 Juegos Twizl Juegos Yepi 2017 Juegos De Twizl

    ReplyDelete
  32. great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.
    web design Company
    web development Company
    web design Company in chennai
    web development Company in chennai
    web design Company in India
    web development Company in India

    ReplyDelete
  33. nice blog, thank you
    Danke, dafur dass Ihr jeden Tag mit uns die Hl. Messe gefeiert habt, fur all die Reparaturen im ganzen Haus Friv 10 Friv 2018 Friv 2019 fur Euere Bereitschaft Friv 10 Friv 20 Friv 2 immer zur Verfugung zu stehen Geometry Dash Twizl Twizy Twizl Danke, dass Sie Ihr Muhen um den Aufbau des Leibes Christi mit uns teilten.

    ReplyDelete
  34. Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..

    ReplyDelete
  35. Senhor Deputado Cashman, agradeço-lhe a informação. Juegos Friv Jogos Friv Friv4school A todos que partilham e trabalham sob estas mesmas convicções e princípios Jeux De Friv Juegos De Roblox Zoxy Mais uma vez, obrigada ao Parlamento por comungar da visão que informa a nova política dos consumidores Juegos Kizi Juegos Yepi Twizl Zoxy assente no mercado - a visão de um mercado de consumidores informados e capacitados que procuram e usufruem, com confiança,

    ReplyDelete
  36. great and nice blog thanks sharing..I just want to say that all the information you have given here is awesome...Thank you very much for this one.

    ReplyDelete

  37. I like the news that you have written in a detail.
    Thank you for the information you provide. I had a look to start my own.
    hotmail sign | hotmail login in uk | msm hotmail

    ReplyDelete
  38. I like the news that you have written in a detail.
    Thank you for the information you provide. I had a look to start my own.
    hotmail sign | hotmail login in uk | msm hotmail

    ReplyDelete
  39. Wir danken Ihnen
    Friv4school Gry Friv Juegos Friv dass Sie diese Hoffnung mit uns teilen und diesen Schritt auf dem Pilgerweg des Vertrauens Friv Juegos Friv Gry Friv mit uns gegangen sind. Juegos Friv Juegos De Friv Ihnen hiermit die gewünschten Informationen vermitteln zu können. Yepi Juegos Friv wir danken Ihnen für das Interesse an unseren Produkten und hoffe

    ReplyDelete
  40. شركة نقل عفش بالرياض وجدة والدمام والخبر والجبيل اولقطيف والاحساء والرياض وجدة ومكة المدينة المنورة والخرج والطائف وخميس مشيط وبجدة افضل شركة نقل عفش بجدة نعرضها مجموعة الفا لنقل العفش بمكة والخرج والقصيم والطائف وتبوك وخميس مشيط ونجران وجيزان وبريدة والمدينة المنورة وينبع افضل شركات نقل الاثاث بالجبيل والطائف وخميس مشيط وبريدة وعنيزو وابها ونجران المدينة وينبع تبوك والقصيم الخرج حفر الباطن والظهران
    شركة نقل عفش بجدة
    شركة نقل عفش بالمدينة المنورة
    شركة نقل اثاث بالرياض
    شركة نقل عفش بالدمام
    شركة نقل عفش بالطائف

    ReplyDelete
  41. Get best At&t Email support services in USA by calling 1-877-363-0097 toll-free number for At&t email Support Number, At&t email technical support phone number.

    ReplyDelete
  42. Caro leitor, no Jogos Friv você encontra uma imensa variedade de jogos on-line sem pagar nada! Temos muitos jogos divertidos e gratuitos, com novas inserções e atualizações diárias! Você encontrará JOGOS FRIV 2, FRIV 3, FRIV 4 e FRIV 1000 e FRIV 360. Aproveite e boa diversão!

    ReplyDelete
  43. I like the post format as you create user engagement in the complete article. It seems round up of all published posts. Thanks for gauging the informative posts.
    cara menggugurkan kandungan

    ReplyDelete
  44. I am expecting more interesting topics from you. And this was nice content and definitely it will be useful for many people.

    PSD to Wordpress
    wordpress website development

    ReplyDelete
  45. Caro leitor, no Friv Jogos você encontra uma imensa variedade de jogos on-line sem pagar nada! Temos muitos jogos divertidos e gratuitos, com novas inserções e atualizações diárias!
    Friv Jogos online

    ReplyDelete
  46. Take a SAP FICO Training Courses with Expert provided by Talent Magnifier with live practical class.To know more about the course pls visit our Site

    ReplyDelete
  47. If You Want Watch IPL Live Stream Then Visit www.crickspo.com, it also provide IPL Live ScoreCheck IPL Updates, IPL News, Ball By Ball Score, Men of the atch, men of the series, who won the toss today etc.

    ReplyDelete
  48. I’m very happy to read this. This is the kind of manual that needs to be given and not the accidental misinformation that is at the other blogs. Appreciate your sharing this greatest doc!
    Jogos Friv ,Friv Online ,Click Jogos Pro

    ReplyDelete
  49. I was looking for some solution on google and then I cam across your website and got addicted. Such a nice way of website management, colours, way of writing and layout is attractive.
    ipl final score
    ipl live stream 2018
    ipl live score 2018
    ipl 2018 Schedule match
    watch ipl online live
    ipl live score
    free ipl score
    ipl live stream
    ipl final 2018
    ipl live streaming

    ReplyDelete
  50. Caro leitor, no Jogos Online Wx você encontra uma imensa variedade de jogos on-line sem pagar nada! Temos muitos jogos divertidos e gratuitos, com novas inserções e atualizações diárias! Você encontrará JOGOS FRIV 2, FRIV 3, FRIV 4 e FRIV 1000 e FRIV 360. Aproveite e boa diversão!
    Jogos Online Wx
    Jogos do Cartoon Network
    Jogos do Roblox

    ReplyDelete
  51. It's a fact that your blog posts are so unique and interesting and I enjoys a lot while reading your posts because you explained your post very deeply in a very easy and clear language. Thanks for your support and Happy Blogging :D

    ahsec board hs result
    bseb board matric result
    bseb board intermediate result
    cgbse board 10th result
    cgbse board 12th result
    cisce board 10th result

    ReplyDelete


  52. You guys are really doing great work. I am sure you're doing research to provide such kind of stuff to us. Feeling proud that people like you still exist in the world.
    ipl live score
    free ipl score
    ipl live stream
    ipl final 2018
    ipl live streaming
    ipl final score
    ipl live stream 2018
    ipl live score 2018
    ipl 2018 Schedule match
    watch ipl online live

    ReplyDelete
  53. Thank you for sharing this information. Love your blog post. Please Keep updating. You can also visit our blog for
    Happy Mothers Day Pictures
    Happy Mothers Day 2018 Images

    ReplyDelete
  54. This is very good blog you should like this post my ideas here

    ReplyDelete
  55. A citação é o que faz toda a diferença, o que raramente dá importância e jogue online aqui : FRIV e você verá vários jogos interessantes.
    Friv Jogos
    Jogos Online
    2
    Jogos Online
    BLOGGER
    Humor
    Jogos 360
    Click Jogos Pro
    Jogos FRIV
    Jogos Online
    Friv

    ReplyDelete
  56. This comment has been removed by the author.

    ReplyDelete
  57. We are team of experts visit our site for troubleshooting related to printer. we offer a wide array of services, ranging from office supplies, printer repairs and cartridge recycling. providing high quality service and support to its customers. Our technical support is the best visit our website

    ReplyDelete
  58. When I originally commented I clicked the -Notify me when new surveys are added- checkbox and today whenever a comment is added I purchase four emails using the same comment. Will there be any way you may remove me from that service? Thanks!

    Funny Mothers Day Images 2018
    When Is Mothers Day 2018
    Mothers Day Sweet Messages for Mother in Laws
    Happy Mothers Day Activity Creative ideas 2018
    Happy Mothers Day Crafts 2018

    ReplyDelete

  59. Talent Magnifier is a professional, proficient, well-organized and deftly managed Training and development company with 100% job placement assistance.

    ReplyDelete
  60. A citação é o que faz toda a diferença, o que raramente dá importância e jogue online aqui :FRIV e você verá vários jogos interessantes.
    Friv Jogos
    Jogos Online
    Click Jogos
    Jogos Online
    Jogos 360
    Click Jogos Pro
    Jogos FRIV
    Jogos Online
    Friv
    Friv Online Jogos

    ReplyDelete
  61. Join best e-accounts and e-gst training in delhi
    in Talent Magnifier with 100% job placement
    assistance.
    Intrested candidate can Contact Us @
    https://www.talentmagnifier.com/accounts-finance-gst-training-course-institute/

    ReplyDelete
  62. This is very interesting, You’re a very skilled blogger. I have joined your feed and look forward to seeking more of your fantastic post. Also, I have shared your web site in my social networks!
    Regards - www.office.com/setup
    www.office.com/setup

    ReplyDelete
  63. DIAL +1(844)443-2544 THIS IS FREE COMCAST EMAIL CUSTOMER SERVICE PHONE NUMBER TO FIX ANY TYPE OF PROBLEM OR ISSUES ON YOUR EMAIL OF ANY PROVIDER LIKE GMAIL,HOTMAIL,AOL,ATT , Zoho Mail, Mail.com, Yahoo! Mail, GMX, Fastmail, Hushmail, Inbox.com, ShortMail,ETC.
    http://customercarenumberusa.com/comcast-customer-service-number/

    ReplyDelete
  64. DIAL +1-844-443-2544 TOLL-FREE YAHOO MAIL CUSTOMER SUPPORT PHONE NUMBER AND GET CONNCTED WITH YAHOO MAIL CUSTOMER SUPPORT

    ReplyDelete
  65. In addition to WWE Money in the Bank, NXT TakeOver will also return to the Allstate Arena on the same weekend. Tickets for TakeOver: Chicago are available now at

    Money In The Bank 2018 Live Streaming

    ReplyDelete
  66. Expect Talent Magnifier's Basic Computer Training Courses For Freshers -Enroll Now - Free Demo Classes.
    For more info - Click Here

    ReplyDelete

  67. Contact With America Online Aol Email Support Phone NumberAol Email Customer Support Phone Number
    To fix Any Troubleshoot Error And Bugs With Expert technicicans
    Who Can Easily Fix All type Of Aol Email Issue

    ReplyDelete
  68. Contact +1(888) 211-0387 Epson Laser Printer Support Phone Number for Epson Printer Tech Support Help. Connect Epson Laser Printer support Number Technician for Fix Laser wireless printer, Installatiion, Drivers and setup Laser Printer on Windows and Mac Errors.

    ReplyDelete
  69. Contact +1(888) 211-0387 Epson Laser Printer Support Phone Number for Epson Printer Tech Support Help. Connect Epson Laser Printer support Number Technician for Fix Laser wireless printer, Installatiion, Drivers and setup Laser Printer on Windows and Mac Errors.

    ReplyDelete
  70. get the latest best wishes msgs, sms, pic, status happy birthday msgs, happy fathers day, happy mothers day sms, happy new year fb status etc .

    GET THE LATEST GOVT JOB NOTIFICATIONS ELIGIBILITY DETAILS, AGE LIMIT, QUALIFICATION NEEDED FOR GOVT JOB .

    get the latest COMPUTER LAUNCH INFORMATION AND KEYBOARD,MOUSE,PRINTERS,HEADPHONES,MONITORS,GAMING ACCESSORIES

    ReplyDelete
  71. Join Best Microsoft Advanced Excel Training
    in Talent Magnifier -Enroll Now For Free Demo Classes.
    For more info - Click Here

    ReplyDelete
  72. get the latest best wishes msgs, sms, pic, status happy birthday msgs, happy fathers day, happy mothers day sms, happy new year fb status etc .

    GET THE LATEST GOVT JOB NOTIFICATIONS ELIGIBILITY DETAILS, AGE LIMIT, QUALIFICATION NEEDED FOR GOVT JOB .

    get the latest COMPUTER INFORMATION AND KEYBOARD,MOUSE,PRINTERS,HEADPHONES,MONITORS,GAMING ACCESSORIES INFORMATION.

    ReplyDelete
  73. Thanks for this valuable blog with. This is such a great full to be found this for me. Visit for
    Website Design Company

    ReplyDelete
  74. Nice blog, thank you so much for sharing this. I’m really impressed with this. Visit for
    Bulletproof VPS

    ReplyDelete
  75. Hotstar is one of the best platform for fans to enjoy every moment of cricket without cost. Asia Cup is starting in a few days in United Arab Emirates. Asia Cup 2018 is one of the biggest event in 2018 after the Football World Cup. 2018 Asia Cup (ODI) cricket carry six teams listed below. Hotstar live streaming Asia Cup 2018 world wide for cricket fans.
    Asia Cup Live Streaming
    Hotstar Live Streaming
    India vs Pakistan live Streaming
    PTV Sports live Streaming
    Star Sports Live Streaming

    ReplyDelete
  76. These two main adversaries will do their damnedest to enlist a win. At the fag year’s end 2018, the pressure between two nations had heightened in particular and given the air winning around then it was generally expected that the match may not occur, assuming never, at any rate sooner rather than later. Yet, as there has been some defrost between the two nations, the cricket devotees of these two nations as well as around the globe can seek after the huge match.

    Hot Star Live Streaming
    Pakistan vs India Live Streaming
    India vs Pakistan Live Streaming

    ReplyDelete
  77. Talent Magnifier has been supporting candidates with advanced excel training.We are the Advanced Excel Training in Delhi. We guarantee you will get a higher salary than your peers after completing the course from us.For more details visit us @http://bit.ly/2wumdN3

    ReplyDelete