You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment Mark Text using a simple String to represent the document content. When it comes to larger documents, this is very inefficient and result in high CPU and RAM usage because we create many copies from the String.
A solution would be to use a (immutable) data structure with support for snapshots (undo/redo) and better memory management. I don't want to go into the detail, but the explanation from Juan Pedro Bolivar Puente of his talk "Postmodern immutable data structures" or Atom's/vscode's blog post, does indeed. There are already libraries, which we can use like Superstring from the Atom text editor.
Problems
How do we interact with CodeMirror and the virtual HTML DOM stuff. Should we fork/implement this by our own and consider this problem?
Can we "just" change your API to use a different data structure?
Note to self: Atom has written a blog post about integrating Superstring with a virtual DOM.
@fxha Very comprehensive finishing work, I have recently considered refactoring some of the code in muya, such as the new document object model, new data management, which was previously unified into blocks. It will be divided into document object model and data management in the future. This will better support the undo and redo features, and one goal is to support collaborative editing.
How do we interact with CodeMirror and the virtual HTML DOM stuff. Should we fork/implement this by our own and consider this problem?
�I maybe replace CodeMirror with other highlight code library, such as highlight.js and prism. Because CodeMirror has a large size. It is also possible for us to do DOM operations ourselves, so as to avoid repeated rendering.
Can we "just" change your API to use a different data structure?
Maybe it's not that simple. I've also looked at some open source libraries recently to see how they manage state and support collaborative editing. Such as quill, prosemirror and so on.
I haven't dug though the code at all so I'm not sure if these are done already or the feasibility/practicality of any of these recommendations but:
If images are rendered at all times, maybe only rendering them when on screen would help
Adding the option to disable some of the more advanced options (Vega Chart, Flow Chart, Sequence Diagrams) may help
As noted about history, anything with the clipboard is awful, and from the original issue description above, it does sound like this just comes down to the data structure used. You may be able to abuse some things about the data though. For example, it's almost certain that any document large enough to notice a performance impact will be organized by headings, maybe you could split at each header? I'm not sure this is a logical route to take, but I think it's worth considering
Similarly, the data is fundamentally raw text data and working with the MD file directly may be the obvious route, but there's no reason a cache where the file is converted to something more processing friendly couldn't be kept: say in JSON somewhere?
I know that many of these suggestions hit the same issue as described above- a significant refactor is necessary no matter what, even if just switching to a better data structure as originally suggested.
Thanks for all the great work on this project :)
EDIT: just checked the roadmap and saw that it's at the top and already well planned out. Thanks again to everyone working so hard on this!
I am a new user and filed many issues within two days. Today, I edited a file wihch has 1229 lines. I never thought that was a big file because other electron markdown editors have no problem of it. But until now, when I edit it in marktext, marktext just can't handle it. Every single char typing will result in 100% of CPU core. This makes marktext kinda not useable.
I've also looked at some open source libraries recently to see how they manage state and support collaborative editing. Such as quill, prosemirror and so on.
What is the relationship between Mark Text (Muya) and ProseMirror? ProseMirror seems to attempt to provide an elegant and robust solution to many of the low-level problems, such as document tree and revisions, separate from the presentation layer. Might Muya use ProseMirror underneath, in order to avoid separate development of the overlapping functionality? Might such an approach have added benefits (for example, interactivity with others servers using ProseMirror but not necessarily using Muya)?
I did some comparison testing on some large markup file (200kb). Between Typora, Marktext, Joplin, and Zettlr (the later two editing and viewing the rendered markup), Marktext seems to be about in the middle, with Typora really having the best (though still not great) performance. Though these are not apples-to-apples comparisons because they aren't all WYSIWYG editors. Microsoft Word's performance, as a comparison, is near-instant even on much larger files - although it's unknown how they achieve that.
The architectural change requested here has been fully implemented in the new @muyajs/core editor engine (now shipping). The document is no longer represented as a flat string — it is a JSON block tree (TState[]) with all mutations tracked as ot-json1 operational transforms. Undo/redo is backed by op inversion rather than string snapshots, and rendering uses snabbdom virtual DOM diffing. This resolves the core performance and memory concerns raised in 2018. Closing as resolved by the engine migration.
Congrats on the rework! 8 years later is wild to see an issue get closed. I see the repos been using a lot of Claude lately, I take it that's been going well? I'm sorta mixed on AI, but seeing it have the real world impact of assisting FOSS projects in improving performance is really cool.
Activity
Jocs commentedon Oct 17, 2018
@fxha Very comprehensive finishing work, I have recently considered refactoring some of the code in
muya, such as the new document object model, new data management, which was previously unified intoblocks. It will be divided into document object model and data management in the future. This will better support the undo and redo features, and one goal is to support collaborative editing.Jocs commentedon Oct 17, 2018
�I maybe replace CodeMirror with other highlight code library, such as
highlight.jsandprism. Because CodeMirror has a large size. It is also possible for us to do DOM operations ourselves, so as to avoid repeated rendering.Maybe it's not that simple. I've also looked at some open source libraries recently to see how they manage state and support collaborative editing. Such as
quill,prosemirrorand so on.VegaDeftwing commentedon May 24, 2019
Using Marktext 0.14.0-3 -- marktext-bin in the AUR on a very high end system
Wanted to drop by and note that this is actually affecting real world use cases. I'm working on a massive markdown document over at https://github.com/VegaDeftwing/opinionatedeng/blob/master/opinionatedeng.md and hoboy does marktext get laggy, but then again so does everything else. Even just a raw text editor, like VSCode, with syntax highlighting for the markdown just gets bogged down.
I haven't dug though the code at all so I'm not sure if these are done already or the feasibility/practicality of any of these recommendations but:
I know that many of these suggestions hit the same issue as described above- a significant refactor is necessary no matter what, even if just switching to a better data structure as originally suggested.
Thanks for all the great work on this project :)
EDIT: just checked the roadmap and saw that it's at the top and already well planned out. Thanks again to everyone working so hard on this!
sgon00 commentedon May 29, 2020
I am a new user and filed many issues within two days. Today, I edited a file wihch has 1229 lines. I never thought that was a big file because other electron markdown editors have no problem of it. But until now, when I edit it in marktext, marktext just can't handle it. Every single char typing will result in 100% of CPU core. This makes marktext kinda not useable.
brainchild0 commentedon Jun 16, 2020
What is the relationship between Mark Text (Muya) and ProseMirror? ProseMirror seems to attempt to provide an elegant and robust solution to many of the low-level problems, such as document tree and revisions, separate from the presentation layer. Might Muya use ProseMirror underneath, in order to avoid separate development of the overlapping functionality? Might such an approach have added benefits (for example, interactivity with others servers using ProseMirror but not necessarily using Muya)?
tmairegasnighto commentedon Nov 29, 2020
I did some comparison testing on some large markup file (200kb). Between Typora, Marktext, Joplin, and Zettlr (the later two editing and viewing the rendered markup), Marktext seems to be about in the middle, with Typora really having the best (though still not great) performance. Though these are not apples-to-apples comparisons because they aren't all WYSIWYG editors. Microsoft Word's performance, as a comparison, is near-instant even on much larger files - although it's unknown how they achieve that.
bigshans commentedon May 18, 2022
Source Code Mode is much slower than WYSIWYG mode.
kud commentedon Apr 17, 2023
Mark Text is quite slow/not smooth, I don't know why, and I'm currently using a M1 cpu. It's the only app which is not smooth like that.
Could be great to improve performance. Let me know if I can help. Thanks.
Jocs commentedon Jun 26, 2026
The architectural change requested here has been fully implemented in the new @muyajs/core editor engine (now shipping). The document is no longer represented as a flat string — it is a JSON block tree (TState[]) with all mutations tracked as ot-json1 operational transforms. Undo/redo is backed by op inversion rather than string snapshots, and rendering uses snabbdom virtual DOM diffing. This resolves the core performance and memory concerns raised in 2018. Closing as resolved by the engine migration.
VegaDeftwing commentedon Jun 26, 2026
Congrats on the rework! 8 years later is wild to see an issue get closed. I see the repos been using a lot of Claude lately, I take it that's been going well? I'm sorta mixed on AI, but seeing it have the real world impact of assisting FOSS projects in improving performance is really cool.