Sublime Forum

Markdown loads very slow

#21

The syntax is so exhaustive that even loading the caches takes such a long time.

0 Likes

#22

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?

0 Likes

#23

Another OP says it no longer happens today somehow.

1 Like

#24

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?

0 Likes

#25

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?

0 Likes

#26

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?

0 Likes

#27

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.

0 Likes