From 2787eead8996894a19e2d9122788fa4c18abade9 Mon Sep 17 00:00:00 2001 From: Colin Dean Date: Sun, 16 Apr 2023 21:32:47 +0000 Subject: [PATCH] Add bottle file size to GHP manifest annotations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will reduce the number of requests necessary to ascertain the size of formulas' bottle archives for analysis purposes. Currently, getting the size of each bottle requires 1 request for the formula.json and followed by N requests per formula-version, which for most formulae is 7— more than 47k requests! After this change, size retrieval can ascertain all bottle sizes for a formula-version in a single request, at the cost of one additional request per formula-version if that formula-version has not been rebuilt since this change was introduced. To start, size retrieval will incur an additional P requests where P is the number of packages. Over the next few weeks and months, the retrieval will go a lot faster as all new and updated packages will require only one request. --- Library/Homebrew/github_packages.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Library/Homebrew/github_packages.rb b/Library/Homebrew/github_packages.rb index dd0eefed30..f59220ea7b 100644 --- a/Library/Homebrew/github_packages.rb +++ b/Library/Homebrew/github_packages.rb @@ -356,11 +356,14 @@ class GitHubPackages documentation = "https://formulae.brew.sh/formula/#{formula_name}" if formula_core_tap + local_file_size = File.size(local_file) + descriptor_annotations_hash = { "org.opencontainers.image.ref.name" => tag, "sh.brew.bottle.cpu.variant" => cpu_variant, "sh.brew.bottle.digest" => tar_gz_sha256, "sh.brew.bottle.glibc.version" => glibc_version, + "sh.brew.bottle.size" => local_file_size, "sh.brew.tab" => tab.to_json, }.reject { |_, v| v.blank? }