The syntax is so exhaustive that even loading the caches takes such a long time.
Markdown loads very slow
Thatâs really interesting because MarkdownEditing doesnât have this problem, despite the fact that it too embeds pretty much everything. What is the core markdown syntax doing thatâs so much worse?
Iâm having the same issue. The slow load (~1 second) happens once per program launch: itâll happen with the first Markdown file I open, then never again as long as the program stays open, then if I quit Sublime Text and restart it itâll happen with the first Markdown file again. Behavior is the same if, instead of opening a Markdown file, I just create a blank new file, open the Command Palette, and trigger âSet Syntax: Markdownâ. The program freezes until the delay completes, the Command Palette doesnât close until the program is responsive again.
My hardware is pretty slow, but it is an SSD and it is fast enough that just about everything else in ST is instant. Including loading all other syntaxes I use, about 5-10. Sublime Text 3.2.2, macOS 10.13.6. (Iâm unable to update macOS to latest.)
Based on earlier comments, maybe syntax compilation is supposed to be getting cached, and isnât?
After you open sublime, but before opening any Markdown file, run sublime.find_resources('Markdown.sublime-syntax.*')
in the console. This should produce (resource paths to) two cache files. Does it?
Yes, the result is
['Cache/Markdown/Markdown.sublime-syntax.cache', 'Cache/Markdown/Markdown.sublime-syntax.rcache']
I then triggered âSet Syntax: Markdownâ and the delay did occur.
I checked and the files exist. Markdown.sublime-syntax.cache is 11 KB, Markdown.sublime-syntax.rcache is 8.4 MB. I tried loading other syntaxes with large .rcache sizes, in particular PHP at 3.4 MB, and the delay seemed proportional, about half as long. So it looks like itâs the large .rcache size. Is that about the size it should be?
That seems like a reasonable regexp cache. Markdown is actually the largest and most complicated syntax by far because it includes many other syntaxes by reference. In some cases, we can use embed
/escape
to avoid duplicating data â but I wonder if that might actually increase initial loading time, because other syntax definitions need to be loaded as well.
If the syntax performance is generally good, except for the one-time latency the first time itâs loaded, then I suspect that this may just be the âoffâ end of the trade-off. Is your Sublime data local (not on a remote filesystem)? Is it on an SSD or a hard drive?
Myself, I tend to leave Sublime open in the background 24/7, so I generally only notice the loading times when Iâm doing something silly/dangerous and crash the plugin host. But I guess on Windows it automatically closes down when you have no windows open, so that might not be helpful advice.