Repository navigation
refactor(core): return ValueTask from the greeting repository - #167
Merged
Merged
Conversation
The repository methods run against an in-memory list, so the Task wrapper bought nothing. SaveAsync now allocates nothing and GetRecentAsync allocates only its result array. CA2012 enforces the single consumption. Restore the backward read walk that 83f564a dropped. A full sort on the read path costs the stored count per call: the recorded harness ran 1,655 req/s with the sort and 7,278 req/s without it. Record the ValueTask contract in lode/dotnet/performance.md and drop the stale net10.0 clause from the runtime-async note. Also adds the mr-sparkle precondition, three analyzer candidates from the 2026-11-14 sessions, and the review plan for that run. Co-Authored-By: Claude
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.
Executive Summary
The greeting repository returned
Taskfrom methods that never suspend.SaveAsyncalready returned the cachedTask.CompletedTask, so it allocated nothing, butGetRecentAsyncallocated a freshTask<IReadOnlyList<Greeting>>on every read. Both methods now returnValueTask, so a save allocates nothing and a read allocates only its result array.The same read path had lost its measured optimization. Commit 83f564a, a bulk analyzer refactor, replaced the backward list walk with a full
OrderByDescendingsort. The walk is restored. Recency follows save order, becauseGreetingServicestampsCreatedAtat save time.Code Changes
IGreetingRepositoryreturnsValueTaskandValueTask<IReadOnlyList<Greeting>>.InMemoryGreetingRepositoryimplements both signatures and reads the newest entries by walking back from the list end under the existing lock.FixedGreetingRepositoryand theCoreBenchmarksread benchmark follow the new signatures.InMemoryGreetingRepositoryTestsconsumes eachValueTaskonce, which CA2012 enforces as an error in this repo.lode/dotnet/performance.mdrecords theValueTaskcontract and drops a stalenet10.0clause from the runtime-async note.Tests and Tooling
scripts/check.sh --allpassed: shell lint, format check, build, and 2990 tests with 0 failures and 2 pre-existing skips.scripts/internal/analyzer-release-check.shandscripts/readme-table-diff.sh --analyzerreport no drift.The recorded throughput figures (1,655 req/s with the sort, 7,278 req/s without) were not re-measured in this run. They come from the commit that first introduced the walk.
Review Guide
Read
InMemoryGreetingRepository.GetRecentAsyncfirst: it holds the restored walk and the changed return type. Then check the four signature changes. The interface change is a public API change.Rollback
Revert this commit. Nothing depends on the new signatures outside the solution.
Links
None.
🤖 Generated with Claude Code