saqimtiaz / streams

TiddlyWiki plugin for rapid data entry with a keyboard driven workflow. Divide content into smaller tiddlers as you write.
BSD 3-Clause "New" or "Revised" License
58 stars 6 forks source link

Performance issues for larger trees #8

Closed MeneDev closed 3 years ago

MeneDev commented 3 years ago

Thanks for the great work! I noticed that editing in a larger tree is pretty slow making typing sluggish. It would be great if the editing behaviour could be changed so that the edits are only applied after a few seconds of inactivity or when the editor is closed?

saqimtiaz commented 3 years ago

@MeneDev I'm aware of the issue but only in really really large trees like: https://saqimtiaz.github.io/sq-tw/streams-tiddlytoolmap.html

As mentioned on the Roadmap, the plan is to eventually use something similar to the draft mechanism the core uses to avoid this issue. However that wont be for a while until I have the time to dedicate to what will be a pretty extensive refactoring.

For now your best option would to open a part of the subtree and close the main tree when editing. Or if you are willing to tweak and experiment a bit, you could try setting the nodes to have the field: throttle.refresh See https://tiddlywiki.com/#RefreshThrottling

Another option is to collapse parts of the tree that are not in use. A "collapse all" feature would be useful here and is planned, but there is no specific timeline for when I might be able to work on that.

MeneDev commented 3 years ago

Thanks, wasn't aware of those tw features. I dug a bit deeper and the main performance issue seems to be the styleRefresh which is currently applied with each keystroke, even if I set throttle.refresh. For testing I set $:/config/Drafts/TypingTimeout to 2000, yet the style changes are applied immediately. It's happening in $:/core/modules/startup/render.js:51. I'll try to investigate further.

saqimtiaz commented 3 years ago

@MeneDev could you please confirm if styleRefresh() is also called with every keystroke in an empty TiddlyWiki with no plugins, when typing in a tiddler?

MeneDev commented 3 years ago

No, I did some changes and that improved performance massively: I have Stroll installed, the backreferences were reevaluated when typing, I removed that part of Stroll, I also disabled all other plugins. One surprising finding: using the Vanilla theme with enabled Sticky titles causes [[200]subtract<currentTiddler>] (in wiki/tiddlers/$__themes_tiddlywiki_vanilla.json) to be reevaluated. Adding a single character increases the counter by exactly 300 invocations.

saqimtiaz commented 3 years ago

No, I did some changes and that improved performance massively:

That is good to hear. I had been rather surprised that you were having such significant performance issues. I have some further performance optimizations planned for after the release of TiddlyWiki 5.1.23

One surprising finding: using the Vanilla theme with enabled Sticky titles causes [[200]subtract<currentTiddler>] (in wiki/tiddlers/$__themes_tiddlywiki_vanilla.json) to be reevaluated. Adding a single character increases the counter by exactly 300 invocations.

Oh wow. If that happens without any plugins, I highly recommend reporting an issue at https://github.com/Jermolene/TiddlyWiki5

saqimtiaz commented 3 years ago

PS: I am going to leave this issue open for now until I've had a chance to work on the planned performance optimizations.

saqimtiaz commented 3 years ago

In Streams 0.2 (still in preview, code in performance branch), rendering time for very large streams is reduced by over 3 fold.

You can compare the rendering time for the tiddler "TiddlyWiki Toolmap" on the old version versus the new one.

There should be significant refresh performance improvements as well.

saqimtiaz commented 3 years ago

Streams 0.21 is now available and has significant performance improvements. Let me know if you still have any issues with performance.

pmario commented 3 years ago

One surprising finding: using the Vanilla theme with enabled Sticky titles causes [[200]subtract<currentTiddler>] (in wiki/tiddlers/$__themes_tiddlywiki_vanilla.json) to be reevaluated. Adding a single character increases the counter by exactly 300 invocations.

Oh wow. If that happens without any plugins, I highly recommend reporting an issue at https://github.com/Jermolene/TiddlyWiki5

I know, where this comes from. It's how the "sticky titles" CSS is created. It uses z-index.

It's the dynamic CSS creation in $:/themes/tiddlywiki/vanilla/sticky ... May be we should "hardcode" those settings in the tiddler