[native] Drop <chrono> from the timing code - #12550
Merged
simonrozsival merged 2 commits intoAug 28, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
src/native/common/include/runtime-base/timing-internal.hh — Suggestion (documentation): The comment above time_interval says “whole milliseconds”, which can… |
What changed in this PR
This PR advances the CoreCLR “drop-libc++ headers” effort by removing <chrono> from native timing code paths and representing timing points/intervals as a plain uint64_t nanosecond count, while preserving the existing timing output format relied on by performance tooling.
Changes:
- Replace
std::chrono-tagged time points withuint64_tnanosecond timestamps (time_point) and compute durations via integer arithmetic. - Introduce a shared
time_intervalhelper to centralize the seconds / total-milliseconds / nanoseconds-within-millisecond split used in multiple log formats. - Switch the timing clock source from
CLOCK_MONOTONIC_RAWtoCLOCK_MONOTONICand remove an unused<chrono>include.
| File | Description |
|---|---|
| src/native/mono/monodroid/monodroid-glue.cc | Use time_interval for JIT timing log formatting instead of std::chrono duration casts. |
| src/native/common/runtime-base/timing-internal.cc | Remove <chrono> usage and format accumulated timing results via time_interval. |
| src/native/common/include/runtime-base/timing.hh | Use time_interval for managed timing sequence log formatting; initialize start/end as 0. |
| src/native/common/include/runtime-base/timing-internal.hh | Redefine time_point as uint64_t, add time_interval, remove <chrono>, and update get_time() implementation/clock. |
| src/native/common/include/runtime-base/mainthread-dso-loader.hh | Drop unused <chrono> include. |
simonrozsival
force-pushed
the
dev/simonrozsival/clr-drop-chrono
branch
2 times, most recently
from
August 28, 2026 06:10
f47cca6 to
0d37fc3
Compare
simonrozsival
force-pushed
the
dev/simonrozsival/clr-drop-chrono
branch
2 times, most recently
from
August 28, 2026 07:54
864a3eb to
ce91e4c
Compare
simonrozsival
force-pushed
the
dev/simonrozsival/clr-drop-chrono
branch
from
August 28, 2026 08:47
ce91e4c to
8941965
Compare
simonrozsival
force-pushed
the
dev/simonrozsival/clr-drop-chrono
branch
from
August 28, 2026 08:56
8941965 to
bf9157b
Compare
simonrozsival
force-pushed
the
dev/simonrozsival/clr-drop-chrono
branch
from
August 28, 2026 09:51
bf9157b to
67df971
Compare
simonrozsival
force-pushed
the
dev/simonrozsival/clr-drop-chrono
branch
from
August 28, 2026 10:29
67df971 to
f50052b
Compare
`FastTiming::get_time()` already read the clock with `clock_gettime()`; `std::chrono::steady_clock` was only used as the type tag of the `chrono::time_point` the result was wrapped in. Store the timestamps as a plain `uint64_t` nanosecond count instead and drop `<chrono>` from the four files that included it (it was entirely unused in mainthread-dso-loader.hh). All four places that formatted an interval repeated the same seconds/milliseconds/nanoseconds split, so they now share a `time_interval` helper. The split is reproduced exactly as `chrono::duration_cast` computed it, so the timing output is unchanged - this matters because the format after the first colon is parsed by our performance measuring utilities. Also read `CLOCK_MONOTONIC` rather than `CLOCK_MONOTONIC_RAW`, so that we keep using the same clock `steady_clock` was documented to use. The two differ only in that `CLOCK_MONOTONIC` is slewed by NTP, which is irrelevant at the granularity we measure. This does not remove any undefined libc++ symbols - `<chrono>` is header only - but it does shrink libnet-android.release.so by 80 bytes and removes one more libc++ header from the build. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0a35a0db-502d-48c0-8468-e73b5dd0ab2e
…tals Addresses review feedback. Both fields are totals for the whole interval and both are printed, so `milliseconds` is not milliseconds-within-the-second. The output format is consumed by performance measuring utilities, so spell this out to keep a future change from "correcting" it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0a35a0db-502d-48c0-8468-e73b5dd0ab2e
simonrozsival
force-pushed
the
dev/simonrozsival/clr-drop-chrono
branch
from
August 28, 2026 12:06
f50052b to
d350d84
Compare
Base automatically changed from
dev/simonrozsival/clr-replace-std-function
to
dev/simonrozsival/clr-timing-free-list
August 28, 2026 12:42
Member
Author
|
Consolidated into #12545 to reduce the depth of the #12546 stack. No code changed: the commits from this PR are now part of #12545 unmodified, and the resulting tree is byte-identical. This PR sat directly on top of #12545 and touched the same files, so reviewing them together is easier than reviewing the same file across two intermediate states. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Part of the drop-libc++ work for CoreCLR.
FastTiming::get_time()has always read the clock withclock_gettime()directly — the comment above it even says we do that to avoid calling into libc++:std::chrono::steady_clockwas then used only as the type tag of thechrono::time_pointwe wrapped the result in. So we were paying for<chrono>without using the clock it provides.This PR stores timestamps as a plain
uint64_tnanosecond count and removes<chrono>from the four files that included it. Inmainthread-dso-loader.hhthe include was entirely unused.Sharing the interval formatting
Four places repeated the same seconds / milliseconds / nanoseconds-within-the-millisecond split, so they now share one helper:
The split reproduces
chrono::duration_castexactly, including the fact that the middle field is the total milliseconds rather than a remainder. The timing output is byte-for-byte unchanged, which matters because the format after the first colon is parsed by our performance measuring utilities.I verified this rather than assuming it: a standalone harness compared the old
chronocomputation againsttime_intervalover the nine interesting edge cases (0,999999,1000000,1000001,999999999,1000000000, …,INT64_MAX) plus 2,000,000 random values — 2,000,009 checked, 0 mismatches.CLOCK_MONOTONIC_RAW → CLOCK_MONOTONIC
We now read
CLOCK_MONOTONIC, the clocksteady_clockis specified to use, instead ofCLOCK_MONOTONIC_RAW. The two differ only in thatCLOCK_MONOTONICis slewed by NTP, which is irrelevant at the granularity we measure.Results
This does not remove any undefined libc++ symbols — the count stays at 59.
<chrono>is header-only, so it never contributed any. What it does do is shrink the binary slightly and remove one more libc++ header from the build, which is a prerequisite for eventually building without libc++ headers at all:libnet-android.release.sotiming-internal.cc.o(Measured against a real rebuild of the parent commit, not remembered numbers.)
Testing
format_managed_type_namewarning).time_intervalverified againstchronoover 2,000,009 inputs as described above.