Skip to content

Make symbol link icon to be refreshed correctly #168707

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ShuiRuTian
Copy link

#167146

Another try to fix #167146 by reference #167828 (comment)

This PR makes the following changes:

  • IDecorationsProvider is able to fire another event onForceRefresh, to tell which URI need to be refreshed.
  • DecorationsService will listen to the event, record the URIs that need to be refreshed. And when getting values, it will get the fresh value rather than cache from the IDecorationsProvider if the IDecorationsProvider and URI are both same.

However, this PR is kind of noisy, because it adds onForceRefresh to all IDecorationsProviders. Should this method be optional?

@ShuiRuTian
Copy link
Author

Ping @jrieken and @lramos15

@ShuiRuTian ShuiRuTian changed the title Another try to fix 167146 Make symbol link icon to be refreshed correctly Dec 10, 2022
@lramos15
Copy link
Member

Looks like some unit tests are failing here.

@jrieken
Copy link
Member

jrieken commented Dec 12, 2022

@ShuiRuTian I really don't understand why this needs any changes in the decoration service and why this isn't a problem of the concrete provider, e.g of ExplorerDecorationsProvider. It has the ability to signal changes for one or many resources and the decoration service will re-request data from it in return. So, please explain why these complex changes are needed. Thanks

@ShuiRuTian
Copy link
Author

ShuiRuTian commented Dec 13, 2022

Hi, @jrieken

The main purpose is to be a bit more accurate and effective.

As we could see, ExplorerDecorationsProvider does not listen to file change event:
image

So what about listening to FileService.onDidFilesChange?
It could work, but the data need to be refetched each time when the resource is updated. Because we have no idea whether it was a symbolic link or not last time.(The data is stored in templateData.label, in which we decide whether the decorations value need to be updated or not.)

To avoid this, this PR add another Emitter to provider, which is very similar to the existing Event. The purpose is to give more control to the client(which use the service):
image
Here, it's able to decide whether the value need to be refreshed or not.

However, I agree it's kind of complex, maybe it's better to just fix the issue with listen to fileService.onDidFilesChange at first, and if it's proven this is an issue in the future, we could fix it. Is this preferred?

@jrieken
Copy link
Member

jrieken commented Dec 13, 2022

So what about listening to FileService.onDidFilesChange?

I leave it up to @lramos15 to know but generally the place to fix this should be the one provider that's wrong, not the service around them

@lramos15
Copy link
Member

@ShuiRuTian Are there worries about listening to it in the decoration provider? Is this a performance question? I would definitely attempt that solution first since this is explorer specific and then run a performance profile of some sort. Thanks for looking into this!

@ShuiRuTian ShuiRuTian force-pushed the another-try-to-fix-167146 branch from 627d7c7 to 82b2548 Compare December 14, 2022 08:58
@ShuiRuTian ShuiRuTian force-pushed the another-try-to-fix-167146 branch from 82b2548 to 7731fd4 Compare December 14, 2022 09:50
@ShuiRuTian
Copy link
Author

Thanks for the great suggestions, code is updated.
Ping @jrieken and @lramos15

@lramos15
Copy link
Member

FYI @bpasero Any concerns about the update to the label file or listening to the file service like this?

});
}

private hasIsSymbolicLinkChanged(newOptions?: IResourceLabelOptions): boolean {
Copy link
Member

Choose a reason for hiding this comment

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

hasSymbolicLinkChanged?

@@ -456,6 +461,7 @@ class ResourceLabelWidget extends IconLabel {
}
}

const hasIsSymbolicLinkChanged = this.hasIsSymbolicLinkChanged(options);
Copy link
Member

Choose a reason for hiding this comment

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

hasSymbolicLinkChanged?

@@ -59,6 +61,9 @@ export class ExplorerDecorationsProvider implements IDecorationsProvider {
this.toDispose.add(explorerRootErrorEmitter.event((resource => {
this._onDidChange.fire([resource]);
})));
this.toDispose.add(fileService.onDidFilesChange(e => {
Copy link
Member

Choose a reason for hiding this comment

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

This event can fire thousands of times at the same time for thousands of files, so whoever is listening needs to be checked for perf bottlenecks if that happens.

@bpasero
Copy link
Member

bpasero commented Dec 15, 2022

We should at least measure the perf baseline on a slower machine (maybe also OS = Windows) when thousands of events come in, e.g. from npm install. Listening to file events and re-emitting that as a change you always have to be fit for potential 10-thousands of events firing at the same time.

I am not 100% sure the (relatively minor) issue deserves such a fix when it makes perf worse tbh.

@ShuiRuTian
Copy link
Author

So we do not want to introduce any potential performance issue or any complexity? Then maybe we could close this PR to keep the house clean.

@bpasero
Copy link
Member

bpasero commented Dec 16, 2022

So we do not want to introduce any potential performance issue or any complexity?

We do not want to introduce performance issues. File events are a potential source of performance issue because the amount of events can be very very high. We unfortunately not have a way to listen for specific events, but in reality we would probably only be interested in events for resources that are visible in the explorer.

@ShuiRuTian
Copy link
Author

ShuiRuTian commented Dec 16, 2022

At the beginning, this PR adds another Emitter to each decoration provider, so that we could give more control to the caller and avoid the performance issue because we only fetch data when symbolic link is changed. You could reference this comment.

But I agree it's indeed kind of weird. And the reviewers give different opinions here and here.

I have no idea, let the team decide it...

PS: I used force push, so the history is gone...

@lramos15
Copy link
Member

@ShuiRuTian I wonder, could we listen to the explorer refresh and then iterating through just the files the explorer knows of checking if they're symbolic links? Like Ben said this is expensive for an edge case and I would like to resolve it, but not at the cost of perf. If you don't have time to investigate such a complex issue I understand and can take a look myself when I have some free cycles.

@ShuiRuTian
Copy link
Author

@lramos15 Sorry for the late response.

Sounds great, but how do we know whether one explorer item was symbolic link or not? I think this info is kind of like an implementation detail now and it's hidden in high level. Or we need to reactor a bit to get this message?

@lramos15
Copy link
Member

@lramos15 Sorry for the late response.

Sounds great, but how do we know whether one explorer item was symbolic link or not? I think this info is kind of like an implementation detail now and it's hidden in high level. Or we need to reactor a bit to get this message?

You would likely need to do some refactoring to get the message to the right place

@evur
Copy link

evur commented Apr 20, 2023

When will this be finished?

@vivodi
Copy link

vivodi commented Dec 29, 2024

Is this still relevant?

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.

Softlink icon is not updated for folder
6 participants