Skip to content

Use minipal timers directly in GC - #132197

Merged
jkotas merged 7 commits into
mainfrom
copilot/add-build-time-check-queryunbiasedinterrup
Aug 14, 2026
Merged

Use minipal timers directly in GC#132197
jkotas merged 7 commits into
mainfrom
copilot/add-build-time-check-queryunbiasedinterrup

Conversation

Copilot AI commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #126551 (comment)

  • Remove GC low- and high-resolution timer wrappers from GCToOSInterface.
  • Replace GC callers with minipal_lowres_ticks, minipal_hires_ticks, and minipal_hires_tick_frequency.
  • Keep platform-specific timer implementation centralized in minipal; no build-time availability checks added.

Copilot AI lite review requested due to automatic review settings August 12, 2026 03:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
16 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 12, 2026 03:36
Copilot AI changed the title [WIP] Add build-time check for QueryUnbiasedInterruptTime availability Use minipal timers directly in GC Aug 12, 2026
Copilot AI requested a review from jkotas August 12, 2026 03:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Comment thread src/coreclr/gc/env/gcenv.os.h
Comment thread src/coreclr/gc/interface.cpp Outdated
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 12, 2026 04:06
Copilot AI requested a review from jkotas August 12, 2026 04:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

src/coreclr/gc/env/gcenv.os.h:14

  • The PR metadata claims to fix #126551 (QueryUnbiasedInterruptTime availability), but this change only switches GC call sites to minipal_lowres_ticks()/minipal_hires_ticks() without adding the requested availability check/fallback. minipal_lowres_ticks() on Windows still calls QueryUnbiasedInterruptTime unconditionally, so the original partition-availability concern remains. Please either (a) implement the feature check + fallback in minipal (and align other call sites), or (b) drop the “Fixes #126551” linkage / update the PR scope accordingly.
#include <minipal/mutex.h>
#include <minipal/time.h>

Comment thread src/coreclr/gc/mark_phase.cpp Outdated
Copilot AI review requested due to automatic review settings August 12, 2026 04:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

Suppressed comments (3)

src/coreclr/gc/mark_phase.cpp:2085

  • These dprintf calls use %d but pass an int64_t tick delta (minipal_lowres_ticks() - begin_tick). This is a varargs type mismatch (undefined behavior) on some ABIs; use a 64-bit format specifier consistent with the rest of the GC logging.
                    dprintf (SNOOP_LOG, ("heap%d: marking %zx from %d [%d] tl:%dms",
                            heap_number, (size_t)o, (heap_number+1)%n_heaps, level,
                            (minipal_lowres_ticks()-begin_tick)));

src/coreclr/gc/mark_phase.cpp:2094

  • This dprintf call uses %d/%d for millisecond tick deltas, but the arguments are int64_t (minipal_lowres_ticks() - start_tick / - begin_tick). This is a varargs type mismatch; update the format string to 64-bit specifiers.
                    dprintf (SNOOP_LOG, ("heap%d: done marking %zx from %d [%d] %dms tl:%dms",
                            heap_number, (size_t)o, (heap_number+1)%n_heaps, level,
                            (minipal_lowres_ticks()-start_tick),(minipal_lowres_ticks()-begin_tick)));

src/coreclr/gc/env/gcenv.os.h:14

  • PR description says this fixes #126551 (QueryUnbiasedInterruptTime availability), but after switching GC call sites to minipal_lowres_ticks() the underlying implementation in src/native/minipal/time.c still calls QueryUnbiasedInterruptTime unconditionally and asserts on failure. If this API is missing on some Windows partitions, the regression remains—just centralized in minipal. Consider implementing the proposed feature check/fallback (e.g. to GetTickCount64) in minipal before marking the issue as fixed.
#include <minipal/mutex.h>
#include <minipal/time.h>

@jkotas
jkotas requested a review from a team August 12, 2026 04:34
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @anicka-net, @dotnet/gc
See info in area-owners.md if you want to be subscribed.

Comment thread src/coreclr/gc/gcpriv.h Outdated
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 12, 2026 16:30
@jkotas
jkotas requested a review from kkokosa August 12, 2026 16:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Suppressed comments (1)

src/coreclr/gc/env/gcenv.os.h:14

  • This change routes GC low-res timing through minipal_lowres_ticks() (via <minipal/time.h>), but minipal_lowres_ticks() on Windows still calls QueryUnbiasedInterruptTime unconditionally (see src/native/minipal/time.c). If the PR is intended to fix #126551 (API not available in some Windows partitions), this refactor alone doesn’t address the missing-API problem; the fix likely needs to be implemented in minipal (fallback to GetTickCount64 / dynamic lookup) and then consumed here.
#include <minipal/mutex.h>
#include <minipal/time.h>

Comment thread src/coreclr/gc/gc.cpp
Comment thread src/coreclr/gc/interface.cpp
Comment thread src/coreclr/gc/gc.cpp Outdated
…ctly

Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 13, 2026 20:44
Copilot AI requested a review from jkotas August 13, 2026 20:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/coreclr/gc/env/gcenv.os.h:14

  • This change routes GC low-res timing through minipal_lowres_ticks(), but on Windows the minipal implementation still calls QueryUnbiasedInterruptTime directly (see src/native/minipal/time.c). That means the original problem in #126551 (API not present in some Windows partitions, causing link/load failures) is not actually avoided by moving the callsite into minipal unless minipal also has an availability fallback (e.g., GetProcAddress + GetTickCount64 fallback, or a build-time feature macro).
#include <minipal/mutex.h>
#include <minipal/time.h>

@jkotas

jkotas commented Aug 14, 2026

Copy link
Copy Markdown
Member

/ba-g build analysis misclassifying known failures - dotnet/arcade#17340

@jkotas
jkotas merged commit be7a025 into main Aug 14, 2026
98 of 102 checks passed
@jkotas
jkotas deleted the copilot/add-build-time-check-queryunbiasedinterrup branch August 14, 2026 14:24
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add build-time check for QueryUnbiasedInterruptTime availability

4 participants