Sublime Forum

Opening small file now takes noticeably longer?

#2

When installing a new version of Sublime Text, the syntax files are refreshed, and must be compiled into an optimized state after including all related syntaxes. Since there was a rewrite of LaTeX recently and I know that it supports embedding at least some other syntaxes, I have a decent impression that the syntax implementation is now more complex. This complexity manifests itself the first time you open a file with that syntax, because all of the contexts must be compiled together.

This should only happen the first time you open a file after you install a new version of Sublime Text, or there is an update to the syntax in question (or one of its includes).

Do you see the loading bar after it completes on the first file? I notice this opening Objective-C++ files after syntax changes since that is a complex syntax that includes various contexts from C, C++ and Objective-C. However, after the first file, each subsequent opening is lightning fast.

0 Likes

#3

I notice this after every restart. As a matter of fact, when I open/quit several times with the package control messages file selected, even that file takes about 0.75 seconds to show any text at all.

0 Likes

#4

You should post the contents of your Console. It sounds like something else is going on.

0 Likes

#5

This the contents of console:

startup, version: 3126 osx x64 channel: stable executable: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text working dir: / packages path: /Users/diego/Library/Application Support/Sublime Text 3/Packages state path: /Users/diego/Library/Application Support/Sublime Text 3/Local zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages zip path: /Users/diego/Library/Application Support/Sublime Text 3/Installed Packages ignored_packages: ["Vintage"] pre session restore time: 0.620747 using gpu buffer for window loading dictionary Packages/Language - English/en_US.dic first paint time: 0.738157 using gpu buffer for window startup time: 0.784591 reloading plugin Default.auto_indent_tag reloading plugin Default.block reloading plugin Default.comment reloading plugin Default.convert_syntax reloading plugin Default.copy_path reloading plugin Default.delete_word reloading plugin Default.detect_indentation reloading plugin Default.duplicate_line reloading plugin Default.echo reloading plugin Default.exec reloading plugin Default.fold reloading plugin Default.font reloading plugin Default.goto_line reloading plugin Default.history_list reloading plugin Default.indentation reloading plugin Default.install_package_control reloading plugin Default.kill_ring reloading plugin Default.mark reloading plugin Default.new_templates reloading plugin Default.open_context_url reloading plugin Default.open_in_browser reloading plugin Default.pane reloading plugin Default.paragraph reloading plugin Default.paste_from_history reloading plugin Default.profile reloading plugin Default.quick_panel reloading plugin Default.run_syntax_tests reloading plugin Default.save_on_focus_lost reloading plugin Default.scroll reloading plugin Default.set_unsaved_view_name reloading plugin Default.settings reloading plugin Default.show_scope_name reloading plugin Default.side_bar reloading plugin Default.sort reloading plugin Default.swap_line reloading plugin Default.switch_file reloading plugin Default.symbol reloading plugin Default.transform reloading plugin Default.transpose reloading plugin Default.trim_trailing_white_space reloading plugin CSS.css_completions reloading plugin Diff.diff reloading plugin HTML.encode_html_entities reloading plugin HTML.html_completions reloading plugin 0_package_control_loader.00-package_control reloading plugin 0_package_control_loader.01-pygments reloading plugin 0_package_control_loader.01-tabulate reloading plugin 0_package_control_loader.10-pathtools reloading plugin 0_package_control_loader.20-package_events reloading plugin 0_package_control_loader.20-watchdog reloading plugin 0_package_control_loader.50-backrefs reloading plugin 0_package_control_loader.50-markupsafe reloading plugin 0_package_control_loader.50-oauthlib reloading plugin 0_package_control_loader.50-python-markdown reloading plugin 0_package_control_loader.50-requests reloading plugin 0_package_control_loader.51-python-jinja2 reloading plugin 0_package_control_loader.51-requests-oauthlib reloading plugin 0_package_control_loader.55-mdpopups reloading plugin Alignment.Alignment reloading plugin BracketHighlighter.bh_core reloading plugin BracketHighlighter.bh_logging reloading plugin BracketHighlighter.bh_plugin reloading plugin BracketHighlighter.bh_regions reloading plugin BracketHighlighter.bh_remove reloading plugin BracketHighlighter.bh_rules reloading plugin BracketHighlighter.bh_search reloading plugin BracketHighlighter.bh_swapping reloading plugin BracketHighlighter.bh_wrapping reloading plugin BracketHighlighter.changes reloading plugin BracketHighlighter.support reloading plugin FileBrowser.0_dired_fs_observer /Users/diego/Library/Application Support/Sublime Text 3/Packages/watchdog/all/watchdog/observers/__init__.py:74: UserWarning: Failed to import fsevents. Fall back to kqueue warnings.warn("Failed to import fsevents. Fall back to kqueue") reloading plugin FileBrowser.common reloading plugin FileBrowser.dired reloading plugin FileBrowser.dired_file_operations reloading plugin FileBrowser.dired_misc reloading plugin FileBrowser.fixpaths reloading plugin FileBrowser.jumping reloading plugin FileBrowser.prompt reloading plugin FileBrowser.show reloading plugin FileDiffs.file_diffs reloading plugin Gist.gist reloading plugin Gist.helpers reloading plugin Gist.request reloading plugin Gist.settings reloading plugin Google Spell Check.google-spell-check reloading plugin JsFormat.js_formatter reloading plugin LaTeXing.LaTeXing reloading plugin LinkOpener.LinkOpener reloading plugin Material Theme.mt_activator reloading plugin Material Theme.mt_changes reloading plugin Material Theme.mt_config reloading plugin Material Theme.mt_info reloading plugin Material Theme.mt_urls reloading plugin Package Control.1_reloader reloading plugin Package Control.2_bootstrap reloading plugin Package Control.Package Control reloading plugin SideBarEnhancements.SideBar reloading plugin SideBarEnhancements.SideBarAPI reloading plugin SideBarEnhancements.SideBarDefaultDisable reloading plugin Wrap Plus.wrap_plus reloading plugin AutoSpell.AutoSpell reloading plugin PlainTasks.PlainTasks reloading plugin PlainTasks.PlainTasksDates reloading plugin PlainTasks.PlainTasksToHTML reloading plugin PlainTasks.plist_parser plugins loaded Building AutoSpell Index: Started Building AutoSpell Index: Finished Package Control: Skipping automatic upgrade, last run at 2016-09-23 19:45:53, next run at 2016-09-23 20:45:53 or after

