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

fetch detected tasks twice on clicking "Run Tasks" #7536

Closed
wants to merge 1 commit into from

Conversation

elaihau
Copy link
Contributor

@elaihau elaihau commented Apr 9, 2020

Signed-off-by: Liang Huang lhuang4@ualberta.ca

What it does

Refactored TaskConfigurations.getTasks().
Instead of fetching detected tasks from providers for every single customized detected task, only fetch from providers for the 1st customized detected task, and from the cache for the rest.

How to test

I smoke-tested the following features:

  • Open Terminal -> Run Tasks, and check if the detected tasks and customzied detected tasks are properly displayed.
  • Check if the detected tasks and customzied detected tasks can be started properly.
  • Added logging to ProvidedTaskConfigurations.getTasks() to ensure it is called once by TaskConfigurations.getTasks(), and two times in total when Terminal -> Run Tasks is clicked.

Review checklist

@elaihau elaihau added the tasks issues related to the task system label Apr 9, 2020
@elaihau elaihau requested a review from tsmaeder April 9, 2020 00:44
- detected tasks are fetched N+1 times when users click "Run Tasks" from
the menu, where N is the number of customized detected tasks in the
tasks.json.

- fixes #7496

Signed-off-by: Liang Huang <lhuang4@ualberta.ca>
@elaihau elaihau force-pushed the Liang/provideTaskCalledTooManyTimes branch from 5d5d6b5 to da037d0 Compare April 16, 2020 18:49
Copy link
Contributor

@tsmaeder tsmaeder left a comment

Choose a reason for hiding this comment

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

Unfortunately, I think the approach you've chosen is not optimal: it requires clients of "ProvidedTasksConfiguration" to manage the cases where they want to use cached tasks or refetch from the task providers. Also, while it fixes the concrete case I found, there may be other code paths that still refetch multiple times.
The question we need to ask, IMO is how long we consider the fetched tasks to be valid. During that interval we want a non-changing set of contributed tasks. My approach would add a "clearCache" call on "ProvidedTaskConfigurations" and call that whenever we need to.
The correct points to clear the cache is whenever we start a new user operation, in my opinion. So either from commands or on the level of method call on "TaskService".
I'll try to do a quick PoC.

@tsmaeder
Copy link
Contributor

I sketched my approach here: #7633

@elaihau
Copy link
Contributor Author

elaihau commented Apr 22, 2020

Unfortunately, I think the approach you've chosen is not optimal: it requires clients of "ProvidedTasksConfiguration" to manage the cases where they want to use cached tasks or refetch from the task providers. Also, while it fixes the concrete case I found, there may be other code paths that still refetch multiple times.
The question we need to ask, IMO is how long we consider the fetched tasks to be valid. During that interval we want a non-changing set of contributed tasks. My approach would add a "clearCache" call on "ProvidedTaskConfigurations" and call that whenever we need to.
The correct points to clear the cache is whenever we start a new user operation, in my opinion. So either from commands or on the level of method call on "TaskService".
I'll try to do a quick PoC.

Thank you for the POC ! I believe yours is better. I will close this one :)

@elaihau elaihau closed this Apr 22, 2020
@elaihau elaihau deleted the Liang/provideTaskCalledTooManyTimes branch April 22, 2020 01:33
@tsmaeder tsmaeder mentioned this pull request Apr 22, 2020
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tasks issues related to the task system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Run tasks" calls same Task Provider repeatedly.
2 participants