-
Notifications
You must be signed in to change notification settings - Fork 919
[CLI] Speed up sky status by caching
#6166
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
Conversation
sky/client/cli/command.py
Outdated
| with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor: | ||
| ssh_future = executor.submit(update_ssh_configs, cluster_records) | ||
|
|
||
| # Process cluster records while SSH configs are being updated | ||
| hints = [] | ||
| normal_clusters = [] | ||
| controllers = [] | ||
| for cluster_record in cluster_records: | ||
| cluster_name = cluster_record['name'] | ||
| controller = controller_utils.Controllers.from_name(cluster_name) | ||
| if controller is not None: | ||
| controllers.append(cluster_record) | ||
| else: | ||
| normal_clusters.append(cluster_record) | ||
|
|
||
| # Wait for SSH config updates to complete | ||
| ssh_future.result() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to double check if this can provide any speedup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Master
hyperfine --warmup 3 --runs 10 'sky status'
Benchmark 1: sky status
Time (mean ± σ): 2.382 s ± 0.057 s [User: 0.445 s, System: 0.087 s]
Range (min … max): 2.269 s … 2.446 s 10 runs
With health check caching
hyperfine --warmup 3 --runs 10 'sky status'
Benchmark 1: sky status
Time (mean ± σ): 2.043 s ± 0.062 s [User: 0.447 s, System: 0.086 s]
Range (min … max): 1.954 s … 2.186 s 10 runs
With health check caching + grouping request
hyperfine --warmup 3 --runs 10 'sky status'
Benchmark 1: sky status
Time (mean ± σ): 1.711 s ± 0.092 s [User: 0.425 s, System: 0.083 s]
Range (min … max): 1.641 s … 1.951 s 10 runs
It does speedup
| return ApiServerInfo(status=ApiServerStatus.UNHEALTHY) | ||
|
|
||
|
|
||
| @cachetools.cached(cache=cachetools.TTLCache(maxsize=10, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add a lock= kwarg to the cachetools.cached call for thread safety?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Locked
| f'View logs at: {constants.API_SERVER_LOGS}') | ||
| try: | ||
| # Clear the cache to ensure fresh checks during startup | ||
| get_api_server_status.cache_clear() # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typing 😔 but I see there is no way around this
|
should we get this merged? |
Builds on top of speedup-api branch
Here are the results
Here's the profile of each:
Before:

After:

If you take a look closely with the number of
check..calls understatus, there's one for every request (blocking). These changes merge it into one call and the main perf improvement is keepingget_api_server_statuscached,Tested (run the relevant ones):
bash format.sh/smoke-test(CI) orpytest tests/test_smoke.py(local)/smoke-test -k test_name(CI) orpytest tests/test_smoke.py::test_name(local)/quicktest-core(CI) orpytest tests/smoke_tests/test_backward_compat.py(local)