Skip to content

Route benchmark subprocess through the PAR bootstrap (#143)#143

Merged
wychi merged 1 commit into
mainfrom
export-D107483498
Jun 6, 2026
Merged

Route benchmark subprocess through the PAR bootstrap (#143)#143
wychi merged 1 commit into
mainfrom
export-D107483498

Conversation

@kaiming-cheng
Copy link
Copy Markdown
Contributor

@kaiming-cheng kaiming-cheng commented Jun 4, 2026

Summary:

The kernel benchmark subprocess in benchmark.py launched the child as bare sys.executable. Inside a Buck PAR sys.executable is the static-linked #native-main# interpreter; re-exec'ing it directly leaves it un-bootstrapped (no LD_LIBRARY_PATH/PYTHONPATH/LD_PRELOAD from the PAR _bootstrap.sh), so the benchmark child fails to load bundled shared libraries (e.g. libevict-thrift-py3-extensions.so). Every candidate then benchmarks as inf and opt_manager reports "did not produce an improved kernel".

KA already ships the bootstrap hook: setup_internal_environment() sets KERNEL_PROFILER_PYTHON to the PAR _bootstrap.sh (which rebuilds the env from $0 before exec-ing the native main), but only ncu_profiler.py honored it. Route the benchmark child through the same hook, falling back to sys.executable when unset (OSS / non-PAR).

Reviewed By: stashuk-olek

Differential Revision: D107483498

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 4, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Jun 4, 2026

@kaiming-cheng has exported this pull request. If you are a Meta employee, you can view the originating Diff in D107483498.

Copy link
Copy Markdown
Contributor

@Laurawly Laurawly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls fix lint

Summary:

The kernel benchmark subprocess in `benchmark.py` launched the child as bare `sys.executable`. Inside a Buck PAR `sys.executable` is the static-linked `#native-main#` interpreter; re-exec'ing it directly leaves it un-bootstrapped (no `LD_LIBRARY_PATH`/`PYTHONPATH`/`LD_PRELOAD` from the PAR `_bootstrap.sh`), so the benchmark child fails to load bundled shared libraries (e.g. `libevict-thrift-py3-extensions.so`). Every candidate then benchmarks as `inf` and `opt_manager` reports "did not produce an improved kernel".

KA already ships the bootstrap hook: `setup_internal_environment()` sets `KERNEL_PROFILER_PYTHON` to the PAR `_bootstrap.sh` (which rebuilds the env from `$0` before exec-ing the native main), but only `ncu_profiler.py` honored it. Route the benchmark child through the same hook, falling back to `sys.executable` when unset (OSS / non-PAR).

Reviewed By: stashuk-olek

Differential Revision: D107483498
@meta-codesync meta-codesync Bot changed the title Route benchmark subprocess through the PAR bootstrap Route benchmark subprocess through the PAR bootstrap (#143) Jun 4, 2026
@meta-codesync meta-codesync Bot force-pushed the export-D107483498 branch from eaacd26 to 850f11b Compare June 4, 2026 20:59
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Jun 4, 2026

@wychi has imported this pull request. If you are a Meta employee, you can view this in D107483498.

@wychi wychi merged commit 92ec588 into main Jun 6, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. fb-exported meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants