question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mark Text performance improvement

See original GitHub issue

Description

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.

Existing implementations

References

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:16
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
VegaDeftwingcommented, 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:

  • 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!

0reactions
bigshanscommented, May 18, 2022

Source Code Mode is much slower than WYSIWYG mode.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Reproducibility Concern about Image-Text Retrieval
According to their assertions, these techniques provide improved modality interactions and hence more precise multimodal representations. In ...
Read more >
Enforce Performance Improvement Plan Mark | signNow
Check out how easily the enforce Performance Improvement Plan mark feature ... Open a sample document to add a signature, date, text, upload...
Read more >
Performance improvement while querying TEXT column
Performance improvement while querying TEXT column. Hello, I have a table 'Document' with a TEXT column, say DocumentBody. The column has huge data....
Read more >
Improve the Performance of Full-Text Indexes - SQL Server
If re-routing occurs frequently, it results in performance degradation of the full-text indexing process. To work around this problem, mark the ...
Read more >
how to improve performance | SAP Community
I have the following code snippet: *fetch data from table using select *now for each record, get the text using read_text loop on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found