-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-45209: [C++][CMake] Fix the issue that allocator not disabled for sanitizer cmake presets #45210
GH-45209: [C++][CMake] Fix the issue that allocator not disabled for sanitizer cmake presets #45210
Conversation
|
Hmm. This will be easy to break... Because we want to sort lists in general and we can't add comments in JSON. How about creating |
Ah, that sounds nice. I'll try it and update soon. Thank you for the suggestion! |
Hi @kou , I've introduced a group of Once it comes to the day that enforcing override order is mandatory (let's hope that not!), we can revise these names and introduce number-prefix naming then. How do you think? Plus, I also did some re-ordering/re-grouping/simplification to existing presets the way I see fit. Please also help to check. cc @pitrou as well. Thank you! |
} | ||
}, | ||
{ | ||
"name": "features-emscripten", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we inherit _allocator-none
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
cpp/CMakePresets.json
Outdated
@@ -6,6 +6,30 @@ | |||
"patch": 0 | |||
}, | |||
"configurePresets": [ | |||
{ | |||
"name": "_allocator-none", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use this in features-minimal
too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, yes we can. I was trying to add some specialty to _
presets, that is, not using it in regular inheritance where there is no conflicting variables. However I think nothing functional really prevents it from being used in regular inheritance. I'll try that and update soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
cpp/CMakePresets.json
Outdated
} | ||
}, | ||
{ | ||
"name": "_allocator-mimalloc", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use this in features-basic
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As replied in my other comment, yes we can. Will try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed.
cpp/CMakePresets.json
Outdated
"hidden": true, | ||
"cacheVariables": { | ||
"ARROW_JEMALLOC": "ON", | ||
"ARROW_MIMALLOC": "OFF" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this?
How about specifying only ARROW_JEMALLOC
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean something like this?
"ARROW_MIMALLOC": "OFF" |
I think we should always specify one ON
one OFF
together (unless we are 100% sure about one value of them being specified earlier) - otherwise there could be potentially two allocators which is not desired?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can enable multiple allocators at the same time. :-)
The default allocator is chosen based on our recommendation:
arrow/cpp/src/arrow/memory_pool.cc
Line 143 in 5181c24
struct SupportedBackend default_backend = SupportedBackends().front(); |
arrow/cpp/src/arrow/memory_pool.cc
Lines 86 to 100 in 5181c24
const std::vector<SupportedBackend>& SupportedBackends() { | |
static std::vector<SupportedBackend> backends = { | |
// mimalloc is our preferred allocator for several reasons: | |
// 1) it has good performance | |
// 2) it is well-supported on all our main platforms (Linux, macOS, Windows) | |
// 3) it is easy to configure and has a consistent API. | |
#ifdef ARROW_MIMALLOC | |
{"mimalloc", MemoryPoolBackend::Mimalloc}, | |
#endif | |
#ifdef ARROW_JEMALLOC | |
{"jemalloc", MemoryPoolBackend::Jemalloc}, | |
#endif | |
{"system", MemoryPoolBackend::System}}; | |
return backends; | |
} |
But users can select any allocator from enabled allocators by creating arrow::MemoryPool
instead of using arrow::default_memory_pool()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, I see.
However I think we are expecting these allocator presets to enforce the allocator selection. That is, _allocator_X
should mean "only enable allocator X, nothing else".
So for intentionally enabling both allocators, we can have another _allocator_all
maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Let's use the approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But is _allocator_all
useful enough to worth an individual cmake preset? (It makes the _allocator
group intact though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use it for features-maximal
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that makes much more sense. Updated. Also changed to use plural _allocators
.
cpp/CMakePresets.json
Outdated
"name": "_allocator-mimalloc", | ||
"hidden": true, | ||
"cacheVariables": { | ||
"ARROW_JEMALLOC": "OFF", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Answered in my other comment.
cpp/CMakePresets.json
Outdated
@@ -6,6 +6,30 @@ | |||
"patch": 0 | |||
}, | |||
"configurePresets": [ | |||
{ | |||
"name": "_allocator-none", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that we can add comments by "$comment"
: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#format
Could you add a comment why we use _XXX
name here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the idea. But unfortunately "$comment"
is only supported in version 10 or above, and version 10 is only supported since cmake 3.31.
From the link you provided.
Preset files specifying version 10 or above may include comments using the key $comment at any level within the JSON object to provide documentation.
10 Added in version 3.31.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Thanks!
Could you update the PR description before you merge this? |
Updated, thanks. I'll also do some final verification for this change later before merging. |
@github-actions crossbow submit -g cpp |
@github-actions crossbow submit -g python |
Revision: 20da6bf Submitted crossbow builds: ursacomputing/crossbow @ actions-a28de98f4d |
Revision: 20da6bf Submitted crossbow builds: ursacomputing/crossbow @ actions-489c8994f2 |
Hi @kou , sorry to bother you again. The test-ubuntu-22.04-cpp-emscripten failure is related, because the reordering from
to
messed up the We can again tune the overriding of |
Hmm. I'm OK with it if we can use comment in the JSON... In general, we should use I think that |
Thank you so much for the confirmation.
Yes, that seems to be the general rule for inheritance.
I personally think introducing number prefix could be a bit overkill. And hope that the repeating occurrences of I'll rework the PR, keeping the non-related refinement, and reducing the ordering stuff. |
@github-actions crossbow submit -g cpp |
@github-actions crossbow submit -g python |
Revision: 7150e71 Submitted crossbow builds: ursacomputing/crossbow @ actions-8d07c78518 |
Revision: 7150e71 Submitted crossbow builds: ursacomputing/crossbow @ actions-212fbf47c1 |
@github-actions crossbow submit -g cpp python |
|
@github-actions crossbow submit -g cpp |
@github-actions crossbow submit -g python |
Revision: 424a9a2 Submitted crossbow builds: ursacomputing/crossbow @ actions-1e52e8655b |
Revision: 424a9a2 Submitted crossbow builds: ursacomputing/crossbow @ actions-06bc23cb35 |
I've refined the code and validated that all the variables set in each preset are as expected. Other than the allocators being disabled for sanitizer presets (as intended), there is another diff for @kou would you mind to look again? Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
We don't need to keep old descriptions with XXX. Because we can see old descriptions by GitHub's UI. We can use only the latest description for commit message.
Co-authored-by: Sutou Kouhei <[email protected]>
PR description updated. |
The CI failures are not related. Merging. I appreciate the comments and help from @kou , thank you! |
Rationale for this change
I gave the reason in #45209
What changes are included in this PR?
Adjust the inheritance list order and make a lot of simplification/regrouping/reordering for existing presets the way I see fit.
Also introduce a soft rule to order inheritance list:
sanitizer
comes beforefeatures
comes beforebase
. Though we can't really mandate such a rule (thus it's "soft") or make it clear in comments (our current cmake dosn't support comment in json), we hope people will notice this pattern and follow it when editing this file.Are these changes tested?
Manually tested.
Are there any user-facing changes?
None.