doris icon indicating copy to clipboard operation
doris copied to clipboard

[Bug] SpillReadDeserializeBlockTime is always 0 in query profiles

Open zhuxiangyi opened this issue 3 months ago • 1 comments

Search before asking

  • [X] I had searched in the issues and found no similar issues.

Version

master, commit 5202d06dd8

What's Wrong?

SpillReadDeserializeBlockTime is always 0 in query profiles. The time spent deserializing spilled blocks has never been recorded for any spill-enabled query.

The counter is registered by SpillReadCounters::init under the shared name constant profile::SPILL_READ_DESERIALIZE_BLOCK_TIME, whose value is "SpillReadDeserializeBlockTime":

// be/src/exec/operator/spill_counters.h
spill_read_deserialize_block_timer =
        ADD_TIMER_WITH_LEVEL(profile, profile::SPILL_READ_DESERIALIZE_BLOCK_TIME, 1);
// be/src/runtime/runtime_profile_counter_names.h:116
inline constexpr char SPILL_READ_DESERIALIZE_BLOCK_TIME[] = "SpillReadDeserializeBlockTime";

But SpillFileReader resolves it with a hand-written literal that is missing an s:

// be/src/exec/spill/spill_file_reader.cpp:50
_deserialize_timer = custom_profile->get_counter("SpillReadDerializeBlockTime");
//                                                        ^^^ "Derialize"

get_counter() returns nullptr for the unknown name, and ScopedTimer returns early when the counter is null:

// be/src/runtime/runtime_profile.h:855
ScopedTimer(RuntimeProfile::Counter* counter, const Bool* is_cancelled = nullptr)
        : _counter(counter), _is_cancelled(is_cancelled) {
    if (counter == nullptr) {
        return;
    }

So SCOPED_TIMER(_deserialize_timer) in SpillFileReader::read() silently measures nothing, and the counter stays at its initial 0.

The same misspelling is also present in two unit tests (be/test/vec/spill/spill_file_test.cpp, be/test/vec/spill/spill_repartitioner_test.cpp), which register the counters by hand. That is why the gap went unnoticed: the reader's lookup matches in those tests while returning null in a real query.

Only this one name is affected — the other 15 get_counter() literals under be/src/exec/spill/ match their constants.

What You Expected?

SpillReadDeserializeBlockTime should report the actual time spent in Block::deserialize() when reading spilled data back, so that deserialization cost is visible when diagnosing slow spill-enabled queries.

How to Reproduce?

Run any query that spills and reads the data back, then inspect the profile:

set enable_spill = true;
set enable_force_spill = true;
set enable_profile = true;

select l_orderkey, count(*) from lineitem group by l_orderkey;

In the resulting profile, under the aggregation source operator's CustomCounters, SpillReadDeserializeBlockTime reads 0ns while sibling counters such as SpillReadFileTime, SpillReadBlockCount and SpillReadRows are populated.

Anything Else?

The fix is a one-name change, but it is worth resolving the counters through the shared profile:: constants rather than repeating string literals, so the same drift cannot recur silently.

Are you willing to submit PR?

  • [X] Yes I am willing to submit a PR!

Code of Conduct

zhuxiangyi avatar Aug 22 '26 08:08 zhuxiangyi

Breakwater initial analysis

Assessment: confirmed bug, high confidence. This is an observability defect in the spill-read profile path; the inspected path does not indicate an effect on query results or spill execution itself.

Verified facts

  • At commit 5202d06dd8, PipelineXSpillLocalState::init() initializes SpillReadCounters on CustomCounters, and SpillReadCounters::init() registers profile::SPILL_READ_DESERIALIZE_BLOCK_TIME, whose value is SpillReadDeserializeBlockTime.
  • SpillFileReader instead looks up SpillReadDerializeBlockTime. RuntimeProfile::get_counter() returns nullptr when that name is absent.
  • SCOPED_TIMER(_deserialize_timer) surrounds the decode work in SpillFileReader::read(), but ScopedTimer deliberately performs no timing or update when its counter is null. The correctly registered production counter therefore remains at its initial value.
  • The same misspelled name is manually registered in spill_file_test.cpp and spill_repartitioner_test.cpp, so those fixtures give the reader a non-null counter and mask the production mismatch. The existing ReadCounters test checks block, row, and byte counters but not the deserialize timer.
  • The typo is isolated to these three occurrences in the inspected tree: the reader lookup and the two test fixtures.

One semantic nuance: the current timer scope includes both protobuf ParseFromArray() and Block::deserialize(). Correcting the lookup will measure that existing combined decode scope; narrowing it to only Block::deserialize() would be a separate semantics decision.

Missing information

No additional version, logs, profile, or reproduction details are required to confirm the root cause. The issue identifies an exact revision and a deterministic registration/lookup mismatch. The issue currently has no labels, assignee, milestone, or linked PR.

Recommended next steps

  1. Accept this as a valid, narrowly scoped profile-counter bug and let the reporter submit the offered PR.
  2. Resolve the reader's counter names through the shared constants (using a fully qualified name such as doris::profile::SPILL_READ_DESERIALIZE_BLOCK_TIME where the profile function parameter would otherwise shadow the namespace). Prefer converting the other spill reader lookups at the same time to prevent another silent string drift.
  3. Correct both test fixtures to register the canonical name, ideally through the same shared counter initialization path used in production.
  4. Extend SpillFileTest.ReadCounters to assert that the canonical SpillReadDeserializeBlockTime counter exists and is updated after an actual spill-file read. This is the regression assertion currently missing.
  5. Run the spill file and spill repartitioner BE unit tests and the normal BE formatting checks. A full cluster/profile reproduction is useful as end-to-end confirmation but is not necessary to establish this code-level defect.

Breakwater-GitHub-Analysis-Slot: slot_51a4a1e991e2

Doris-Breakwater avatar Aug 22 '26 08:08 Doris-Breakwater