cputime optimize for arm64#3247
Open
dwh110 wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to optimize cpuwide_time_ns() on ARM64 by using the architectural counter frequency (CNTFRQ_EL0) to populate detail::invariant_cpu_freq, shifting initialization away from per-call logic.
Changes:
- On
__aarch64__, routecpuwide_time_ns()to use the cycle-counter path instead of theclock_gettimepath. - Move initialization of
detail::invariant_cpu_freqinto a pre-main initializer, usingCNTFRQ_EL0on ARM64.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/butil/time.h |
Changes cpuwide_time_ns() preprocessor gating to include ARM64 in the invariant-counter fast path and removes lazy init recursion. |
src/butil/time.cpp |
Adds a pre-main initializer to set detail::invariant_cpu_freq, reading CNTFRQ_EL0 on ARM64. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
modify using __attribute__((constructor)) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
What problem does this PR solve?
Issue Number: n/a
Problem Summary: cpugettime optimize for ARM64
What is changed and the side effects?
Changed:
detail::invariant_cpu_freq value get by CNTFRQ_EL0
Side effects:
Performance effects:
Breaking backward compatibility: 无
Check List: