Skip to content

Commit fb9dca9

Browse files
krallinmeta-codesync[bot]
authored andcommitted
Disable daemon cgroup assignment in e2e tests
Summary: Buck2 e2e tests have garbage data recorded for their local test resource utilization, because the daemon gets assigned a cgroup. As a result things like these massive BXL tests have a low expected resource use: https://www.internalfb.com/sandcastle/job/13510801349671108/ (side note: why are we even using buck2_e2e to check dependencies? Each test gets an isolated daemon loading the whole app, that's crazy expensive? they could probably just use `--reuse-current-config`?? I pinged mzlee to try and find a POC about this) Reviewed By: IanChilds Differential Revision: D93086502 fbshipit-source-id: 413c1a2b4c12f68974acf3b5c4cafc634a774550
1 parent a70d5ee commit fb9dca9

File tree

11 files changed

+32
-15
lines changed

11 files changed

+32
-15
lines changed

app/buck2_resource_control/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ rust_library(
1919
"fbsource//third-party/rust:tokio-util",
2020
"//buck2/allocative/allocative:allocative",
2121
"//buck2/app/buck2_common:buck2_common",
22+
"//buck2/app/buck2_core:buck2_core",
2223
"//buck2/app/buck2_data:buck2_data",
2324
"//buck2/app/buck2_error:buck2_error",
2425
"//buck2/app/buck2_events:buck2_events",

app/buck2_resource_control/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ allocative = { workspace = true }
1616
dupe = { workspace = true }
1717

1818
buck2_common = { workspace = true }
19+
buck2_core = { workspace = true }
1920
buck2_data = { workspace = true }
2021
buck2_error = { workspace = true }
2122
buck2_events = { workspace = true }

app/buck2_resource_control/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#![feature(trait_alias)]
12+
#![feature(used_with_arg)]
1213

1314
use futures::Stream;
1415
use tokio::sync::mpsc;

app/buck2_resource_control/src/spawn_daemon.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,14 @@ pub async fn create_daemon_spawn_command(
9191
working_directory: &AbsNormPath,
9292
) -> buck2_error::Result<(std::process::Command, Vec<String>)> {
9393
let daemon_spawner = {
94-
if config.status == ResourceControlStatus::Off {
94+
if config.status == ResourceControlStatus::Off
95+
|| buck2_core::buck2_env!(
96+
"BUCK2_TEST_DISABLE_DAEMON_CGROUP",
97+
type = bool,
98+
applicability = testing,
99+
)?
100+
.unwrap_or(false)
101+
{
95102
DaemonSpawner::None
96103
} else {
97104
match (config.status, get_daemon_spawner(&config.init).await) {

tests/core/help/test_help_env_data/buck2-help-env-testing.golden.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ BUCK2_TESTING_INACTIVITY_TIMEOUT bool false
3131
BUCK2_TEST_BLOCK_ON_UPLOAD bool false
3232
BUCK2_TEST_BUILD_ERROR bool false
3333
BUCK2_TEST_DISABLE_CACHING bool
34+
BUCK2_TEST_DISABLE_DAEMON_CGROUP bool
3435
BUCK2_TEST_DISABLE_LOG_UPLOAD bool false
3536
BUCK2_TEST_ERROR_ON_CACHE_UPLOAD bool false
3637
BUCK2_TEST_EXTRA_EXTERNAL_CONFIG String

tests/core/resource_control/test_action_suspension.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ async def _check_suspends( # noqa C901
119119
return num_suspended_actions
120120

121121

122-
@buck_test(skip_for_os=["darwin", "windows"])
122+
@buck_test(skip_for_os=["darwin", "windows"], disable_daemon_cgroup=False)
123123
@env("BUCK2_HARD_ERROR", "panic")
124124
@pytest.mark.parametrize("kill_and_retry", [True, False])
125125
async def test_action_suspend(
@@ -155,7 +155,7 @@ async def test_action_suspend(
155155
assert len(pressure_ends) == 1
156156

157157

158-
@buck_test(skip_for_os=["darwin", "windows"])
158+
@buck_test(skip_for_os=["darwin", "windows"], disable_daemon_cgroup=False)
159159
@env("BUCK2_HARD_ERROR", "panic")
160160
@pytest.mark.parametrize("kill_and_retry", [True, False])
161161
async def test_action_suspend_stress_test(
@@ -170,7 +170,7 @@ async def test_action_suspend_stress_test(
170170
)
171171

172172

173-
@buck_test(skip_for_os=["darwin", "windows"])
173+
@buck_test(skip_for_os=["darwin", "windows"], disable_daemon_cgroup=False)
174174
@pytest.mark.parametrize("kill_and_retry", [True, False])
175175
async def test_suspend_one_of_two(
176176
buck: Buck,

tests/core/resource_control/test_daemon_memory_metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
from buck2.tests.e2e_util.buck_workspace import buck_test
1616

1717

18-
@buck_test(skip_for_os=["darwin", "windows"])
18+
@buck_test(skip_for_os=["darwin", "windows"], disable_daemon_cgroup=False)
1919
async def test_metrics_cgroup_no_resource_control(buck: Buck) -> None:
2020
write_config(buck, resource_control=False)
2121
snapshot = await start_daemon_and_get_snapshot(buck)
2222
assert snapshot["allprocs_cgroup"] is None
2323
assert snapshot["forkserver_actions_cgroup"] is None
2424

2525

26-
@buck_test(skip_for_os=["darwin", "windows"])
26+
@buck_test(skip_for_os=["darwin", "windows"], disable_daemon_cgroup=False)
2727
async def test_metrics_cgroup_resource_control(buck: Buck) -> None:
2828
write_config(buck, resource_control=True)
2929
snapshot = await start_daemon_and_get_snapshot(buck)

tests/core/resource_control/test_hybrid_execution_resource_control.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _use_some_memory_args(buck: Buck) -> list[str]:
3131
]
3232

3333

34-
@buck_test(skip_for_os=["darwin", "windows"])
34+
@buck_test(skip_for_os=["darwin", "windows"], disable_daemon_cgroup=False)
3535
async def test_memory_pressure_telemetry(
3636
buck: Buck,
3737
) -> None:
@@ -62,7 +62,7 @@ async def test_memory_pressure_telemetry(
6262
)
6363

6464

65-
@buck_test(skip_for_os=["darwin", "windows"])
65+
@buck_test(skip_for_os=["darwin", "windows"], disable_daemon_cgroup=False)
6666
async def test_resource_control_events_created(
6767
buck: Buck,
6868
) -> None:
@@ -112,7 +112,7 @@ def get_daemon_cgroup_path(pid: int) -> Path:
112112
raise Exception(f"Could not find cgroup v2 entry for PID {pid}")
113113

114114

115-
@buck_test(skip_for_os=["darwin", "windows"])
115+
@buck_test(skip_for_os=["darwin", "windows"], disable_daemon_cgroup=False)
116116
async def test_daemon_id_in_cgroup_path(buck: Buck) -> None:
117117
await buck.server()
118118

tests/core/resource_control/test_instruction_count.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def helper_bin_flags() -> List[str]:
2424
]
2525

2626

27-
@buck_test(skip_for_os=["windows", "darwin"])
27+
@buck_test(skip_for_os=["windows", "darwin"], disable_daemon_cgroup=False)
2828
async def test_instruction_count_disabled(buck: Buck) -> None:
2929
await buck.build(
3030
"root//:three_billion_instructions",
@@ -67,7 +67,7 @@ async def get_matching_details(buck: Buck) -> Dict[str, Any]:
6767
raise AssertionError("did not find the expected target")
6868

6969

70-
@buck_test(skip_for_os=["windows", "darwin"])
70+
@buck_test(skip_for_os=["windows", "darwin"], disable_daemon_cgroup=False)
7171
async def test_instruction_count_enabled(buck: Buck) -> None:
7272
await buck.build(
7373
"root//:three_billion_instructions",
@@ -90,7 +90,7 @@ async def test_instruction_count_enabled(buck: Buck) -> None:
9090
assert instruction_count < 3300000000
9191

9292

93-
@buck_test(skip_for_os=["windows", "darwin"])
93+
@buck_test(skip_for_os=["windows", "darwin"], disable_daemon_cgroup=False)
9494
async def test_instruction_count_remote(buck: Buck) -> None:
9595
await buck.build(
9696
"root//:three_billion_instructions",

tests/core/resource_control/test_memory_reporting.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def _use_some_memory_args(buck: Buck) -> list[str]:
2929
]
3030

3131

32-
@buck_test(skip_for_os=["windows", "darwin"])
32+
@buck_test(skip_for_os=["windows", "darwin"], disable_daemon_cgroup=False)
3333
async def test_memory_reporting_disabled(buck: Buck) -> None:
3434
env = {"BUCK2_TEST_RESOURCE_CONTROL_CONFIG": '{"status":"Off"}'}
3535

@@ -68,7 +68,7 @@ async def get_matching_details(buck: Buck) -> Dict[str, Any]:
6868
raise AssertionError("did not find the expected target")
6969

7070

71-
@buck_test(skip_for_os=["windows", "darwin"])
71+
@buck_test(skip_for_os=["windows", "darwin"], disable_daemon_cgroup=False)
7272
async def test_memory_reporting(buck: Buck) -> None:
7373
await buck.build(
7474
*_use_some_memory_args(buck),
@@ -82,7 +82,7 @@ async def test_memory_reporting(buck: Buck) -> None:
8282
assert memory_peak < 15000000
8383

8484

85-
@buck_test(skip_for_os=["windows", "darwin"])
85+
@buck_test(skip_for_os=["windows", "darwin"], disable_daemon_cgroup=False)
8686
async def test_memory_reporting_in_test(buck: Buck) -> None:
8787
await buck.test(
8888
*_use_some_memory_args(buck),

0 commit comments

Comments
 (0)