Skip to content

Commit 9fffe69

Browse files
committed
DPL: double the number of processes which can be created by the driver
This makes sure that the extra file descriptors which are needed to setup the parent / child communication channel created as late as possible, and closed as soon as the fork happens. Before this change, since we were creating the file descriptors in one go, the extra endpoints which get closed after the fork were needlessly using resources, leading to early exhaustion.
1 parent 4e183e7 commit 9fffe69

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

Framework/Core/src/runDataProcessing.cxx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -613,13 +613,6 @@ struct DeviceStdioContext {
613613
int childstdout[2];
614614
};
615615

616-
void prepareStdio(std::vector<DeviceStdioContext>& deviceStdio)
617-
{
618-
for (auto& context : deviceStdio) {
619-
createPipes(context.childstdin);
620-
createPipes(context.childstdout);
621-
}
622-
}
623616
void handleSignals()
624617
{
625618
struct sigaction sa_handle_int;
@@ -649,8 +642,6 @@ void handleChildrenStdio(uv_loop_t* loop,
649642
for (size_t i = 0; i < childFds.size(); ++i) {
650643
auto& childstdin = childFds[i].childstdin;
651644
auto& childstdout = childFds[i].childstdout;
652-
close(childstdin[0]);
653-
close(childstdout[1]);
654645

655646
uv_work_t* req = (uv_work_t*)malloc(sizeof(uv_work_t));
656647
req->data = new StreamConfigContext{forwardedStdin, childstdin[1]};
@@ -759,6 +750,8 @@ void spawnDevice(DeviceRef ref,
759750
}
760751
execvp(execution.args[0], execution.args.data());
761752
}
753+
close(childFds[ref.index].childstdin[0]);
754+
close(childFds[ref.index].childstdout[1]);
762755
if (varmap.count("post-fork-command")) {
763756
auto templateCmd = varmap["post-fork-command"];
764757
auto cmd = fmt::format(templateCmd.as<std::string>(),
@@ -1695,8 +1688,10 @@ int runStateMachine(DataProcessorSpecs const& workflow,
16951688
callback(serviceRegistry, varmap);
16961689
}
16971690
childFds.resize(runningWorkflow.devices.size());
1698-
prepareStdio(childFds);
16991691
for (int di = 0; di < runningWorkflow.devices.size(); ++di) {
1692+
auto& context = childFds[di];
1693+
createPipes(context.childstdin);
1694+
createPipes(context.childstdout);
17001695
if (runningWorkflow.devices[di].resource.hostname != driverInfo.deployHostname) {
17011696
spawnRemoteDevice(forwardedStdin.str(),
17021697
runningWorkflow.devices[di], controls[di], deviceExecutions[di], infos);

0 commit comments

Comments
 (0)