Six times faster than C

This page summarizes the projects mentioned and recommended in the original post on

Our great sponsors
  • Onboard AI - Learn any GitHub repo in 59 seconds
  • InfluxDB - Collect and Analyze Billions of Data Points in Real Time
  • SaaSHub - Software Alternatives and Reviews
  • blog-code

    > because without FDO (or PGO) the compiler has no idea how likely each branch is to be taken

    So, the maximum amount of times you can hit '\0' is once in the string, because then the function returns, but you can hit the other characters many times, which seems to be information a compiler has access to without PGO.

    PGO does help, of course, and on my machine gives me 2.80s, which is better than the code at the end of the `Rearranging blocks` section :)

    > I assume that their test input (which isn't described in the post, and is also not in their GitHub repo)

    It's described under `Benchmarking setup`, and is in the repository here:

    Side note: There's a part two to this post (linked at the bottom) where I make the C code as fast as I possibly can, and it beats all the assembly in this post.

    I never said writing assembly is (necessarily) a good idea, I just find optimizing it, and deciphering compiler output, an interesting challenge, and a good learning opportunity.

  • compiler-explorer

    Run compilers interactively from your web browser and interact with the assembly

    I tried, and neither Clang nor GCC trunk give the same code for the two programs.

    Pretty shocking for such a simple program.

  • Onboard AI

    Learn any GitHub repo in 59 seconds. Onboard AI learns any GitHub repo in minutes and lets you chat with it to locate functionality, understand different parts, and generate new code. Use it for free at

  • highway

    Performance-portable, length-agnostic SIMD with runtime dispatch

    You could study Google's Highway library [1].


NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts