Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize startup time #1427

Closed
Eucyon opened this issue Dec 20, 2019 · 9 comments
Closed

Optimize startup time #1427

Eucyon opened this issue Dec 20, 2019 · 9 comments

Comments

@Eucyon
Copy link

Eucyon commented Dec 20, 2019

Description of the problem or steps to reproduce

$ time micro 

real	0m0,587s
user	0m0,087s
sys	0m0,020s
$ time nano

real	0m1,735s
user	0m0,004s
sys	0m0,003s
$ time tilde 

real	0m0,798s
user	0m0,017s
sys	0m0,006s

Commit hash: 1856891
OS: Arch
Terminal: lxterminal

zyedidia added a commit that referenced this issue Dec 25, 2019
The code from the refactor that I have been working on is
now more or less ready to be merged. These changes make some
breaking changes, notably with regards to the plugin
interface. Once a lot more documentation has been written, I
will release this code as micro 2.0. There are a lot of new
features, and in the coming days I will try to go through
the open issues to see exactly which ones are addressed by
the new features, and write lots more documentation
regarding what has been implemented.

Some highlights include:

* Simple autocompletion.
    * Autocompletion (tab by default) will do a simple
      "buffer completion" which will autocomplete according
      to words used elsewhere in the buffer. In the future
      plugin support could be added along with support for
      interfacing with language-specific autocompletion
      tools.
* Automatic backups.
    * Backup files are stored in `~/.config/micro/backups`
      for every open buffer and are saved roughly every 8
      seconds if the buffer is being modified. Backups
      are removed when the buffer is closed, but if micro
      or the system crashes, any unsaved changes can be
      recovered by re-opening the file (micro will auto-
      recover) or by manually viewing the backup in the
      `~/.config/micro/backups` directory.
* Configurable statusline.
* Configurable linter plugin.
* Resizeable splits.
* Complete re-organization of the code to support better go
  modules and maintain a better directory structure.
* Better plugin interface with better access to the Go
  standard library and internal Micro functions (lots of
  documentation still needs to be written).
    * Documentation still needs to be written, but in the
      meantime please see the default plugins as examples
      as they have been converted from their old versions
      to be compatible with the new interface.
* Buffer synchronization when the same file is opened
  multiple times.
* Keybindings and mouse support in the command bar.
* Support for non-utf8 encodings.
* General QoL improvements and bug fixes.
    * Notably I believe the autoclose plugin crash issue is
      fixed.
* No more plugin manager.
    * Plugin installation will now be performed manually
      by git cloning into the `~/.config/micro/plug`
      directory. This may not be a highlight for some but
      I believe it is much simpler, and there is no need
      to have a heavyweight dependency manager. Perhaps
      in the future, a good command-line tool can be made
      to manage plugins if people would find it useful.
* Other features that I have forgotten.

Next I plan to write up more documentation for all the new
features, and make a "release candidate" for micro 2.0. I
will also be working to fix any bugs that come up (hopefully
not too many, but this is a big change and bound to have
some issues). After release I hope to focus more on
optimization (for example loading syntax files is currently
somewhat inefficient, and the bottleneck for startup time #1427).

Sorry for not being so active recently, but I hope merging
this big change can help me get back to more regular
development. Thanks to everyone for using micro and for
giving feedback and engaging with development online (even
if I don't always respond).

Merry Christmas!

Issues that are fixed/affected by this change:

Ref #1419 (configurable statusline)
Ref #1413 (cursor behaves better)
Ref #1401 (softwrap problems)
Ref #1383 (better save with sudo)
Ref #1424 (better save with sudo)
Ref #1382 (go modules)
Ref #1381 (install plugins from command line)
Ref #1357 (sorting -- textfilter)
Ref #1351 (custom linting)
Ref #1350 (sudo problem might be fixed)
Ref #1298 (readonly option)
Ref #1250 (autoclose bug)
Ref #1239 (go modules)
Ref #813  (autoclose bug)
Ref #812  (cursor sync across same buffers)
Ref #770  (resizeable panes)
Ref #635  (keybindings in infobar)
Ref #596  (disable builtin plugins)
Ref #550  (backups)
Ref #174  (autocompletion)
zyedidia added a commit that referenced this issue Dec 29, 2019
This change introduces header files for syntax files. The header
files only contain the filetype and detection info and can be
parsed much faster than parsing a full yaml file. To determine
which filetype a file is, only scanning the headers is necessary
and afterwards only one yaml file needs to be parsed. Use the
make_headers.go file to generate the header files. Micro expects
that all default syntax files will have header files and that
custom user syntax files may or may not have them. Resolving
includes within syntax has not yet been implemented. This
optimization improves startup time.

Ref #1427
@zyedidia
Copy link
Owner

zyedidia commented Jan 1, 2020

The startup time is better now, although it was hardly noticeable in the first place. Tilde and nano are still faster, but micro is faster than vim (marginally) and emacs so I'm happy. The bottleneck is the large number of syntax files that must be loaded at startup to check the filetype of the buffer. Also keep in mind that the user number measures cpu time on all cores.

@zyedidia zyedidia closed this as completed Jan 1, 2020
@Eucyon
Copy link
Author

Eucyon commented Jan 1, 2020

Happy new year!

I suspected that the reason was the syntax files. It is indeed faster now, thank you.

In most cases, I don't need syntax highlighting. However, setting the syntax option to false seems to have no consequence.

@zyedidia
Copy link
Owner

zyedidia commented Jan 1, 2020

Yes even if syntax highlighting is disabled it still uses the syntax files to determine the filetype which can still be useful.

@Eucyon
Copy link
Author

Eucyon commented Jan 1, 2020

Is it possible to turn that off, maybe with an option?

@zyedidia
Copy link
Owner

zyedidia commented Jan 2, 2020

In theory yes. I'm not sure I really see the use-case for shaving a few milliseconds off the startup time though. Such an option could also disable plugins, which I presume you would also like to disable in favor of startup time?

@dullbananas
Copy link
Contributor

It is important for Micro to be environmentally friendly

@Eucyon
Copy link
Author

Eucyon commented Jan 2, 2020

I personally don't need syntax highlighting. I need the usual keybindings, a search and the cursor position stored when quitting. I like it when an application starts quickly.

But I would of course respect if you said this would change micro too drastically.

zyedidia added a commit that referenced this issue Jan 3, 2020
@zyedidia
Copy link
Owner

zyedidia commented Jan 3, 2020

You can set the filetype to off now to disable filetype detection completely (set it back to the default of unknown to re-enable). You can consider also disabling the various plugins that come with micro, which might further improve the startup time.

@Eucyon
Copy link
Author

Eucyon commented Jan 3, 2020

The overall startup time is much better now, especially when a file is opened and not only micro started empty. Thank you!

However, I didn't notice a speed difference between setting filetype=unknown and filetype=off.

But for me it's fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants