From f2399cb0ac897ae40d351b8e5074de435f99b5ea Mon Sep 17 00:00:00 2001 From: Mryange Date: Mon, 3 Aug 2026 10:12:12 +0800 Subject: [PATCH] [improvement](be) Avoid eager formatting in hot paths ### What problem does this PR solve? Issue Number: None Related PR: #66363 Problem Summary: Successful delete bitmap cache checks repeatedly traversed both bitmaps to construct an unused error message, and nullable LARGEINT Arrow serialization formatted values before checking whether rows were null. Reuse the computed bitmap cardinalities, construct the mismatch message only on failure, and format LARGEINT values only for non-null rows. ### Release note None ### Check List (For Author) - Test: No need to test (control flow-only optimization; clang-format and git diff checks completed) - Behavior changed: No - Does this need documentation: No --- be/src/cloud/cloud_tablet.cpp | 16 ++++++++-------- .../data_type_serde/data_type_number_serde.cpp | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/be/src/cloud/cloud_tablet.cpp b/be/src/cloud/cloud_tablet.cpp index 7827c438bf9f54..9e5c1eac6f3293 100644 --- a/be/src/cloud/cloud_tablet.cpp +++ b/be/src/cloud/cloud_tablet.cpp @@ -1540,14 +1540,14 @@ Status CloudTablet::check_delete_bitmap_cache(int64_t txn_id, Status st = engine.txn_delete_bitmap_cache().get_delete_bitmap( txn_id, tablet_id(), &cached_delete_bitmap, nullptr, nullptr); if (st.ok()) { - bool res = (expected_delete_bitmap->cardinality() == cached_delete_bitmap->cardinality()); - auto msg = fmt::format( - "delete bitmap cache check failed, cur_cardinality={}, cached_cardinality={}" - "txn_id={}, tablet_id={}", - expected_delete_bitmap->cardinality(), cached_delete_bitmap->cardinality(), txn_id, - tablet_id()); - if (!res) { - DCHECK(res) << msg; + const auto expected_cardinality = expected_delete_bitmap->cardinality(); + const auto cached_cardinality = cached_delete_bitmap->cardinality(); + if (expected_cardinality != cached_cardinality) { + auto msg = fmt::format( + "delete bitmap cache check failed, cur_cardinality={}, cached_cardinality={}" + "txn_id={}, tablet_id={}", + expected_cardinality, cached_cardinality, txn_id, tablet_id()); + DCHECK_EQ(expected_cardinality, cached_cardinality) << msg; return Status::InternalError(msg); } } diff --git a/be/src/core/data_type_serde/data_type_number_serde.cpp b/be/src/core/data_type_serde/data_type_number_serde.cpp index 72fcad1a6500ea..4d4ec603cb3e9e 100644 --- a/be/src/core/data_type_serde/data_type_number_serde.cpp +++ b/be/src/core/data_type_serde/data_type_number_serde.cpp @@ -583,12 +583,12 @@ Status DataTypeNumberSerDe::write_column_to_arrow(const IColumn& column, cons } else if constexpr (T == TYPE_LARGEINT) { auto& string_builder = assert_cast(*array_builder); for (size_t i = start; i < end; ++i) { - auto& data_value = col_data[i]; - std::string value_str = fmt::format("{}", data_value); if (null_map && (*null_map)[i]) { RETURN_IF_ERROR( checkArrowStatus(string_builder.AppendNull(), column, *array_builder)); } else { + const auto& data_value = col_data[i]; + std::string value_str = fmt::format("{}", data_value); RETURN_IF_ERROR(checkArrowStatus( string_builder.Append(value_str.data(), cast_set(value_str.length())),