perf(shadercache): use faster clock#1275
Conversation
WalkthroughThe changes replace the use of C++'s Changes
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Automated formatting by clang-format, prettier, and other hooks. See https://pre-commit.ci for details.
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the ShaderCache timing system from C++ std::chrono to Windows QueryPerformanceCounter API for improved performance and precision in time measurements during shader compilation.
- Replaces
std::chrono::steady_clockwith WindowsQueryPerformanceCounterAPI - Updates time calculation logic to use high-resolution performance counters
- Standardizes parameter naming from
a_totalmstoa_totalMs
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/ShaderCache.h | Replaces chrono member variables with LARGE_INTEGER performance counter fields and adds constructor for initialization |
| src/ShaderCache.cpp | Updates all timing calculations to use QueryPerformanceCounter and converts to milliseconds when needed |
|
|
||
| double CompilationSet::GetEta() | ||
| { | ||
| double totalMs = static_cast<double>(totalTime.QuadPart) * 1000.0 / frequency.QuadPart; |
There was a problem hiding this comment.
The conversion from performance counter to milliseconds is duplicated in GetEta() and GetStatsString(). Consider extracting this calculation into a private helper method to reduce code duplication.
|
@coderabbitai can you investigate if there are other parts of the code base that would benefit from a similar change in the timer and if so, create a new issue describing the refactor work, leave it unassigned, but tag as a good first issue and help wanted? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain@alandtse I'll investigate the codebase for other timing usage that could benefit from similar performance improvements. Let me search for 🏁 Script executed: Length of output: 165280 Based on my analysis of the codebase, I found several areas that could benefit from similar high-resolution timing optimizations. Let me create a GitHub issue to document this refactor opportunity. 🏁 Script executed: Length of output: 2883 Let me try creating the issue again with the available labels: 🏁 Script executed: Length of output: 2870 @alandtse Perfect! I've successfully created GitHub issue #1276 documenting additional timer optimization opportunities. After analyzing the codebase, I identified several areas that could benefit from similar QueryPerformanceCounter optimizations as implemented in this PR: Primary Target (High Priority):
Secondary Targets:
The issue has been tagged as "good first issue" and "help wanted" as requested, and left unassigned. It includes detailed implementation guidelines following the pattern established in PR #1275, specific file locations, and testing recommendations. The State.cpp frame timing optimization would likely provide the most significant performance benefit since it's used for real-time per-frame shader performance measurement, similar to the shader compilation timing that was optimized in this PR. 🧠 Learnings used |
|
✅ A pre-release build is available for this PR: |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Automated formatting by clang-format, prettier, and other hooks. See https://pre-commit.ci for details.
|
Tested in game. I'm not sure this buys us much since it's just the cache compilation measuring. |
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Alan Tse <alandtse@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary by CodeRabbit
Refactor
Style