Skip to content

Commit

Permalink
add cache for entry points in a group (#3622)
Browse files Browse the repository at this point in the history
Entry point loading is already cached at the `reentry` level but getting
all entry points within a group can still take significant amount of
time.
This commit introduces a simple cache at the AiiDA level. An alternative
would be to add a cache at the reentry level.

To provide some context: The timings on a query for 300 Dict nodes are
as follows:

 * No cache: ~110 ms
 * Cache: 82ms
  • Loading branch information
ltalirz authored Dec 10, 2019
1 parent a334244 commit fcfbf3a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions aiida/plugins/entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import enum
import traceback
import functools

try:
from reentry.default_manager import PluginManager
Expand Down Expand Up @@ -185,7 +186,6 @@ def load_entry_point_from_string(entry_point_string):
group, name = parse_entry_point_string(entry_point_string)
return load_entry_point(group, name)


def load_entry_point(group, name):
"""
Load the class registered under the entry point for a given name and group
Expand Down Expand Up @@ -234,6 +234,7 @@ def get_entry_point_names(group, sort=True):
return entry_point_names


@functools.lru_cache(maxsize=None)
def get_entry_points(group):
"""
Return a list of all the entry points within a specific group
Expand All @@ -243,7 +244,7 @@ def get_entry_points(group):
"""
return [ep for ep in ENTRYPOINT_MANAGER.iter_entry_points(group=group)]


@functools.lru_cache(maxsize=None)
def get_entry_point(group, name):
"""
Return an entry point with a given name within a specific group
Expand Down

0 comments on commit fcfbf3a

Please sign in to comment.