dotnet / dotnet/sdk

Add timestamp optimization for global.json in dotnetup manifest

Open
#53,395 0 comments 0 reactions 0 assignees View on GitHub
Area-dotnetup
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

## Context

PR https://github.com/dotnet/sdk/pull/53290 introduces install specs that can be sourced from `global.json`. During garbage collection and update workflows, dotnetup re-reads global.json files to refresh the channel/version. Since global.json files are typically small and don't change frequently, we can optimize by storing a timestamp of the last-modified time in the manifest's install spec.

## Proposal

Add a `timestamp` field to global.json-sourced install specs, e.g.:

```json
{
"component": "sdk",
"versionOrChannel": "10.0.1xx",
"installSource": "globalJson",
"globalJsonPath": "/repo/global.json",
"timestamp": "2025-04-15T14:30:22.1234567Z"
}
```

If the file's last-modified time matches the stored timestamp, skip re-reading the file contents — we already know the channel from the install spec. This avoids unnecessary I/O during GC and update passes.

## Considerations

- global.json files are quite small, so the perf gain may be marginal.
- Need to decide whether `File.GetLastWriteTimeUtc` is sufficient or if we need content hashing.
- This is a v2 / lower priority optimization with small cost.

## Origin

PR #53290 review comment: https://github.com/dotnet/sdk/pull/53290#discussion_r2897721529

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.