GH-49146: [C++] Add option to disable atfork handlers#49148
Conversation
07d10a1 to
a9c3279
Compare
2753054 to
3a44920
Compare
3a44920 to
57e9185
Compare
|
|
||
| uint32_t res = GetEnvironmentVariableA(name.data(), value.data(), | ||
| static_cast<uint32_t>(value.size())); | ||
| if (res >= value.size()) { |
There was a problem hiding this comment.
This >= comparison was a bit confusing to me at first but this is fine as the == case should never happen.
|
After merging your PR, Conbench analyzed the 2 benchmarking runs that have been run so far on merge-commit ebaaf07. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 12 possible false positives for unstable benchmarks that are known to sometimes produce them. |
|
After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit ebaaf07. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. It also includes information about 13 possible false positives for unstable benchmarks that are known to sometimes produce them. |
Rationale for this change
The atfork handlers we register in Arrow C++ are generally useful if the Arrow APIs are meant to be used from the child process, but they also have the unfortunate effect of executing non-async-signal-safe code in the child process even if Arrow is not be used there. That is not allowed by POSIX if the parent process is multi-threaded.
There are situations where fork() is only called just before exec(), and therefore it is not necessary to run any atfork handler.
What changes are included in this PR?
GetEnvVarIntegerutility function to automate parsing of a numeric environment variableARROW_REGISTER_ATFORKto disable the registration of atfork handlers at runtimeAre these changes tested?
The new environment variable cannot be easily tested automatically, so I've checked it manually.
Are there any user-facing changes?
No, only a new feature.