This is an archive of the discontinued LLVM Phabricator instance.

[CMake][benchmark] Cache result of CXXFeatureCheck
Needs ReviewPublic

Authored by beanz on May 1 2019, 10:08 AM.

Details

Summary

This check is actually pretty expensive. When cross-compiling it compiles and links, when not cross compiling it compiles, links and runs. By not caching this value we re-run the test every time cmake gets re-invoked.

In my local tests this change reduced iterative CMake executions from ~10.2 seconds to ~9.7 seconds.

Event Timeline

beanz created this revision.May 1 2019, 10:08 AM
Herald added a project: Restricted Project. · View Herald Transcript

In general, yes, these checks can be expensive. I wish that there was a way to ensure that the naming of the features was consistent across all the projects so that the same tests do not need to be rerun.

llvm/utils/benchmark/cmake/CXXFeatureCheck.cmake
56

Mind using ON here?

64

Mind using OFF here?

beanz updated this revision to Diff 197593.May 1 2019, 10:50 AM

Updating based on review feedback.

lebedev.ri retitled this revision from [CMake] Cache result of CXXFeatureCheck to [CMake][benchmark] Cache result of CXXFeatureCheck.May 1 2019, 12:39 PM

Please can you submit these changes upstream first?
(There are two other copies of benchmark - in libcxx, and test-suite)

Also, it's not a great idea to store something into cache/global scope without ensuring unique global prefix, so please change HAVE_ to BENCHMARK_HAVE_

beanz added a comment.May 1 2019, 2:21 PM

@lebedev.ri I actually disagree with prefixing capabilities check variables. If other projects are checking the same thing you want them to use the same variable so that they don't all check the same thing over and over again.

Also, why is this duplicated between libcxx, test-suite and llvm? There is functionality in the libcxx build that requires the LLVM CMake modules (like building the tests), so it seems like a better solution would be having this module be a llvm CMake module that is shared across the other projects.

lebedev.ri requested changes to this revision.May 1 2019, 2:25 PM

@lebedev.ri I actually disagree with prefixing capabilities check variables. If other projects are checking the same thing you want them to use the same variable so that they don't all check the same thing over and over again.

Or they happen to just use the same name but use it for different things.

Also, why is this duplicated between libcxx, test-suite and llvm? There is functionality in the libcxx build that requires the LLVM CMake modules (like building the tests), so it seems like a better solution would be having this module be a llvm CMake module that is shared across the other projects.

I'm not sure i follow.
There are three copies of the entire benchmark library - one here in llvm, one in libc++ and one in test-suite.
This isn't just about this cmake file (which is part of the benchmark library)

This revision now requires changes to proceed.May 1 2019, 2:25 PM
beanz added a comment.May 1 2019, 4:08 PM

That kinda makes it worse. We don't duplicate gtest in all the tools that use it, why are we duplicating this library?

That kinda makes it worse. We don't duplicate gtest in all the tools that use it, why are we duplicating this library?

Testsuite can be built without llvm; llvm can be built without testsuite; llvm can be built without libc++ - so you already have two copies - in llvm and testsuite
Likely libc++ also wants to be buildable standalone (including benchmarks)?

beanz added a comment.May 2 2019, 10:58 AM

Libc++'s test cases aren't buildable without LLVM. Why should the benchmarks be?

Libc++'s test cases aren't buildable without LLVM. Why should the benchmarks be?

Note that libc++'s benchmark predates llvm's benchmark,
so if libc++ really doesn't care about building benchmarks in standalone mode,
then i suppose libc++ benchmark is the one you want to drop.
But this isn't particularly relevant to this patch, i suppose.

lebedev.ri resigned from this revision.Jan 12 2023, 4:41 PM

This review seems to be stuck/dead, consider abandoning if no longer relevant.

This revision now requires review to proceed.Jan 12 2023, 4:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2023, 4:41 PM
Herald added a subscriber: StephenFan. · View Herald Transcript