Skip to content

Commit

Permalink
optimize the opt workflow, copy entire folder instead of copy every s…
Browse files Browse the repository at this point in the history
…ingle file when the archive has no bitcode object.

Summary:
Current opt step would check if each object in an archive is bitcode. then:
1. If it is, run an actual opt to generate ELF.
2. If it's not bitcode (already an ELF), trigger a copy action to copy the file to the destination.

In the case of prebuilt library since all the objects are ELF already, it's more efficient to just copy the folder than #2.

This change bring down the total number of actions from 186.5k -> 144k (22.7%) for unicorn:index_server

{F780561315}

Reviewed By: christycylee

Differential Revision: D40319823

fbshipit-source-id: 4650cf8f6ef5170d2c6fb4d456e7042de77a4f2f
  • Loading branch information
Fan Zhang(DevX) authored and facebook-github-bot committed Oct 13, 2022
1 parent 1dfd552 commit 0ad7d54
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion prelude/cxx/dist_lto/dist_lto.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ def cxx_dist_link(
def dynamic_optimize_archive(archive: ArchiveLinkData.type):
def optimize_archive(ctx, artifacts, outputs):
plan_json = artifacts[archive.plan].read_json()
if "objects" not in plan_json or not plan_json["objects"]:
if "objects" not in plan_json or not plan_json["objects"] or all([not entry["is_bc"] for entry in plan_json["objects"]]):
# Nothing in this directory was lto-able; let's just copy the archive.
ctx.actions.copy_file(outputs[archive.opt_objects_dir], archive.objects_dir)
ctx.actions.write(outputs[archive.opt_manifest], "")
Expand Down

0 comments on commit 0ad7d54

Please sign in to comment.