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

[24.1] Paginate tabular datasets in tables to load invocation reports quicker #19470

Conversation

ahmedhamidawan
Copy link
Member

@ahmedhamidawan ahmedhamidawan commented Jan 28, 2025

Tries to improve performance of invocations reports as reported in #19439

The b-table was crashing the browser tab for tabular datasets with many rows. Using b-pagination here to fix that. We were also making a call to fetch datatypes for each dataset in the invocation report. Now we use the store.
Viewing reports is faster now.

use_datatypes_mapper_composable_in_reports_2.mp4

@guerler 's upcoming work on reports in Overhaul Workflow Reports and Pages #19452 could refactor this so that the useDatatypesMapper composable is called from within the HistoryDatasetDetails instead of using the store like I did here?

Note: Targeting 24.1 because the invocation view was introduced then and users clicking on reports can get their whole tab frozen because of this...

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

@mvdbeek
Copy link
Member

mvdbeek commented Jan 28, 2025

Fixes #19439

definitely not :). The chrome tab runs out of memory, that's never gonna happen just for datatypes.

Copy link
Member

@mvdbeek mvdbeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a nice change, but it doesn't fix the bug. Can you target dev ?

@ahmedhamidawan ahmedhamidawan changed the base branch from release_24.1 to dev January 28, 2025 15:06
@ahmedhamidawan ahmedhamidawan changed the title [24.1] Use datatypes mapper composable to load invocation reports quicker Use datatypes mapper composable to load invocation reports quicker Jan 28, 2025
@ahmedhamidawan
Copy link
Member Author

@mvdbeek

definitely not :). The chrome tab runs out of memory, that's never gonna happen just for datatypes.

Hmm interesting, the performance is definitely improved as the tab doesn't freeze anymore.

That's a nice change, but it doesn't fix the bug. Can you target dev ?

The reason I wanted to target 24.1 or still even 24.2 was mentioned in the PR description:

Targeting 24.1 because the invocation view was introduced then and users clicking on reports can get their whole tab frozen because of this..

This improved the UX at least, even if it doesn't fix the bug entirely

@mvdbeek
Copy link
Member

mvdbeek commented Jan 28, 2025

Have you tested this with https://test.galaxyproject.org/workflows/invocations/81483e7017833431 ?
Yes, we fetch datatypes_and_mapping 5 times, but that's done very quickly. It seems to me that rendering the preview for GCA_900093555.2_GCA_900093555.augustus.gtf.gz is the culprit. I can remove this and it loads immediately. I have a hard time seeing how this could improve the situation.

@ahmedhamidawan
Copy link
Member Author

This is https://test.galaxyproject.org/workflows/invocations/81483e7017833431 on local dev server on this same branch:

use_datatypes_mapper_composable_in_reports.mp4

The page doesnt crash anymore

@mvdbeek
Copy link
Member

mvdbeek commented Jan 28, 2025

Well, this is weird. I tried your branch with yarn run develop pointing against test, and yes, that fixes it. However, why does replacing the gtf.gz dataset with something else fix this as well ? It just seems really weird that making something that is a fast operation 5 times faster. That goes against my entire experience of optimizing code 😆

Anyway, you were right, we should target 24.1

@ahmedhamidawan
Copy link
Member Author

I think the reason removing that fixes it is because that is the HistoryDatasetDisplay component that uses the datatypesMapper, and I've moved the mapper to the parent fixing this.

@mvdbeek
Copy link
Member

mvdbeek commented Jan 28, 2025

OK, so one difference is that the multiqc report renders as text instead of html, which I think is a bug. I think we're getting closer to the reason why this is so much faster .. it might be that the composable only fetches the datatypes that can be uploaded, which is a smaller subset. Then we make different decisions based on what we determine the datatype to be.

@ahmedhamidawan ahmedhamidawan changed the title Use datatypes mapper composable to load invocation reports quicker [24.1] Use datatypes mapper composable to load invocation reports quicker Jan 28, 2025
@ahmedhamidawan ahmedhamidawan changed the base branch from dev to release_24.1 January 28, 2025 16:56
@mvdbeek
Copy link
Member

mvdbeek commented Jan 28, 2025

diff --git a/client/src/components/Markdown/Elements/HistoryDatasetDisplay.vue b/client/src/components/Markdown/Elements/HistoryDatasetDisplay.vue
index e9cae99042..9f324a459f 100644
--- a/client/src/components/Markdown/Elements/HistoryDatasetDisplay.vue
+++ b/client/src/components/Markdown/Elements/HistoryDatasetDisplay.vue
@@ -60,15 +60,15 @@
                 <div v-else-if="error">{{ error }}</div>
                 <div v-else :class="contentClass">
                     <b-embed
-                        v-if="datatypesMapper?.isSubTypeOfAny(datasetType, ['pdf', 'html'])"
+                        v-if="datatypesMapper.isSubTypeOfAny(datasetType, ['pdf', 'html'])"
                         type="iframe"
                         aspect="16by9"
                         :src="displayUrl" />
                     <HistoryDatasetAsImage
