macana

Static site generator for Obsidian Vault

Dev docs for profiling I tried to optimize build process so the docs can be built under 150ms. Currently, on my M1 Mac mini, it takes 180ms~210ms. I think it's too much for just 16 documents. I'm not good at profiling or optimization or whatever. I suck at looking at profiling result. What the fuck is bottom-up? But I have to profile in order to optimize further more. Luckily, Deno/V8's profiler is easy to use and call tree representation is intuitive even for beginers like me. Unfortunately, most of the process time is from third-party libraries. The most time consuming one was refractor (syntax highlighting) and the second was hast-util-to-html or mdast-from-markdown (or inner micromark). All of those are reasonable: refractor's "all" entrypoint (I willingfully choose this) contains every language syntax, thus it takes a lot of time loading and registering syntaxes. Seriealizing HTML and parsing Markdown are, well, time-consuming considering they are written in JavaScript, which is difficult to write performant string ops (esp. spatial efficiency). In its current form, the most impactful performance optimization I can think of is not emitting embed page until required. In order to do that, I have to make significant changes to how page builder handles build queue (or make one). While I found out there are no low-haning fruit for temporal optimization, I believe an experience and knowledge I gained from this should be noted and shared anyhow. So here it is.

Changes

1 changed files (+21/-3)