Maybe change .md
extension to be opened as said plain text
before your issue is addressed.
Markdown loads very slow
Under Package Control > Settings - User I have:
{
“bootstrapped”: true
}
I don’t know what it means but since I know now how to open md as plain text I’m good, thank you.
I can confirm @stax76’s issue about Markown. At least the first markdown file being opened in Sublime Text takes 2-5s to load and causes the RAM usage to increase by at least 60MB on Windows. The size of the file or the content doesn’t matter.
The reason seems to be the bunch of syntaxes mensioned by @ThomSmith. All embedded syntaxes and markdown are parsed and loaded to RAM. Even ST’s syntax caching system seems to hit its limits in manner of performance here.
My ST runs on a Core i5 and is installed on a SATA-SSD. Not the fastest but not the slowest hardware.
The heavy delay is just caused because ST loads dozens of embedded syntaxes, which might never be used in a single markdown file at a time.
Already filed an issue about it at
It’s definitely the syntax compilation issue then. There’s not much that can be done about it right now given Sublime’s architecture, but the good news is that it’s only a one-time hit, and you won’t see that hit again unless the underlying syntaxes are updated (and even then, the hit would only be proportional to the number of syntaxes modified).
I mean, now that it’s been compiled, you can load it as markdown and you’ll have no trouble. Like I said, it’s a one-time hit. You shouldn’t see it at all from now on.
Follow the steps that @jfcherng described above to change markdown files to open with the Markdown mode once again. The compilation hit has already taken place, so you shouldn’t see it ever again. In other words, loading markdown files should be basically just as fast with the markdown mode as with the plain text mode.
I changed it back to open markdown files with markdown syntax by default and it is slow again everytime the sublime text application is starting to open a markdown file.
Please excuse when I cannot follow you, I don’t have a lot of experience with sublime text.
Every time you open a file? I wonder if this isn’t just a compilation issue then…
The syntax is so exhaustive that even loading the caches takes such a long time.
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.