-                        v-else-if="datatypesMapper?.isSubTypeOfAny(datasetType, ['galaxy.datatypes.images.Image'])"
+                        v-else-if="datatypesMapper.isSubTypeOfAny(datasetType, ['galaxy.datatypes.images.Image'])"
                         :args="args" />
                     <div v-else-if="itemContent.item_data">
-                        <div v-if="datatypesMapper?.isSubTypeOfAny(datasetType, ['tabular'])">
+                        <div v-if="datatypesMapper.isSubTypeOfAny(datasetType, ['tabular'])">
                             <UrlDataProvider
                                 v-slot="{ result: metaData, loading: metaLoading, error: metaError }"
                                 :url="metaUrl">
diff --git a/client/src/components/Markdown/MarkdownContainer.vue b/client/src/components/Markdown/MarkdownContainer.vue
index 7d9238824f..764203c8a8 100644
--- a/client/src/components/Markdown/MarkdownContainer.vue
+++ b/client/src/components/Markdown/MarkdownContainer.vue
@@ -179,7 +179,9 @@ function argToBoolean(args, name, booleanDefault) {
                 v-else-if="['history_dataset_embedded', 'history_dataset_display'].includes(name)"
                 :args="args"
                 :datasets="datasets"
-                :embedded="name == 'history_dataset_embedded'" />
+                :embedded="name == 'history_dataset_embedded'"
+                :datatypes-mapper="datatypesMapper"
+                :datatypes-loading="datatypesMapperLoading" />
             <HistoryDatasetDetails
                 v-else-if="
                     [

that'll cause this to crash as it did before.

@mvdbeek
Copy link
Member

mvdbeek commented Jan 28, 2025

https://github.com/ahmedhamidawan/galaxy/blob/use_datatypes_mapper_composable_in_reports/client/src/components/Markdown/Elements/HistoryDatasetDisplay.vue#L77-L82 might not be performant enough to render large tables. It might help to remove reactivity with Object.freeze ?

@mvdbeek
Copy link
Member

mvdbeek commented Jan 28, 2025

might not be performant enough to render large tables. I

I think it's actually b-table that can't deal with so many rows. slicing to 200 is an easy fix, but maybe we need a more performant table component.

@mvdbeek
Copy link
Member

mvdbeek commented Jan 28, 2025

#19322 could be an option

@ahmedhamidawan
Copy link
Member Author

Should we Object.freeze for this bugfix then?

And then as @guerler refactors and modernizes reports etc, we can replace the BTable with the AG Grid thing?

@ahmedhamidawan ahmedhamidawan marked this pull request as draft January 28, 2025 17:38
@ahmedhamidawan
Copy link
Member Author

ahmedhamidawan commented Jan 28, 2025

Actually, the datatypesMapper is never being used in this component now (it is always undefined/null).

When I use the composable directly in the component instead of passing it as a prop, we have the same bug again of freezing for some time, until we actually show the table.

You are right, the table is the culprit

@mvdbeek
Copy link
Member

mvdbeek commented Jan 28, 2025

Actually, the datatypesMapper is never being used in this component now (it is always undefined/null).

See #19470 (comment) which I think you should apply

the table is the culprit

b-table has pagination (https://bootstrap-vue.org/docs/components/table#pagination), maybe that could be a fix that won't be too intrusive ?

@ahmedhamidawan ahmedhamidawan force-pushed the use_datatypes_mapper_composable_in_reports branch from d788c33 to 93a4302 Compare January 28, 2025 19:32
@ahmedhamidawan ahmedhamidawan marked this pull request as ready for review January 28, 2025 19:32
@ahmedhamidawan
Copy link
Member Author

I rebased it to just using b-pagination for the b-table, and the datatypesMapperStore in the singular HistoryDatasetDisplay component (using the composable in the setup of this options API component was creating weird problems with the datatypesMapperLoading ref)

use_datatypes_mapper_composable_in_reports_2.mp4

@ahmedhamidawan ahmedhamidawan changed the title [24.1] Use datatypes mapper composable to load invocation reports quicker [24.1] Paginate tabular datasets in tables to load invocation reports quicker Jan 28, 2025
It's not what's causing the slowness, that's entirely because of b-table being slow to render many rows
We may have many of these displays, so let's be on the safe side here. The embedded frame is less than 100 rows high anyway, so using the pagination control is not a bother anyway.
Copy link
Member

@mvdbeek mvdbeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ahmedhamidawan, let's get this in.

@mvdbeek
Copy link
Member

mvdbeek commented Jan 29, 2025

Deployed on usegalaxy.org, working nicely!

@mvdbeek mvdbeek merged commit 7b6f23b into galaxyproject:release_24.1 Jan 29, 2025
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants