{"id":20409,"date":"2018-02-02T14:58:16","date_gmt":"2018-02-02T19:58:16","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=20409"},"modified":"2018-02-02T14:58:16","modified_gmt":"2018-02-02T19:58:16","slug":"base64-encoding-and-decoding-with-simd-instructions","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2018\/02\/02\/base64-encoding-and-decoding-with-simd-instructions\/","title":{"rendered":"Base64 Encoding and Decoding With SIMD Instructions"},"content":{"rendered":"<p><a href=\"https:\/\/lemire.me\/blog\/2018\/01\/17\/ridiculously-fast-base64-encoding-and-decoding\/\">Daniel Lemire<\/a> (via <a href=\"https:\/\/news.ycombinator.com\/item?id=16171806\">Hacker News<\/a>):<\/p>\n<blockquote cite=\"https:\/\/lemire.me\/blog\/2018\/01\/17\/ridiculously-fast-base64-encoding-and-decoding\/\">\n<p><a href=\"http:\/\/www.alfredklomp.com\/programming\/sse-base64\/\">Alfred Klomp showed a few years ago that you could do much better using vector instructions<\/a>. Wojciech Mu&#x142;a, myself and a few others (i.e., Howard and Kurz) decided the seriously revisit the problem. <a href=\"http:\/\/0x80.pl\/notesen\/2016-01-12-sse-base64-encoding.html\">Mu&#x142;a has a web page on the topic<\/a>.<\/p>\n<p>We found that, in the end, you could speed up the problem by a factor of ten and use about 0.2 cycles per byte on recent Intel processors using vector instructions. That&rsquo;s still more than a copy, but much less likely to ever be a bottleneck. I should point out that this 0.2 cycles per byte includes error handling: the decoder must decode and validate the input (e.g., if illegal characters are found, the decoding should be aborted).<\/p><p><a href=\"https:\/\/github.com\/lemire\/fastbase64\">Our research code is available<\/a> so you can reproduce our results. Our paper is available from arXiv and has been accepted for publication by ACM Transactions on the Web.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Daniel Lemire (via Hacker News): Alfred Klomp showed a few years ago that you could do much better using vector instructions. Wojciech Mu&#x142;a, myself and a few others (i.e., Howard and Kurz) decided the seriously revisit the problem. Mu&#x142;a has a web page on the topic. We found that, in the end, you could speed [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[],"tags":[45,138,71],"class_list":["post-20409","post","type-post","status-publish","format-standard","hentry","tag-c","tag-optimization","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/20409","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=20409"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/20409\/revisions"}],"predecessor-version":[{"id":20410,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/20409\/revisions\/20410"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=20409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=20409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=20409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}