-
Notifications
You must be signed in to change notification settings - Fork 125
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
Fix puml
not syncing Resolve #1617
#2345
Conversation
The performance hit from The fix needs to be more involved #1617 (comment). |
I have an alternative solution using the lock file. Not sure if this could fix the issue. |
@SPWwj is there a real need to implement it as a lock file? Can we do it in memory? Also pls update your PR description |
Yes, a similar idea would be to use a singleton class instead of files for this lock service. Another way is to use Vue components. Alternatively, we could make |
pros & cons? rationale behind your decision? could you elaborate to aid review plz |
The first option (singleton) is recommended as it does not affect the current project structure and provides a way to support asynchronous operations. |
packages/core/test/unit/plugins/default/_plantuml/a31b4068deea63d65d1259b4d54bcc79.png
Outdated
Show resolved
Hide resolved
Sounds like a plan. What about performance (time, and maybe cpu/memory?) before and after introducing this change? How much longer(or shorter or no diff) would it take, especially for sites with a lot of puml diagrams? |
I don't expect much performance difference as the lock service does not change the current implementation. The only thing it does is to wait for all asynchronous operations to complete, much like a The compiling time may slightly increase after applying this lockfile, due to PlantUML is able to finish generating the file, just like in the test case mentioned above. |
Sure, have some numbers when you are done so that we can make a fair judgment 👍 |
Good idea. Use a decent number of puml diagram in the test case. |
@damithc @tlyltI have updated the PR description to include some test statistics. |
@SPWwj is this ready for review? There's still a merge conflict |
Fixed merged conflict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @SPWwj, looks mostly good on my end, thank you for your quick response. Have one more concern as I read through the diagram status tracking code:
- Could you add in comments to explain the functions? the definition of "dead" and "alive" weren't as clear. I initially thought you meant "stale" and "fresh", but the logic doesn't add up.
- Could you illustrate the flow of events for the typical cases:
- on first generation, what happens? (especially the state of processedDiagrams)
- after edit of a puml file, what happens? (especially the state of processedDiagrams)
- after edit of a non puml file, what happens? (especially the state of processedDiagrams)
I'm not sure whether processedDiagrams is working as advertised. Clarification from your end would help!
On first generation, all the diagrams will be added to the map, and whenever a diagram is generated, |
Yes, it will be removed in a future update.
Yes answered above
Yes
We can add a feature here to remove diagrams. |
I see, thank you for that! I adjusted the comments slightly as well as code (made unlink sync). For inline use of
seems alright now, the only issue is the delayed deletion of the stale diagrams. Could be improved in the future but ok for now. For use of
(On initial markbind serve, the _site images are present) (After double save, only the first diagram remains, hence resulting in error) @SPWwj could you investigate this, please? |
The hot reload scans only the PUML diagram on the modified page, causing diagrams on other non-modified pages to become stale. Currently, there's no good solution, as there's no way to identify inline PUML. Every change to Since this is for production, one option is to clean up the PUML diagrams in the directory on |
Does making the plantuml status tracking hashmap persist through site rebuild help to fix the issue? Either somehow make it global or write to file |
The issue won't be resolved, as we have no way to identify and remove the inline PUML diagram tracker from the tracking list. This is because there's no common identifier for the inline PUML diagram, unlike the .puml file where we can use the filename as an identifier. One solution is to remove the diagram during the initial load with 'Markbind serve'. This ensures that our tracker list only captures the required diagrams. |
Hey @SPWwj could you help me understand your replies further?
Aren't we currently making the identifier depend on both the output file path and the puml content, meaning every change to any PUML diagram will generate a new diagram without a common identifier to the stale diagram? This includes both inline and file puml diagrams?
"what" is for production? What do you mean by "production" here?
Do you mean we now ONLY remove the diagram during the initial load with "markbind serve", and stop removing the diagrams afterwards? I think that is a viable solution. |
The goal is to remove unused, outdated diagrams. Here's the relevant code snippet: If
If node.attribs.name is missing, the old diagram can't be removed or replaced by a new one,
When the site is ready to be deployed and go live.
Yes, because during the implementation of the website, I don't think there's a need to worry about deleting unused diagrams while editing PUML source code. This will also improve the undo operation during PUML code editing. |
Hmm, now it reminds me that we should ensure that our solution works for the case where the user edits the plantuml files without running
Sure, sounds like a plan 👍.
|
@tlylt Actually, I just realized that MarkBind already takes care of deleting redundant files during build time. Thus, there's no need to worry about accumulating and occupying disk space. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @SPWwj, LGTM 🚀
I updated the relevant docs to:
- use the
<puml src="...puml">
directly in our UG - remove the generated diagrams since they will be generated on the fly
- update instructions in DG regarding puml files in UG
- add a note on duplicated names may result in invalid output
And finally some minor refactoring/adjusting comments.
What is the purpose of this pull request?
Overview of changes:
Resolve #1617
By introducing a lock service to wait for asynchronous functions to complete:
Fix the issue where all distinct PUML diagrams were being reprocessed on every hot reload by introducing a hashmap tracker to keep track of the diagrams.
Anything you'd like to highlight/discuss:
Performance Analysis:
The implementation of the lock service has minimal impact on PUML processing performance.
Testing was conducted on 70 PUML diagrams:
Original Configuration (without lock service)
- o
- d
Singleton Implementation
-o
Initial Performance Statistics:
-d
Initial Performance Statistics:
These results indicate that the lock service does not significantly affect PUML processing performance.
In fact, it greatly reduces the CPU computation on every hot reload, leading to a more efficient processing system.
Testing instructions:
markbind init
.markbind serve -o
.Proposed commit message: (wrap lines at 72 characters)
Introduce LockManager for Async Handling and Optimize PUML Diagrams
Introduce the LockManager module to manage the lifecycle of asynchronous
functions, ensuring robust and consistent handling within synchronous
methods.
Utilize the createLock, deleteLock, and waitForLockRelease methods for
starting, stopping, and waiting for async functions respectively.
Code snippet:
Fix the issue where all distinct PUML diagrams were being reprocessed on
every hot reload by introducing a hashmap tracker.
`cleanDiagrams(processedDiagrams)`.
By implementing these changes, the code is made more maintainable,
asynchronous functions are properly managed, and PUML diagram processing
is optimized.
Checklist: ☑️