cylc / cylc-uiserver

A Jupyter Server extension that serves the cylc-ui web application for monitoring and controlling Cylc workflows.
https://cylc.org
GNU General Public License v3.0
15 stars 18 forks source link

efficiency: investigate bottleneck #547

Open oliver-sanders opened 9 months ago

oliver-sanders commented 9 months ago

See also: https://github.com/cylc/cylc-ui/issues/1614

This workflow has proven to be remarkably difficult for the UIS & UI to handle:

#!Jinja2

{% set members = 10 %}
{% set hours = 100 %}

[scheduler]
    allow implicit tasks = True

[task parameters]
    member = 0..{{members}}
    fcsthr = 0..{{hours}}
  [[templates]]
    member = member%(member)03d
    fcsthr = _fcsthr%(fcsthr)03d

[scheduling]
  initial cycle point = 2000
  runahead limit = P3
  [[xtriggers]]
    start = wall_clock(offset=PT7H15M)
  [[graph]]
    T00,T06,T12,T18 = """
        @start & prune[-PT6H]:finish => prune & purge
        @start => sniffer:ready_<member,fcsthr> => <member,fcsthr>_process? => finish
        <member,fcsthr>_process:fail? => fault
      """

[runtime]
    [[sniffer]]
        [[[outputs]]]
{% for member in range(0, members + 1) %}
    {% for hour in range(0, hours + 1) %}
            ready_member{{ member | pad(3, 0) }}_fcsthr{{ hour | pad(3, 0) }} = {{ member }}{{ hour }}
    {% endfor %}
{% endfor %}

For more information see: https://cylc.discourse.group/t/slow-load-of-cylc-workflows-disconnects/823/19

Investigation so far has confirmed:

This issue focuses on the UIS side of things.

Suggested remediation (Flow/UIS only, please update with new suggestions):

oliver-sanders commented 9 months ago

Early investigations using https://github.com/cylc/cylc-uiserver/pull/546:

dwsutherland commented 7 months ago

The promise is gone when I get around to (hopefully soon) upgrading Graphene, and rewriting our own graphql-ws (as this uses promises too) .. It appears, promise was created by the original developer of Graphene who (I assume) also (in addition to async support) found it a useful way of translating graphql libraries of javascript to python equivalent (could be wrong)..

dwsutherland commented 7 months ago

The other thing we do is recursively sift through the GraphQL query result (in the middleware) and strip out all the null fields... Not exactly sure how expensive this is.. Think I use the promise library for this.

hjoliver commented 7 months ago

to_snake_case

This simple method gets hammered (10's of thousands of calls).

Sorry if I've missed relevant discussions elsewhere (just back from leave) - but can we just rename all affected variables using JS conventions? It'll look ugly in a Python program, but the payoff sounds big.

oliver-sanders commented 7 months ago

We could, but it would be easier to just cache the output of the method or re-write the code so that method doesn't get hammered, there's a separate issue for this in cylc-flow.