Skip to content
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

Right panel perf #604

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

will-moore
Copy link
Member

@will-moore will-moore commented Jan 17, 2025

Improves performance of loading right panel for single Objects (Project, Dataset, Image, Screen, Plate, Well, PlateAcquisition)

I looked into the timing for getObject() with group: -1 and found that is slower when the user is logged-in to a large group (even if that group is private).

E.g. about 1 second in the code below.

It's actually faster to:

  • perform a preliminary queryService.get() to get the object, get it's group ID...
  • and then use that group ID for getObject()
  • These 2 queries take about 0.02 seconds in the code below.
import argparse
import sys
from datetime import datetime

from omero.cli import cli_login
from omero.gateway import BlitzGateway

def main(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument('dataset', type=int, help='Dataset ID')
    args = parser.parse_args(argv)

    with cli_login() as cli:
        conn = BlitzGateway(client_obj=cli._client)
        dataset_id = args.dataset
        for test in range(10):
            start = datetime.now()
            if test % 2 == 0:
                # Use group: -1 via get(), then set group for conn.getObject()
                group_id = conn.getQueryService().get("Dataset", dataset_id, {'group': '-1'}).details.group.id.val
            else:
                group_id = -1
            conn.SERVICE_OPTS.setOmeroGroup(group_id,)
            dataset = conn.getObject("Dataset", dataset_id)
            print(datetime.now() - start, "group_id", group_id)

if __name__ == '__main__':
    main(sys.argv[1:])

prints:

0:00:00.031096 group_id 2
0:00:01.097150 group_id -1
0:00:00.028419 group_id 2
0:00:00.999497 group_id -1
0:00:00.019667 group_id 2
0:00:01.045434 group_id -1
0:00:00.021599 group_id 2
0:00:01.070055 group_id -1
0:00:00.023816 group_id 2
0:00:00.942411 group_id -1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant