-
Notifications
You must be signed in to change notification settings - Fork 97
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
Fix high CPU usage during ramalama pull #685
base: main
Are you sure you want to change the base?
Conversation
Showing update progress in 1 kiB blocks adds unnecessary overhead. 100 kiB or even 1 MiB should be sufficient. Related: containers#684
Reviewer's Guide by SourceryThis pull request introduces a new Sequence diagram for the modified download processsequenceDiagram
participant Client
participant DownloadManager
participant HTTPClient
Client->>DownloadManager: download_file(url, show_progress)
DownloadManager->>HTTPClient: init(url, show_progress)
activate HTTPClient
loop Until EOF
HTTPClient->>HTTPClient: read(100KB blocks)
Note right of HTTPClient: Increased from 1KB to 100KB blocks
alt show_progress is true
HTTPClient->>Client: Update progress bar
end
end
HTTPClient-->>DownloadManager: Download complete
deactivate HTTPClient
DownloadManager-->>Client: File downloaded
Class diagram showing modified download componentsclassDiagram
class HTTPClient {
-response
-now_downloaded: int
-start_time: float
+init(url, headers, output_file, show_progress)
+perform_download(file, progress)
}
class DownloadManager {
+download_file(url, dest_path, headers, show_progress)
}
class PullCommand {
+pull(args)
}
PullCommand ..> DownloadManager : uses
DownloadManager ..> HTTPClient : uses
note for HTTPClient "Block size increased to 100KB"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @mkesper - I've reviewed your changes - here's some feedback:
Overall Comments:
- The --quiet flag should use action="store_true" instead of action="store" with default=False to be consistent with other boolean flags in the codebase
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@@ -45,9 +45,9 @@ def pull_blob(repos, layer_digest, accept, registry_head, models, model_name, mo | |||
run_cmd(["ln", "-sf", relative_target_path, model_path]) | |||
|
|||
|
|||
def init_pull(repos, accept, registry_head, model_name, model_tag, models, model_path, model): | |||
def init_pull(repos, accept, registry_head, model_name, model_tag, models, model_path, model, show_progress): |
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.
issue (bug_risk): Function signature mismatch: pull_config_blob is called with show_progress parameter but doesn't accept it
Change looks fine to me @mkesper you just need to sign your commits with something like:
to satisfy the DCO bot. |
Lots of tests failed too, we need to get this build green somehow, at least some of the failures are flakes, not sure how many. This will all be rebuilt anyway when you the commits are signed. |
@@ -177,7 +177,7 @@ def download_file(url, dest_path, headers=None, show_progress=True): | |||
show_progress = False | |||
|
|||
try: | |||
http_client.init(url=url, headers=headers, output_file=dest_path, progress=show_progress) | |||
http_client.init(url=url, headers=headers, output_file=dest_path, show_progress=show_progress) |
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.
This rename needs to be made to HttpClient.init as well.
Anybody know what "podman pull" or "podman artifact pull" block size is? @baude @rhatdan We could just standardise on that, it's likely a sane value. I probably care about reliability over cpu usage. I know in practice at the TCP level of the stack a max packet size is 1500 bytes, but that's probably not so important at the http level. |
It could be the progress bar causing the CPU usage issue also, maybe we could change it so that it doesn't update every single block iteration. |
Does quiet alone lower the CPU usage significantly @mkesper ? |
@ericcurtin Best I can tell, the image copier used in podman updates once per second by default: |
If you guys could check if this makes a difference I'd appreciate it, not much CPU usage issues on my machine (and maybe the time calculation is as expensive that printing a progress bar update, I've no idea): |
Feel free to adjust block size. But 1k blocks are ridiculously low for downloading GiB of LLM data.
Related: #684
Summary by Sourcery
New Features:
--quiet
flag to suppress the progress bar during downloads.