High typing latency when authoring a math-heavy note with linked preview

Math blocks are only re-rendered when they are changed. If your file separates each block of text using 2 line breaks (1 empty line) then they should only be re-rendered when you actually modify the source block.

I’ve downloaded the provided file to do some performance testing. There seems to be 3 major sources of performance slowdowns. My PC is too fast to experience any of them, but luckily the built in debugger can impose a 4x or 6x CPU slowdown, which shows the issues clearly.

  1. HTML sanitizer is a bit slow. I’ve added a patch for this one (should be in 0.7.6), but it’s mainly slow because it re-sanitizes the whole document on edit, where it should only be re-sanitizing the edited blocks.

  2. Blocks that contain many pieces of inline LaTeX would re-render all of them on edit. For now, not much I can do about that, but we do have plans for optimization in the future. See Performance issues when working with larger .md files (With video footage)

  3. The whole document having so many separate pieces of LaTeX causes significant layout strain on the rendering engine. This one I don’t have much to help, but we do have plans for small optimizations here and there that should cut down on the performance cost of this. First optimization will remove elements that are outside of view, and second optimization will “box” panes so having a crowded preview pane won’t impact another editor pane, for example.

4 Likes