1. 109
  1. 29

    In the new JS+Rust implementation this would have required extra work, but it turned out, that’s not needed either - clicking on the progress bar in the new player, to jump to the desired time in the recording, results in instantaneous jump, even when it has to feed the emulator with megabytes of data to parse and interpret.

    If you’re fast enough you don’t need fancy features!

    1. 11

      Also enjoyed this bit:

      At first I planned to implement the terminal emulation part in Rust without any optimizations, just write idiomatic Rust code, then revisit the tricks from the old implementation. The initial benchmarks blew my mind though, showing that spending additional time on optimizing the emulation part is absolutely unnecessary.

      1. 2

        For my first book, the publisher outsourced the conversion to ePub and got awful results (apparently the outsourced company used the PDF, not the LaTeX sources, and mangled a lot of things). For my second book, I put all of the macros in the header and wrote semantic markup in all of the chapter .tex files. I wrote a program in Objective-C that parsed my markup, built a DOM-like structure, did cross-referencing, and generated an ePub structure. I had exactly the same idea as the quote: write it naively, optimise later. Objective-C objects for everything, message sending for all control flow, and so on.

        The first time I ran it on the 200 page book (debug build, -O0), it took 250ms, of which about 100ms was process-creation time. It did use about 300 MB of memory, but adding an autorelease pool inside a loop that generated a lot of short-lived objects fixed that.

        This was on a computer that was significantly slower than my cheap phone is today.

        I managed to get the execution time up to closer to a minute by using libclang to parse all of the files that contained my examples and annotate each token with its meaning (e.g. local variable, global variable, macro) that I could then style in CSS.

        1. 1

          Would be nice if they would post a follow up what they had to optimize to gain the speed they needed.