Repository navigation
Albert load workflow opt - #1398
Conversation
...by freezing joint paper until all updates are complete, skipping unnecesarry rendering
...by batching the addition of new operators with one addcells() / resetcells() call
515c7a8 to
b393f1b
Compare
|
I've had to compromise on some things:
|
| } | ||
|
|
||
| return ContextManager; | ||
| } No newline at end of file |
There was a problem hiding this comment.
ContextManager is my attempt to bring python's context managers to typescript. It can be used to:
- bind and release resources reliably
- act as *global state*, but only controlled from one place in the code. Using withContext, you can execute a function with some context, and any resulting function call in the stack can be aware of that context.
This was originally introduced right before I figured out async mode was a toggle-able option
My idea was to set the paper to async permanently, and create a sync/async boolean context.
for every function that changes the jointpaper, check if they're called in an async context, and if not, manually sync the jointpaper to emulate the behavior of sychronous mode.
zuozhiw
left a comment
There was a problem hiding this comment.
Looks good! I made some minor changes and we can merge it.
I tested it on the production server and the loading time of large workflows reduce from ~3 seconds to 1 second on my machine.
|
I found a bug when merging this part into #1427 and found it exists in master: when reloading a workflow, all the links will appear to have breakpoints (when actually they do not). Hovering on the "!" will make the icon disappear though. |
|
Seems this PR breaks the version preview as it depends on the |
# Continuation of #1398 # The bug: There is an event listener responsible for adding the link breakpoint button to all links: ``` getJointLinkCellAddStream().subscribe(link => { const linkView = link.findView(this.getJointPaper()); ... linkView.hideTools(); // hides breakpoint icon }); ``` In async mode, the link cell is added to the graph but not drawn to the webpage (This avoids an expensive DOM reflow) Since it's not drawn to the webpage, hideTools doesn't work right (for reasons unknown, it fails silently) # The solution: We can't draw the link cells: the whole point is to avoid DOM reflows Instead, we modify the event stream getJointLinkCellAddStream() to buffer its events while the jointgraph is in async mode and emit them all at once afterwards. I adapted the method from https://kddsky.medium.com/pauseable-observables-in-rxjs-58ce2b8c7dfd (02/06/22) ``` merge( source$.pipe( bufferToggle(off$, ()=>on$) ), source$.pipe( windowToggle(on$, ()=>off$) ) ).pipe( // then flatten buffer arrays and window Observables flatMap(x => x) ) ``` bufferToggle starts buffering on **_off$_**, and emits on **_on$_** windowToggle starts emitting on **_on$_** and stops emitting on **_off$_** P.S. https://kddsky.medium.com/pauseable-observables-in-rxjs-58ce2b8c7dfd (02/06/22) this article had another cool trick for rate-limiting for bursty events Co-authored-by: zuozhiw <[email protected]>
# Continuation of apache#1398 # The bug: There is an event listener responsible for adding the link breakpoint button to all links: ``` getJointLinkCellAddStream().subscribe(link => { const linkView = link.findView(this.getJointPaper()); ... linkView.hideTools(); // hides breakpoint icon }); ``` In async mode, the link cell is added to the graph but not drawn to the webpage (This avoids an expensive DOM reflow) Since it's not drawn to the webpage, hideTools doesn't work right (for reasons unknown, it fails silently) # The solution: We can't draw the link cells: the whole point is to avoid DOM reflows Instead, we modify the event stream getJointLinkCellAddStream() to buffer its events while the jointgraph is in async mode and emit them all at once afterwards. I adapted the method from https://kddsky.medium.com/pauseable-observables-in-rxjs-58ce2b8c7dfd (02/06/22) ``` merge( source$.pipe( bufferToggle(off$, ()=>on$) ), source$.pipe( windowToggle(on$, ()=>off$) ) ).pipe( // then flatten buffer arrays and window Observables flatMap(x => x) ) ``` bufferToggle starts buffering on **_off$_**, and emits on **_on$_** windowToggle starts emitting on **_on$_** and stops emitting on **_off$_** P.S. https://kddsky.medium.com/pauseable-observables-in-rxjs-58ce2b8c7dfd (02/06/22) this article had another cool trick for rate-limiting for bursty events Co-authored-by: zuozhiw <[email protected]>

Some quick fixes to improve page load times for large workflows by ~ 1/2. Specifically reduces time spent rendering the page.
Changes:
Results:
Before:
async freeze/unfreeze
async + addCells()