mirror of
https://github.com/simdjson/simdjson
synced 2026-06-08 17:27:07 +00:00
Improve build times for debug builds (#1859)
* Rename simdjson_really_inline -> simdjson_inline I want to change the simdjson_really_inline macro to sometimes not force inlining. After that upcoming change, the name simdjson_really_inline will no longer makes sense. Rename simdjson_really_inline to simdjson_inline. This patch should not change semantics; simdjson_inline still forces inlining as before. Some functions still need to be really inlined for ABI reasons. (GCC's -Wpsabi complains otherwise.) Leave those functions marked as simdjson_really_inline. * Improve build times for debug builds simdjson_inline is used for most simdjson functions. It forces inlining. In unoptimized/debug builds, this can lead to a lot of machine code being generated (especially with Address Sanitizer), causing slow compilation. Change simdjson_inline to force inlining only for optimized builds. Sometimes, the programmer might want a slightly-optimized build and want fast compilation (e.g. GCC's -Og mode). Allow simdjson users to define the simdjson_inline macro themselves (e.g. on the command line: -Dsimdjson_inline=inline) in cases where the default behavior is undesired. This patch reduced build times by over 75% for ondemand_object_tests.cpp with GCC 9.4.0 and CMAKE_BUILD_TYPE=Debug on my AMD 5950X: Before: 6.885 6.683 6.971 6.957 6.949 seconds (5 samples) After: 1.492 1.551 1.494 1.490 1.531 seconds (5 samples)
This commit is contained in:
@@ -10,17 +10,17 @@ namespace {
|
||||
using namespace simd;
|
||||
|
||||
struct json_character_block {
|
||||
static simdjson_really_inline json_character_block classify(const simd::simd8x64<uint8_t>& in);
|
||||
static simdjson_inline json_character_block classify(const simd::simd8x64<uint8_t>& in);
|
||||
|
||||
simdjson_really_inline uint64_t whitespace() const noexcept { return _whitespace; }
|
||||
simdjson_really_inline uint64_t op() const noexcept { return _op; }
|
||||
simdjson_really_inline uint64_t scalar() const noexcept { return ~(op() | whitespace()); }
|
||||
simdjson_inline uint64_t whitespace() const noexcept { return _whitespace; }
|
||||
simdjson_inline uint64_t op() const noexcept { return _op; }
|
||||
simdjson_inline uint64_t scalar() const noexcept { return ~(op() | whitespace()); }
|
||||
|
||||
uint64_t _whitespace;
|
||||
uint64_t _op;
|
||||
};
|
||||
|
||||
simdjson_really_inline json_character_block json_character_block::classify(const simd::simd8x64<uint8_t>& in) {
|
||||
simdjson_inline json_character_block json_character_block::classify(const simd::simd8x64<uint8_t>& in) {
|
||||
// Functional programming causes trouble with Visual Studio.
|
||||
// Keeping this version in comments since it is much nicer:
|
||||
// auto v = in.map<uint8_t>([&](simd8<uint8_t> chunk) {
|
||||
@@ -74,12 +74,12 @@ simdjson_really_inline json_character_block json_character_block::classify(const
|
||||
return { whitespace, op };
|
||||
}
|
||||
|
||||
simdjson_really_inline bool is_ascii(const simd8x64<uint8_t>& input) {
|
||||
simdjson_inline bool is_ascii(const simd8x64<uint8_t>& input) {
|
||||
simd8<uint8_t> bits = input.reduce_or();
|
||||
return bits.max_val() < 0x80u;
|
||||
}
|
||||
|
||||
simdjson_unused simdjson_really_inline simd8<bool> must_be_continuation(const simd8<uint8_t> prev1, const simd8<uint8_t> prev2, const simd8<uint8_t> prev3) {
|
||||
simdjson_unused simdjson_inline simd8<bool> must_be_continuation(const simd8<uint8_t> prev1, const simd8<uint8_t> prev2, const simd8<uint8_t> prev3) {
|
||||
simd8<bool> is_second_byte = prev1 >= uint8_t(0xc0u);
|
||||
simd8<bool> is_third_byte = prev2 >= uint8_t(0xe0u);
|
||||
simd8<bool> is_fourth_byte = prev3 >= uint8_t(0xf0u);
|
||||
@@ -91,7 +91,7 @@ simdjson_unused simdjson_really_inline simd8<bool> must_be_continuation(const si
|
||||
return is_second_byte ^ is_third_byte ^ is_fourth_byte;
|
||||
}
|
||||
|
||||
simdjson_really_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t> prev2, const simd8<uint8_t> prev3) {
|
||||
simdjson_inline simd8<bool> must_be_2_3_continuation(const simd8<uint8_t> prev2, const simd8<uint8_t> prev3) {
|
||||
simd8<bool> is_third_byte = prev2 >= uint8_t(0xe0u);
|
||||
simd8<bool> is_fourth_byte = prev3 >= uint8_t(0xf0u);
|
||||
return is_third_byte ^ is_fourth_byte;
|
||||
@@ -120,7 +120,7 @@ namespace SIMDJSON_IMPLEMENTATION {
|
||||
namespace {
|
||||
namespace stage1 {
|
||||
|
||||
simdjson_really_inline uint64_t json_string_scanner::find_escaped(uint64_t backslash) {
|
||||
simdjson_inline uint64_t json_string_scanner::find_escaped(uint64_t backslash) {
|
||||
// On ARM, we don't short-circuit this if there are no backslashes, because the branch gives us no
|
||||
// benefit and therefore makes things worse.
|
||||
// if (!backslash) { uint64_t escaped = prev_escaped; prev_escaped = 0; return escaped; }
|
||||
|
||||
Reference in New Issue
Block a user