SERVER-107518 Package in perf tool with bolt (#38997)

GitOrigin-RevId: 883ef3540dea29856a21570652b0edd1f63be766
This commit is contained in:
Andrew Bradshaw 2025-07-23 15:19:07 -07:00 committed by MongoDB Bot
parent dfaed6ce33
commit c86eb08ce3
2 changed files with 17 additions and 4 deletions

View File

@ -45,14 +45,19 @@ filegroup(
srcs = ["bolt/bin/perf2bolt"],
)
filegroup(
name = "perf",
srcs = ["bolt/bin/perf"],
)
filegroup(
name = "libbolt_rt_instr",
srcs = ["bolt/lib/libbolt_rt_instr.a"],
)
""",
sha256 = "3075be7271266550a02a0fce25622a7130a9fdf947d708e0abd45213ee17e0cf",
sha256 = "9bf3a978edd852b7975c65921ad207a5dad44254fd39eb223830057d35bb9c94",
urls = [
"https://mdb-build-public.s3.us-east-1.amazonaws.com/andrew_pgo_scratch/bolt_good.tar.gz",
"https://mdb-build-public.s3.us-east-1.amazonaws.com/andrew_pgo_scratch/bolt_perf.tar.gz",
] * 5,
)

View File

@ -16,6 +16,10 @@ def _setup_bolt_data(repository_ctx):
# Incase you want to bolt a binary instead of the main binary mongod
bolt_binary_name = repository_ctx.os.environ.get("bolt_binary_name", None)
# Perf2bolt will use the path to call the perf tool
path_env = repository_ctx.os.environ.get("PATH", None)
perf_path_env = str(repository_ctx.path(repository_ctx.attr._perf_binary).dirname) + ":" + path_env
if bolt_binary_name == None:
bolt_binary_name = "mongod"
@ -62,7 +66,10 @@ def _setup_bolt_data(repository_ctx):
for file in data_files:
fdata_file_name = "bolt" + str(processed_fdata_files) + ".fdata"
arguments = [repository_ctx.attr._perf2bolt_binary, "-nl", "-p", file, "-o", fdata_file_name, binary]
result = repository_ctx.execute(arguments)
# We execute perf through path so it doesn't get executable permissions normally
repository_ctx.execute(["chmod", "+x", repository_ctx.attr._perf_binary])
result = repository_ctx.execute(arguments, environment = {"PATH": perf_path_env})
print(result.stdout)
if result.return_code != 0:
print(result.stderr)
@ -98,10 +105,11 @@ filegroup(
setup_bolt_data = repository_rule(
implementation = _setup_bolt_data,
environ = ["bolt_profile_url", "bolt_binary_url", "bolt_binary_name"],
environ = ["bolt_profile_url", "bolt_binary_url", "bolt_binary_name", "PATH"],
attrs = {
# There is a bug where the repo rule does not properly evaluate these labels so we have to list the full path to the binaries
"_merge_fdata_binary": attr.label(allow_single_file = True, default = "@bolt_binaries//:bolt/bin/merge-fdata", executable = True, cfg = "host"),
"_perf2bolt_binary": attr.label(allow_single_file = True, default = "@bolt_binaries//:bolt/bin/perf2bolt", executable = True, cfg = "host"),
"_perf_binary": attr.label(allow_single_file = True, default = "@bolt_binaries//:bolt/bin/perf", executable = True, cfg = "host"),
},
)