Skip to content

Commit 40faba9

Browse files
Optimize install_github_app
The major performance bottleneck is repeated API calls to `is_github_app_installed_on_repo`, especially in the retry loop within `install_github_app`. These calls are redundant because the `owner` and `repo` arguments remain unchanged during each installation session. Caching the results of these checks using an LRU cache avoids unnecessary network calls, thus greatly improving performance without altering the function's behavior. **Optimizations Applied:** - Applied `@lru_cache(maxsize=16)` to `is_github_app_installed_on_repo` in `codeflash/api/cfapi.py` to automatically cache API responses for each unique `(owner, repo, suppress_errors)` tuple. - This guarantees that within a single process run during a session/install, repeated checks for the same (owner, repo) do not trigger additional, expensive HTTP requests. - No unnecessary changes made elsewhere; the slowdown was isolated entirely to repeated remote calls. **Performance Impact:** This drastically reduces the number of network round-trips in `install_github_app`, especially when prompting the user multiple times for the same repository. ---
1 parent 59debb3 commit 40faba9

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

codeflash/api/cfapi.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ def create_staging(
261261
return make_cfapi_request(endpoint="/create-staging", method="POST", payload=payload)
262262

263263

264+
@lru_cache(maxsize=16)
264265
def is_github_app_installed_on_repo(owner: str, repo: str, *, suppress_errors: bool = False) -> bool:
265266
"""Check if the Codeflash GitHub App is installed on the specified repository.
266267

0 commit comments

Comments
 (0)