From ba69daca87a8a6d69b106c477eb3f8f7de3bf5ea Mon Sep 17 00:00:00 2001 From: Francisco Oca Date: Fri, 31 May 2024 15:19:35 -0400 Subject: [PATCH] Increase lru cache size, increase performance on large accounts Credits: https://github.com/nccgroup/PMapper/issues/137\#issuecomment-1756379530 Old code took 2 hours to create a graph, with this fix just 5 minutes --- principalmapper/querying/local_policy_simulation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/principalmapper/querying/local_policy_simulation.py b/principalmapper/querying/local_policy_simulation.py index 4b63cd3..59bdadb 100644 --- a/principalmapper/querying/local_policy_simulation.py +++ b/principalmapper/querying/local_policy_simulation.py @@ -888,7 +888,7 @@ def _statement_matches_resource(statement: dict, resource: str, condition_keys: return True -@functools.lru_cache(maxsize=2048, typed=True) +@functools.lru_cache(maxsize=2048*64, typed=True) def _compose_pattern(string_to_transform) -> Pattern: """Helper function that transforms a string with potential wildcards (* or ?) into a regular expression. Uses the functools.lru_cache decorator to reduce re-compiling the same value multiple times."""