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

Also copy dps and remove redundant checks. #777

Merged
merged 6 commits into from Dec 14, 2023
Merged

Conversation

WenzDaniel
Copy link
Collaborator

What is the problem / what does the code in this PR do
In this follow up PR for #768 we change a bit the plugin caching. The plugin caching was introduced in #483 followed by two fixes in #485 and #545. In #483 it was decided to sacrifice a bit performance over reliability, and thus do not cache for example the plugin.deps which also required to rerun fix_dtype when loading plugins from cache.

In this PR we add deps to the cached plugins and remove the deps computation and _fix_dependency which calls fix_dtype from __get_requested_plugins_from_cache. The change should be justified because we cache all plugins using a deterministic context hash based on the current _plugin_class_registry. Thus, if a plugin changes, which potentially changes the deps of the plugins, all plugins need to be cached again anyhow.

@WenzDaniel
Copy link
Collaborator Author

I hope I have not overlooked anything regarding multi-threading.

Copy link

github-actions bot commented Nov 22, 2023

Coverage Status

coverage: 91.216% (-0.4%) from 91.589%
when pulling 7528b40 on speed_up_get_plugin
into 8c54d5b on master.

@WenzDaniel WenzDaniel marked this pull request as draft November 23, 2023 09:21
@WenzDaniel WenzDaniel marked this pull request as ready for review November 23, 2023 11:42
@WenzDaniel
Copy link
Collaborator Author

Edit: I test processed a run up to event_info_double and now everything seems to work. @HenningSE also tested the changes with fuse and the performance boost is significant. However, I think this PR needs a thorough review to make sure we did not overlooked any issue.

@HenningSE
Copy link
Collaborator

Hey @WenzDaniel, thanks for the work! The changes make a big difference when loading and making cut data in a fuse context. The time needed to "make" our basic cuts for a test simulation with just 10 events reduced from >5 minutes down to <30 seconds. The time to load the data also reduced from several minutes down to O(10) seconds.

@WenzDaniel
Copy link
Collaborator Author

Glad that it works. However, @dachengx @JYangQi00, can you have a look at the change? From what I read in Jorans old PRs, and what I have seen in the code we should be good to cache deps too. However, we must run fix_dtype at least for the requested plugins because in some plugins like here we define some class properties which are used in the compute method later.

@dachengx
Copy link
Collaborator

@WenzDaniel Yes, the (1st) review will be done within 2 or 3 days. Would you link the discussion in Slack to the PR description? To help the understanding of the time consumption, for people in nT.

@WenzDaniel
Copy link
Collaborator Author

You mean the once I linked last week? Do not bother with those. These are different very simple PRs. This one here is much more important and needs experts knowledge in my opinion. The other two can be simply assigned to anybody if nobody volunteers.

@dachengx
Copy link
Collaborator

No, no. This one, I put it here: https://xenonnt.slack.com/archives/C016UJZ090B/p1700489148040259. : )

@@ -626,14 +626,14 @@ def _context_hash(self):
If any item changes in the config, so does this hash.

"""
base_hash_on_config = self.config.copy()
self._base_hash_on_config = self.config.copy()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why _base_hash_on_config need to be an attribute of Context?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I will also save depends_on and provides to _base_hash_on_config, just to be safe.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why _base_hash_on_config need to be an attribute of Context?

Not needed, but it was quite handy for debugging. So I think we should keep it.

I think I will also save depends_on and provides to _base_hash_on_config, just to be safe.

This is done implicitly by looping over the plugin class registry. It will change if a plugin has additional, fewer, or different provides than the default ones, is not it?

@dachengx
Copy link
Collaborator

dachengx commented Dec 1, 2023

Things other than the above comments look great. Thanks @WenzDaniel . The boosted performance is significant, nT people can check the boost in the slack thread linked.

@WenzDaniel
Copy link
Collaborator Author

Thanks @dachengx , if you are happy with my replies we can merge.

@dachengx dachengx merged commit b0ca3cb into master Dec 14, 2023
11 checks passed
@dachengx dachengx deleted the speed_up_get_plugin branch December 14, 2023 18:01
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.

None yet

3 participants