Skip to content

Commit 13fca3d

Browse files
morningmanclaude
andcommitted
[opt](build) Cut three hot include edges: pod_array, column.h, wide_integer
- core/pod_array.h no longer includes runtime/thread_context.h: dead include left over from the PODArray memory-tracking experiment (apache#50549); the tracking logic has since moved into Allocator and pod_array.h references no thread_context symbol. 203 TUs stop seeing thread_context.h and 195 of them stop seeing exec_env.h (differential payload 1.37MB per TU). - core/column/column.h no longer includes exec/sort/hybrid_sorter.h (core -> exec layering violation): HybridSorter only appears in virtual signatures, which the forward declaration covers; pdqsort/timsort leave 808 TUs. - wide_integer_impl.h defines the from-double members (set_multiplier / wide_integer_from_builtin(double)) inline only where the 80-bit long double exists (LDBL_MANT_DIG == 64 — unchanged and still constexpr there) or inside the dedicated impl TU core/wide_integer_from_double.cpp; every other TU sees declarations only and drops boost/multiprecision + boost/math from its closure (4.27MB preprocessed x 1169 TUs; the members were never constexpr on these platforms, so no constant evaluation is lost). - check-header-deps.py: two new rules (pod_array.h !-> thread_context.h, column.h !-> exec/sort/). No formal rule for the boost edge: the scanner is preprocessor-blind and would flag the impl TU's gated include; the macro structure is self-guarding (breaking it fails the impl TU build). Preprocessed closure of column.h: 16.72MB -> 10.15MB (-39%). Syntax sweep: 1358 TUs; failures identical to the 4 known pre-existing merge artifacts (stale gensrc x3, apache#66242 template-only call site), zero new. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent c2bf234 commit 13fca3d

4 files changed

Lines changed: 48 additions & 6 deletions

File tree

‎be/src/core/column/column.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "core/string_ref.h"
3737
#include "core/typeid_cast.h"
3838
#include "core/types.h"
39-
#include "exec/sort/hybrid_sorter.h"
4039
#include "storage/olap_common.h"
4140

4241
namespace doris {

‎be/src/core/pod_array.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "common/compiler_util.h" // IWYU pragma: keep
3636
#include "core/allocator.h" // IWYU pragma: keep
3737
#include "core/memcpy_small.h"
38-
#include "runtime/thread_context.h"
3938

4039
#ifndef NDEBUG
4140
#include <sys/mman.h>

‎be/src/core/wide_integer_impl.h‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
// and modified by Doris
2424
#pragma once
2525

26-
#include <boost/math/special_functions/fpclassify.hpp>
2726
#include <cassert>
2827
#include <cfloat>
2928
#include <cmath>
@@ -37,13 +36,28 @@
3736

3837
/// Use same extended double for all platforms
3938
#if (LDBL_MANT_DIG == 64)
39+
#include <boost/math/special_functions/fpclassify.hpp>
40+
4041
#define CONSTEXPR_FROM_DOUBLE constexpr
42+
#define DORIS_WIDE_FROM_DOUBLE_INLINE 1
4143
using FromDoubleIntermediateType = long double;
42-
#else
44+
#elif defined(DORIS_WIDE_INTEGER_FROM_DOUBLE_IMPL_TU)
45+
#include <boost/math/special_functions/fpclassify.hpp>
4346
#include <boost/multiprecision/cpp_bin_float.hpp>
4447
/// `wide_integer_from_builtin` can't be constexpr with non-literal `cpp_bin_float_double_extended`
4548
#define CONSTEXPR_FROM_DOUBLE
49+
#define DORIS_WIDE_FROM_DOUBLE_INLINE 1
4650
using FromDoubleIntermediateType = boost::multiprecision::cpp_bin_float_double_extended;
51+
#else
52+
/// Platforms without an 80-bit long double emulate the intermediate type with
53+
/// boost::multiprecision, which drags ~4.3MB of preprocessed closure into every
54+
/// TU. Ordinary TUs therefore see only declarations of the two from-double
55+
/// members below; the bodies are compiled once in
56+
/// core/wide_integer_from_double.cpp (which defines the *_IMPL_TU macro above
57+
/// and emits explicit instantiations). wide_integer_from_builtin(double) was
58+
/// never constexpr on these platforms, so no constant evaluation is lost.
59+
#define CONSTEXPR_FROM_DOUBLE
60+
#define DORIS_WIDE_FROM_DOUBLE_INLINE 0
4761
#endif
4862

4963
namespace wide {
@@ -308,7 +322,11 @@ struct integer<Bits, Signed>::_impl {
308322
* a_(n - 1) = a_n * max_int + b2, a_n <= max_int <- base case.
309323
*/
310324
template <class T>
311-
constexpr static void set_multiplier(integer<Bits, Signed>& self, T t) noexcept {
325+
CONSTEXPR_FROM_DOUBLE static void set_multiplier(integer<Bits, Signed>& self, T t) noexcept
326+
#if !DORIS_WIDE_FROM_DOUBLE_INLINE
327+
;
328+
#else
329+
{
312330
constexpr uint64_t max_int = std::numeric_limits<uint64_t>::max();
313331
static_assert(std::is_same_v<T, double> || std::is_same_v<T, FromDoubleIntermediateType>);
314332
/// Implementation specific behaviour on overflow (if we don't check here, stack overflow will triggered in bigint_cast).
@@ -343,9 +361,14 @@ struct integer<Bits, Signed>::_impl {
343361
self += static_cast<uint64_t>(t - floor(static_cast<double>(alpha)) *
344362
static_cast<T>(max_int)); // += b_i
345363
}
364+
#endif
346365

347366
CONSTEXPR_FROM_DOUBLE static void wide_integer_from_builtin(integer<Bits, Signed>& self,
348-
double rhs) noexcept {
367+
double rhs) noexcept
368+
#if !DORIS_WIDE_FROM_DOUBLE_INLINE
369+
;
370+
#else
371+
{
349372
constexpr int64_t max_int = std::numeric_limits<int64_t>::max();
350373
constexpr int64_t min_int = std::numeric_limits<int64_t>::lowest();
351374

@@ -374,6 +397,7 @@ struct integer<Bits, Signed>::_impl {
374397
self = -self;
375398
}
376399
}
400+
#endif
377401

378402
template <size_t Bits2, typename Signed2>
379403
constexpr static void wide_integer_from_wide_integer(

‎build-support/check-header-deps.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,26 @@
197197
"thrift and forward-declared); this was a dead include spreading PBlock "
198198
"and segment_v2.pb.h to ~595 TUs through thread_context.h",
199199
),
200+
(
201+
"core/pod_array.h",
202+
"runtime/thread_context.h",
203+
set(),
204+
"dead include left over from the PODArray memory-tracking experiment "
205+
"(#50549); the tracking logic since moved into Allocator and pod_array.h "
206+
"references no thread_context symbol, yet the edge dragged thread_context, "
207+
"exec_env.h and mem_tracker_limiter.h into 203 TUs of core/",
208+
),
209+
(
210+
"core/column/column.h",
211+
"exec/sort/",
212+
set(),
213+
"core must not depend on the exec sort machinery: column.h only names "
214+
"HybridSorter in virtual signatures (forward-declared, bodies in "
215+
"column.cpp); the old hybrid_sorter.h include was a layering violation "
216+
"that pushed pdqsort/timsort into 808 TUs "
217+
"(exec/common/endian.h still rides in via storage/olap_common.h -> "
218+
"util/hash_util.hpp, a separate pre-existing wart)",
219+
),
200220
]
201221

202222
# Forward-declaration headers are the sanctioned way through a barrier: they carry

0 commit comments

Comments
 (0)