1. 1

    A barely relevant nitpick:

    Unfortunately, C doesn’t have a hash table data structure in its standard library. However, there is libc, which has the hcreate and hsearch hash table functions, so we’ll make a small exception and use those libc-but-not-stdlib functions.

    libc is the standard library of C. hcreate and hsearch are non-standard extensions in GNU libc a.k.a. glibc.

    Curiously though, OS X libc has hcreate and hsearch too. So I figure, this simplification (libc = glibc) is plenty justified.

    1. 3

      Not to nitpick your nitpick, but here’s a comment that states that hcreate is part of POSIX:

      https://news.ycombinator.com/item?id=26466477

      1. 1

        Why not just link to POSIX directly, after all ddg has !posix

        https://pubs.opengroup.org/onlinepubs/9699919799/functions/hcreate.html

    1. 1

      Wow! All y’all are impressively fast! I’m happy to not be last. :)

      (That’s in reference to tonight’s scores. For readers from the future, this is the second night but the first that there are scores, since the first night’s scores were disqualified due to server capacity issues.)

      1. 1

        Yeah…

        That private leaderboard is full.

        1. 1

          https://lobste.rs/s/lgotqc/lobste_rs_advent_code_2020_private#c_zna0br

          I’m seeing a market opportunity for AoC to sell access to larger leaderboards to organizations who are prepared to pay for them..

      1. 2

        The linked VCS history articles claim to cover inner workings etc. — but I’m disappointed to find no mention of (CVS-related, I believe?..) in-source markers like this:

        /* $Id: snprintf.c 927 2002-07-23 23:12:20Z strauss $ */
        

        Those who read the source I’m sure will recognize this, seen in many older pieces.

        It’s still sort of a mystery to me. Can anyone explain what was it used for?

        1. 4

          RCS, which CVS was based on, would automatically expand certain variables – you would put $Id$ in a comment (or a perl string) and it would turn into something like that. It was … a feature.

          I remember adding a line like global $VERSION = split("$Id")[2]; or whatever. It was handy, but hardly worth using CVS for.

        1. 7

          There’s even simpler… one could say, codeless technique of poor man’s sample profiling.

          Just break-&-resume the program a dozen times, each time glancing at the stacks, in a debugger, by hand.

          Chances are, if the debuggee has a bottleneck — you’ll notice its stack in most of the “samples”.

          Automating that like shown is the natural next step… but you can “get the food” even without it.

          1. 2

            Yup. Done that a couple of times in my life!

            If one scrapes a few coins together one can take this poor mans approach to the next level…

            http://www.brendangregg.com/flamegraphs.html

            1. 2

              Haha, yes, the flamegraph is an excellent invention of Brendan Gregg. Got me into seeing more of his work. This gem? https://www.youtube.com/watch?v=tDacjrSCeq4 — I could never imagine.

              I think flamegraphs should be the standard representation of profiler output. It’s great both to get the picture yourself, and to showcase the data to whomever you need to.

              1. 2

                Whenever I look at what the hardware engineers are doing, I say Hardware Engineering is exactly like Software Engineering…. except all the basic primitives were designed by satan.

                So a lot of what hardware (and software) is doing is wrapping. ie. Wrapping something almost reliable enough to be useful, in enough checks and retries to make it reliable enough to be useful.

                So anything (like shouting!) that makes that fundamentally dodgy hardware slightly more dodgy shows up as latency.

                A lot of equipment is designed and tested in near ideal conditions… shipped to the noisy real world…. and magically the throughput and latency numbers aren’t quite as advertised…

                Whether this is RF noise, audio noise, vibration, electrical supply noise, thermal stress, …

                There is a lovely list of embedded facts somewhere, my favourite one is “All sensors are temperature sensors… some of them also measure other things.” and “Everything else is also a temperature sensor”.

                The whole industry is plastered over with “As If”’s..

                Y works “As If” X was true. The fact that sometimes X isn’t true shows up as Y taking (almost) imperceptibly longer.

                Various flavours of Meltdown and Spectre are almost fundamental to what the whole industry does.