0 Likes

#6

Here is a gif. Its not very long, but it used to be instant.

0 Likes

#7

Can you try reverting, but save your folder. I’m curious if some package or dependency is causing issues.

If you look in the status bar there is something about “Finished Caching”. That is not something built in – perhaps something is doing a bunch of work in the UI thread?

0 Likes

#8

Hey Will,

After reverting, I still have the following behavior:

(This is 10th time I open the file so I’ve already skipped the long first time)

0 Likes

#9

Try selecting the Syntax Tests build system and run the Performance variant. I’m curious how long it takes to lex the file.

How large is the file in lines and KB?

0 Likes

#10

The file is 62kb and just a bit over 1000 lines. Sorry will, can you please elaborate on how I select the syntax tests build system and run the performance variant?

Thanks for the continued help!

0 Likes

#11

See here: https://www.sublimetext.com/docs/3/syntax.html#testing

Once the above conditions are met, running the build command with a syntax test or syntax definition file selected will run all the Syntax Tests, and show the results in an output panel.

0 Likes

#12

Thank you for that. Im still a little unclear though - am I supposed to generate my own synax test file for latex?

0 Likes

#13

The latex package already has one, just open it on the default packages, and go to build.

0 Likes

#14

Where is it located? In my ~/Library/Application Support/Sublime Text3/ I only have the following contents:

The Cache/ folder has has LaTeX/ subfolder with:

Am I missing something?

0 Likes

#15

You don’t need to create a syntax file. Just open your LaTeX file and then select Tools > Build System > Syntax Tests.

Then run Tools > Build With… and select Performance. It will measure how long the current LaTeX syntax takes to lex your file, averaged over 10 runs. The UI will hang while it is doing this.

0 Likes

#16

Thanks will! It says:

Syntax “Packages/LaTeX/LaTeX.sublime-syntax” took an average of 9.6ms over 10 runs
[Finished]

Edit: Not sure if this is important, but since reverting to a fresh state, I can’t actually “build” (compile) latex, as I dont have the proper settings anymore.

0 Likes

#17

Well, since it only takes 9.6ms to lex your whole file, it is not the syntax definition that is the issue. There must be something else going on that is affecting performance.

What third-party packages do you have installed, if any?

0 Likes

#18

Right now none. I was using latexing, some themes, etc. I can get a full list by restoring my user folder.

But even in the revert state that 1second delay to open the file is normal? I never seemed to notice it before.

0 Likes

#19

@wbond: to add another data point, I see the same behavior as @diego898.

The first time I open (for example) a latex file after starting ST there is always a brief loading bar (just as his gif shows, and where I had assumed the syntax includes were being recompiled or checked.) This always happens on opening the first latex file after ST loads. It is much shorter than the initial file load that happens when a new version of ST is installed, but still noticeably longer than all subsequent file opens in a given session. It is also much more noticeable on my computer with a slower/older processor.

I see the same behavior on a clean new portable version, so I don’t think it is related to a third party package. I have also observed this behavior for a while in syntaxes that include other syntaxes (possibly since the introduction of sublime-syntax), though I suspect it only started in the LaTeX syntax with the rewrite.

As noted, I had assumed this initial delay was due to a necessary check to verify that none of the syntax includes had been updated or something similar, but it would be great if it could be eliminated.

0 Likes

#20

Alright, thanks for confirming that you are seeing this also. I’ll have to do some digging to see what is going on here. Jon is the expert in performance, but based on some issues I’ve seen recently, memory allocations can be one of the biggest factors.

2 Likes

#21

Interestingly the regex cache (data folder Cache/LaTeX/LaTeX.sublime-syntax.rcache) is 9.4MB! The C++ one is 600K.

I think this is probably what I need to investigate. Most likely restoring all of the syntax memory structures from disk is taking a good chunk of time with LaTeX. This seems also to happen with Objective-C++, although to a lesser degree (5MB).

3 Likes

Opening LaTeX files slower than in Version 2.0