Commit 9489e3bc authored by Stephen Roe's avatar Stephen Roe Committed by Chromium LUCI CQ

[fuchsia] Exclude ICU component blobs from package size calculation.

Add SDK arch directory to test data to allow discovery of SDK libraries.
Adjust test size limits.

Bug: 1126177
Change-Id: I807539c53153af6b804b7bad60c96a8e60fe515b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2638075Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Commit-Queue: Stephen Roe <steveroe@google.com>
Cr-Commit-Position: refs/heads/master@{#845728}
parent faa7a493
...@@ -32,6 +32,7 @@ template("compute_fuchsia_package_sizes") { ...@@ -32,6 +32,7 @@ template("compute_fuchsia_package_sizes") {
data += [ data += [
"//build/fuchsia/", "//build/fuchsia/",
"//fuchsia/release/size_tests/", "//fuchsia/release/size_tests/",
"//third_party/fuchsia-sdk/sdk/arch/",
"//third_party/fuchsia-sdk/sdk/tools/${target_cpu}/", "//third_party/fuchsia-sdk/sdk/tools/${target_cpu}/",
"//third_party/zstd-linux-${target_cpu}/", "//third_party/zstd-linux-${target_cpu}/",
] ]
......
...@@ -258,9 +258,15 @@ def CommitPositionFromBuildProperty(value): ...@@ -258,9 +258,15 @@ def CommitPositionFromBuildProperty(value):
raise RuntimeError('Could not get chromium commit position from test arg.') raise RuntimeError('Could not get chromium commit position from test arg.')
def GetSDKLibs(): # Compiled regular expression matching strings like *.so, *.so.1, *.so.2, ...
SO_FILENAME_REGEXP = re.compile(r'\.so(\.\d+)?$')
def GetSdkModulesForExclusion():
"""Finds shared objects (.so) under the Fuchsia SDK arch directory in dist or """Finds shared objects (.so) under the Fuchsia SDK arch directory in dist or
lib subdirectories. lib subdirectories.
Returns a set of shared objects' filenames.
""" """
# Fuchsia SDK arch directory path (contains all shared object files). # Fuchsia SDK arch directory path (contains all shared object files).
...@@ -274,7 +280,7 @@ def GetSDKLibs(): ...@@ -274,7 +280,7 @@ def GetSDKLibs():
for dirpath, _, file_names in os.walk(sdk_arch_dir): for dirpath, _, file_names in os.walk(sdk_arch_dir):
if os.path.basename(dirpath) in sdk_so_leaf_dirs: if os.path.basename(dirpath) in sdk_so_leaf_dirs:
for name in file_names: for name in file_names:
if re.search(sdk_so_filename_re, name): if SO_FILENAME_REGEXP.search(name):
lib_names.add(name) lib_names.add(name)
return lib_names return lib_names
...@@ -285,8 +291,7 @@ def FarBaseName(name): ...@@ -285,8 +291,7 @@ def FarBaseName(name):
return name return name
def GetBlobSizes(far_file, build_out_dir, extract_dir, excluded_paths, def GetBlobSizes(far_file, build_out_dir, extract_dir, compression_args):
compression_args):
"""Calculates compressed and uncompressed blob sizes for specified FAR file. """Calculates compressed and uncompressed blob sizes for specified FAR file.
Does not count blobs from SDK libraries.""" Does not count blobs from SDK libraries."""
...@@ -306,11 +311,14 @@ def GetBlobSizes(far_file, build_out_dir, extract_dir, excluded_paths, ...@@ -306,11 +311,14 @@ def GetBlobSizes(far_file, build_out_dir, extract_dir, excluded_paths,
# Map Linux filesystem blob names to blob hashes. # Map Linux filesystem blob names to blob hashes.
blob_name_hashes = GetBlobNameHashes(meta_far_extract_dir) blob_name_hashes = GetBlobNameHashes(meta_far_extract_dir)
# File names whose sizes are not charged against component's size budgets.
# Fuchsia SDK modules and the ICU icudtl.dat file are excluded from sizes.
excluded_files = GetSdkModulesForExclusion() | set(['icudtl.dat'])
# Sum compresses and uncompressed blob sizes, except for SDK blobs. # Sum compresses and uncompressed blob sizes, except for SDK blobs.
blob_sizes = {} blob_sizes = {}
for blob_name in blob_name_hashes: for blob_name in blob_name_hashes:
_, blob_base_name = os.path.split(blob_name) if os.path.basename(blob_name) not in excluded_files:
if blob_base_name not in excluded_paths:
blob_path = os.path.join(far_extract_dir, blob_name_hashes[blob_name]) blob_path = os.path.join(far_extract_dir, blob_name_hashes[blob_name])
compressed_size = CompressedSize(blob_path, compression_args) compressed_size = CompressedSize(blob_path, compression_args)
uncompressed_size = os.path.getsize(blob_path) uncompressed_size = os.path.getsize(blob_path)
...@@ -319,8 +327,8 @@ def GetBlobSizes(far_file, build_out_dir, extract_dir, excluded_paths, ...@@ -319,8 +327,8 @@ def GetBlobSizes(far_file, build_out_dir, extract_dir, excluded_paths,
return blob_sizes return blob_sizes
def GetPackageSizes(far_files, build_out_dir, extract_dir, excluded_paths, def GetPackageSizes(far_files, build_out_dir, extract_dir, compression_args,
compression_args, print_sizes): print_sizes):
"""Calculates compressed and uncompressed package sizes from blob sizes. """Calculates compressed and uncompressed package sizes from blob sizes.
Does not count blobs from SDK libraries.""" Does not count blobs from SDK libraries."""
...@@ -332,7 +340,7 @@ def GetPackageSizes(far_files, build_out_dir, extract_dir, excluded_paths, ...@@ -332,7 +340,7 @@ def GetPackageSizes(far_files, build_out_dir, extract_dir, excluded_paths,
for far_file in far_files: for far_file in far_files:
package_name = FarBaseName(far_file) package_name = FarBaseName(far_file)
package_blob_sizes[package_name] = GetBlobSizes(far_file, build_out_dir, package_blob_sizes[package_name] = GetBlobSizes(far_file, build_out_dir,
extract_dir, excluded_paths, extract_dir,
compression_args) compression_args)
# Optionally print package blob sizes (does not count sharing). # Optionally print package blob sizes (does not count sharing).
...@@ -373,11 +381,10 @@ def GetBinarySizes(args, sizes_config): ...@@ -373,11 +381,10 @@ def GetBinarySizes(args, sizes_config):
the aggregated sizes across all blobs.""" the aggregated sizes across all blobs."""
# Calculate compressed and uncompressed package sizes. # Calculate compressed and uncompressed package sizes.
sdk_libs = GetSDKLibs()
extract_dir = args.extract_dir if args.extract_dir else tempfile.mkdtemp() extract_dir = args.extract_dir if args.extract_dir else tempfile.mkdtemp()
package_sizes = GetPackageSizes(sizes_config['far_files'], args.build_out_dir, package_sizes = GetPackageSizes(sizes_config['far_files'], args.build_out_dir,
extract_dir, sdk_libs, extract_dir, sizes_config['zstd_args'],
sizes_config['zstd_args'], args.verbose) args.verbose)
if not args.extract_dir: if not args.extract_dir:
shutil.rmtree(extract_dir) shutil.rmtree(extract_dir)
...@@ -476,9 +483,11 @@ def main(): ...@@ -476,9 +483,11 @@ def main():
if not os.path.isfile(far_abs_path): if not os.path.isfile(far_abs_path):
raise Exception('Could not find FAR file "%s".' % far_abs_path) raise Exception('Could not find FAR file "%s".' % far_abs_path)
test_completed = False
test_name = 'sizes' test_name = 'sizes'
timestamp = time.time() timestamp = time.time()
test_completed = False
all_tests_passed = False
test_status = {}
sizes_histogram = [] sizes_histogram = []
results_directory = None results_directory = None
...@@ -497,6 +506,7 @@ def main(): ...@@ -497,6 +506,7 @@ def main():
traceback.print_tb(trace) traceback.print_tb(trace)
print(str(value)) print(str(value))
finally: finally:
if test_completed:
all_tests_passed, test_status = GetTestStatus(package_sizes, sizes_config, all_tests_passed, test_status = GetTestStatus(package_sizes, sizes_config,
test_completed) test_completed)
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
"zstd_args" : [ "-14" ], "zstd_args" : [ "-14" ],
"far_total_name" : "chrome_fuchsia", "far_total_name" : "chrome_fuchsia",
"size_limits" : { "size_limits" : {
"chrome_fuchsia_compressed": 38e6, "chrome_fuchsia_compressed": 54e6,
"cast_runner_compressed": 3e6, "cast_runner_compressed": 7e6,
"web_engine_compressed": 32e6 "web_engine_compressed": 53e6
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment