Skip to content

Stop resolving the UTC time zone in TimezoneMixin - #115488

Merged
thevar1able merged 1 commit into
masterfrom
cli-startup-lazy-utc-timezone
Aug 20, 2026
Merged

thevar1able merged 1 commit into
masterfrom
cli-startup-lazy-utc-timezone

Conversation

@thevar1able

@thevar1able thevar1able commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

While profiling clickhouse local --query "SELECT 1" it turned out that almost all of the run happens before the query: the query itself took 1ms of a 45ms run. This is one of the sources of that startup work, split out of #112496.

TimezoneMixin resolved the UTC time zone in its constructor, in addition to the named or default one. Building a DateLUTImpl walks ~146k days through cctz, about 70M instructions, and DataTypeDateTime / DataTypeDateTime64 get constructed just to name a column type — for example when building the schemas of the system tables — without ever touching UTC.

Only the serializations need UTC, for ISO output and for the best_effort parsers, so SerializationDateTime, SerializationDateTime64 and the DateTime / DateTime64 nodes of JSONExtractTree declare their own utc_time_zone member instead. The cost is then paid once per formatter rather than once per named type.

Changelog category (leave one):

  • Performance Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Naming a DateTime or DateTime64 type no longer builds a UTC time zone lookup table that nothing reads, which makes constructing these types — and therefore starting up clickhouse local and clickhouse client — faster.


Workflow [PR]
Sync PR [sync-upstream/pr/115488]

Version info

  • Merged into: 26.8.1.1780 (included in 26.8 and later)

`TimezoneMixin` resolved the UTC time zone in its constructor, in addition to the
named or default one. Building a `DateLUTImpl` walks ~146k days through cctz
(~70M instructions), and `DataTypeDateTime` / `DataTypeDateTime64` are
constructed just to name a column type - for example when building the schemas of
the system tables - without ever touching UTC. Only the serializations need it,
for ISO output and the `best_effort` parsers, so they declare their own
`utc_time_zone` and pay for it once per formatter.

This is one of the sources of startup work found while profiling
`clickhouse local --query "SELECT 1"`, which spent most of its time before the
query.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a445963]

Summary: ✅


AI Review

Summary

This PR removes eager UTC DateLUT construction from TimezoneMixin and moves that cost to the DateTime / DateTime64 serializations and JSON extract nodes that actually use UTC. The code motion looks consistent and I did not find a correctness or compatibility regression in the touched carriers, but the PR still lacks the before/after measurement needed to justify the Performance Improvement contract.

Tests
  • ⚠️ Performance Improvement PRs need evidence of the claimed win. The description explains the cost center, but it does not show a before/after result for clickhouse local --query "SELECT 1" or a focused benchmark around constructing DateTime / DateTime64 types. Please add the smallest measurement that demonstrates the startup reduction.
Final Verdict

⚠️ No code-level blockers found, but this still needs a small before/after measurement before I would merge it as a Performance Improvement PR.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.90% 87.00% +0.10%
Functions 92.00% 92.00% +0.00%
Branches 79.20% 79.40% +0.20%

Changed lines: Changed C/C++ lines covered: 10/10 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label Aug 19, 2026
@yariks5s yariks5s self-assigned this Aug 19, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing a445963bb with master 581c15c46 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 702.08 MiB 699.05 MiB -3.03 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

598 translation units recompiled, 4344 s compile time in total, 598 of them have a recent master baseline.

Job report

@clickhouse-gh

clickhouse-gh Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 34 queries analysed

This PR removes an always-unused UTC DateLUT build from DateTime/DateTime64 type construction — a startup and type-construction cost, not a query-execution change. Every flagged query is an improvement, across unrelated operations including pure-Date TPC-H queries that never construct a DateTime type, and the changed code does not run in any of these hot paths, so all directional deltas were downgraded to not-sure as systematic run-to-run variance (note also only 6 source runs vs 30 base). Q31's within-envelope suppression is consistent with that same one-directional offset and stands. Re-run on matched hardware to confirm these numbers are noise before reading any speedup into them.

clickbench

⚠️ 8 inconclusive

Flagged queries (8 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 13 not_sure 424 332 -21.6% <0.0001 This PR only removes an always-unused UTC lookup-table build from DateTime type construction; it doesn't touch Q13's scan/aggregation path, so the -21.6% delta reads as off-path variance.
⚠️ 15 not_sure 193 159 -17.6% <0.0001 The diff is a DateTime type-construction/startup optimization, not a query-execution change, so this -17.6% shift is not plausibly caused by the PR.
⚠️ 16 not_sure 726 601 -17.2% <0.0001 Nothing in the changed DateTime serialization code runs in Q16's hot path; the -17.2% improvement is off-path run-to-run variance.
⚠️ 18 not_sure 1271 1049 -17.5% <0.0001 The PR removes a redundant UTC DateLUT construction; it cannot speed up steady-state execution, so the -17.5% delta is variance rather than a PR effect.
⚠️ 23 not_sure 165 77 ×2.1 faster <0.0001 The ×2.1 faster result is not attributable to a DateTime type-construction change, and the source measurements were very noisy, so this reads as off-path variance.
⚠️ 30 not_sure 278 223 -19.8% <0.0001 This -19.8% shift sits on an execution path the PR doesn't touch; the DateLUT-construction change is startup-only, so treat it as variance.
⚠️ 33 not_sure 1242 1162 -6.5% <0.0001 A DateTime type-construction optimization can't move Q33's steady-state execution; the -6.5% delta is off-path variance.
⚠️ 34 not_sure 1238 1156 -6.6% <0.0001 Same as Q33: the changed code isn't exercised here, so the -6.6% improvement is run-to-run variance, not a PR effect.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

⚠️ 2 inconclusive

Flagged queries (2 of 22)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 7 not_sure 560 67 ×8.4 faster <0.0001 TPC-H Q7 operates on Date columns and joins/aggregation, none of which touch the changed DateTime serialization code, so the ×8.4 faster result is variance.
⚠️ 8 not_sure 167 77 ×2.2 faster <0.0001 Q8 exercises Date columns and hash joins, not DateTime type construction; the ×2.2 faster result cannot come from this diff and is downgraded as variance.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

Debug info
  • StressHouse run: 096b6303-6db1-4b34-a0f2-5e537b853e65
  • MIRAI run: f0456e28-5ffb-4655-bc7a-3801cbc2e0d1
  • PR check IDs:
    • clickbench_203206_1787177970
    • clickbench_203212_1787177970
    • clickbench_203218_1787177970
    • tpch_adapted_1_official_203235_1787177970
    • tpch_adapted_1_official_203262_1787177970
    • tpch_adapted_1_official_203276_1787177970

@thevar1able
thevar1able added this pull request to the merge queue Aug 20, 2026
Merged via the queue into master with commit 6481bef Aug 20, 2026
179 checks passed
@thevar1able
thevar1able deleted the cli-startup-lazy-utc-timezone branch August 20, 2026 16:42
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-performance Pull request with some performance improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants