This year, some members of the Rust Programming Language Community Server on Discord set out to solve AoC in under 1ms. I'm pleased to announce that through the use of LUTs, SIMD, more-than-questionable `unsafe`, assertions, LLVM intrinsics, and even some inline ASM that goal has been reached (for real this time)!<p>*As of today, our solutions are able to solve all 49 problems in <1ms!*<p>I have obtained consent from all the top participants to post their solutions to a shared repo, for the community to review and learn from! *All solutions are now available at the linked GitHub repo!*<p>Our solutions have a total runtime of *988936ns*!<p># Context/Caveats<p>- All submissions were run on the same hardware (Ryzen 5950X) to ensure consistency, with the same compiler flags and features available. This was on rustc nightly (updated throughout the course of the contest), and with CPU speed capped at 3400 MHz with boost clock disabled.<p>- AVX-512 was not available on the machine so none (?) of the solutions utilize that particular set of accelerated instructions, but there is <i>plenty</i> of other SIMD in use.<p>- All submissions were run against the same inputs to ensure consistency.<p>- Caching anything that has been fed with input was not allowed to prevent cheating and/or trivial solutions like `Map<Input, Output>`.<p>- For the same reason, inputs were not directly available to the participants, and were not provided at compile-time.<p>- Participants were allowed to use compile-time tricks in their answers. Due to limitations in the benchmark bot, the runtime of these optimizations could not be measured. This was considered acceptable as the compiled binaries were expected to otherwise work correctly for arbitrary inputs. This means that participants are allowed to use look-up tables (LUTs) in their answers, but those LUTs are expected to work for arbitrary inputs, not just specific ones.<p>- I/O is trivial, and was thus not measured as part of the benchmark. That is, participants were provided with an `&str` or `&[u8]` input (their choice) and expected to provide an `impl Display` as part of their result. Therefore, <i>input parsing was measured</i>.<p>If you are interested, join us in #advent-of-code-2024 on the Discord server for further discussion :)<p># Further Reading<p>If you would like a more in-depth explanation of some of the optimization techniques used, I highly recommend you check out this article by ameo [0] (one of our participants). It covers the process they used to optimize their solution for Day 9 Part 2, and how they got it to the top of our leaderboard. The article provides incredible information on the process of both high-level and micro optimization.<p># Credits:<p>- Thank you to the members of the `Rust Programming Language Community` and `Serenity-rs` Discord servers and everyone else who participated in the challenge!<p>- Thank you to Eric Wastl for hosting AoC every year!<p>- Thank you to Noxim [1] for writing the original version of our benchmark bot [2].<p>- Extra special thank you to yuyuko [3], bend-n [4], and giooschi [5] for their help in maintaining and improving our benchmark bot.<p>[0]: <a href="https://cprimozic.net/blog/optimizing-advent-of-code-2024/" rel="nofollow">https://cprimozic.net/blog/optimizing-advent-of-code-2024/</a><p>[1]: <a href="https://github.com/noxime">https://github.com/noxime</a><p>[2]: <a href="https://github.com/indiv0/ferris-elf">https://github.com/indiv0/ferris-elf</a><p>[3]: <a href="https://github.com/ultrabear">https://github.com/ultrabear</a><p>[4]: <a href="https://github.com/bend-n/">https://github.com/bend-n/</a><p>[5]: <a href="https://github.com/SkiFire13/">https://github.com/SkiFire13/</a>