Comments (17)
This is a closed issue, so no need for a tag.
Except that it greatly helps people looking for similar issues to their own, which is the entire point of an issue tracker.
from markdown-mode.
I'm sorry for being so harsh. I'm trying to investigate cause of this disaster. Smartparens executes a lot of stuff even when disabled. I'll need to remove it completely together with Flyspell to adequately profile the rest of offending packages. markdown-check-change-for-wiki-link
was quite slow in one test, but now I cannot reliably reproduce it.
from markdown-mode.
Here we go:
- redisplay_internal (C function) 3449 68%
- jit-lock-function 3381 67%
- jit-lock-fontify-now 3381 67%
- jit-lock--run-functions 3381 67%
- run-hook-wrapped 3381 67%
- #<compiled 0xde4caf> 3381 67%
- font-lock-fontify-region 3381 67%
- font-lock-default-fontify-region 3381 67%
+ font-lock-fontify-syntactically-region 3195 63%
- font-lock-fontify-keywords-region 179 3%
+ markdown-match-code 32 0%
+ markdown-match-italic 26 0%
+ markdown-match-bold 25 0%
+ markdown-match-blockquotes 10 0%
markdown-match-hr 7 0%
+ markdown-match-multimarkdown-metadata 6 0%
+ markdown-match-heading-2-setext 3 0%
+ markdown-match-fenced-start-code-block 3 0%
+ markdown-match-pandoc-metadata 3 0%
+ eval 55 1%
file-remote-p 4 0%
+ #<compiled 0x3e3d5f> 3 0%
- ... 1025 20%
Automatic GC 1025 20%
- command-execute 527 10%
- call-interactively 527 10%
- funcall-interactively 527 10%
+ counsel-M-x 425 8%
- self-insert-command 99 1%
+ markdown-check-change-for-wiki-link-after-change 78 1%
+ markdown-gfm-checkbox-after-change-function 14 0%
+ jit-lock-after-change 7 0%
sml/generate-position-help 7 0%
When I hold a key, I can see how characters periodically slow down for GC. This is poor performance anyway — this should not happen and it does not happen in modes with more complicated syntax than markdown. Fontification is slow. When combined with other nasty things, it stops you from normal interaction with editor altogether. Can you imporve this?
from markdown-mode.
Edit: fontification is not slow, it's rather memory-inefficient if you spend 20% if time in GC. In Emacs lisp mode it's 5 % even with some plugins like aggressive indentation.
from markdown-mode.
First, can you confirm that you are using the latest master? Much effort recently has gone towards efficiency. I have done similar profiling and have seen significant improvement since December or so. See for example #30, #42, and #44. For me, the lag while typing now is almost imperceptible in a complicated 5000+ line file.
Due to the complexity, parsing Markdown on the fly as a user edits is neither easy nor fast when compared to a very structured language, like most programming languages, which can use the Emacs syntax table for everything. Multi-line constructs, nesting lists and pre blocks, etc. mean that we have to sometime go back far in the document to determine the context. Recently, I have moved towards caching this context in text properties. That being said, I still care a lot about making markdown-mode as efficient as possible. If you have other suggestions for improvement they are most welcome, especially in the form of patches.
Many people use Markdown when editing wikis, including on GitHub, which is why the wiki features exist. However, I agree that most people do not need this and therefore adding flags to disable checking for wiki links is something I've already planned to do. We need two flags: one to globally disable wiki link fontification, say markdown-fontify-wiki-links
, and a second one which determines whether to check for broken/missing wiki links (only when the former flag is enabled), say markdown-fontify-missing-wiki-links
. Checking for and updating missing wiki links (whether target files were created or removed) is the source of the latency you're seeing.
from markdown-mode.
Yes, I update all packages regularly (every day) from MELPA, so my version of markdown-mode
is up-to-date. Thanks for the answer, I'm looking forward to having these options to disable wiki link fontification.
from markdown-mode.
Please see f8fd642.
from markdown-mode.
Thank you, I will try it.
from markdown-mode.
I'm running markdown-mode (20160722.445) with emacs 24.5.1. There is still good amount of lag even when just moving around with cursor keys or typing anything. Any ways to improve this?
from markdown-mode.
I see the lag was because I was editing a .md file over sshfs. There is no lag when I edit a local .md file. Sorry for false alarm.
from markdown-mode.
I'm on the most recent markdown-mode and still getting significant lag in some markdown-mode buffers when merely typing. Turning off font-lock-mode resolves the issue but this is a suboptimal solution.
from markdown-mode.
Could someone with permission please add the performance
tag to this issue?
from markdown-mode.
This is a closed issue, so no need for a tag. It will help if you open a new issue with a specific problem narrowed down. Try using the profiler, with a test document.
from markdown-mode.
Thanks.
Profiling clearly shows that markdown-mode (specifically markdown-match-code
and markdown-match-bold
) chokes on lines (copied from command-line output) that have dozens of asterisks in a row.
Moving these multi-asterisk lines into code blocks fixed the massive lag, I assume because markdown-mode no longer tried to calculate nested boldings. Issue resolved for now.
from markdown-mode.
Thanks for following up with that. I am planning to add formatted yank commands (e.g., yank as code block) that will make this more efficient.
from markdown-mode.
I have the same issue for a file with a lot (~140) of GFM toggle boxes in a list. This is the report of the profiler:
- redisplay_internal (C function) 4528 84%
- jit-lock-function 4500 83%
- jit-lock-fontify-now 4496 83%
- jit-lock--run-functions 4492 83%
- run-hook-wrapped 4492 83%
- #<compiled 0x2a18acf> 4492 83%
- font-lock-fontify-region 4492 83%
- font-lock-default-fontify-region 4488 83%
- font-lock-fontify-keywords-region 4404 81%
+ markdown-fontify-reference-links 2068 38%
+ markdown-fontify-inline-links 1984 36%
+ markdown-fontify-list-items 140 2%
+ markdown-match-declarative-metadata 36 0%
+ markdown-fontify-plain-uris 28 0%
+ markdown-match-pandoc-metadata 28 0%
+ markdown-match-code 16 0%
+ markdown-fontify-blockquotes 16 0%
+ markdown-match-yaml-metadata-begin 12 0%
+ markdown-match-includes 8 0%
+ markdown-match-yaml-metadata-key 8 0%
+ markdown-match-inline-attributes 8 0%
markdown-match-math-single 4 0%
+ markdown-fontify-sub-superscripts 4 0%
+ markdown-match-gfm-open-code-blocks 4 0%
+ markdown-fontify-angle-uris 4 0%
+ markdown-match-italic 4 0%
+ font-lock-fontify-syntactically-region 32 0%
from markdown-mode.
@libre-man Thanks, the issue with GFM checkboxes should be fixed now (by commit c9955dc).
from markdown-mode.
Related Issues (20)
- Add support for LaTeX enviroments HOT 1
- Markdown mode leads to heavy input lag HOT 11
- [filelink](does not support spaces in filename) HOT 3
- Caret signs inside math are fontified as Markdown markup
- register yank-media-handler so we can paste images HOT 7
- Should filename links be URI-decoded? HOT 1
- Update MacPorts links in README
- tab in lists items results in invalid list indent itemization
- [Feature Suggestion] markdown-beginning/end-of-line functions
- `move-beginning-of-line` move to wrong position on heading when markdown-hide-markup is enabled HOT 1
- preserve indent-tabs-mode in markdown-edit-code-block HOT 5
- Incorrect table alignment with code block HOT 1
- Markdown hiding for links broken when text surrounded by square brackets
- resurrect emacs-26 support? HOT 2
- Bug: Angle-bracketed URLs in inline code are fontified as links
- "_" character in a variable name turns on underline HOT 1
- Wrong gfm-view-mode syntax highlight if only using *-ts-mode (tree-sitter modes) HOT 1
- v2.6 ERT test failures on wiki-link-rules and wiki-link-search-under-project with Emacs 29.1 HOT 4
- R language isn't included in markdown-gfm-recognized-languages HOT 3
- Wrong table width calculation for Unicode Combining Diacritical Marks
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from markdown-mode.