Repository navigation
test: Prove DP storage ignores registration order - #26284
MartinZikmund wants to merge 1 commit into
Conversation
Guard #25047's storage table: a property's storage cost must not depend on its UniqueId relative to the others an object sets. On the previous id-bucketed storage the order test fails (16 vs 32 slots, 1,528 vs 1,960 B). Also cover hot reload cloning, ClearValue, the cached DataContext details among many properties, and GetAllDetails. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Claude finished @MartinZikmund's task in 14s —— View job Review of #26284: DP storage registration-order testsVerdict: ship. I found no blocking issues. I reviewed the diff only and did not build or run the tests, so the pass/fail numbers below are the PR description's, not mine. Issues by severity: blocker 0, major 0, minor 0, nit 2 (below). I posted no inline comments. Summary
Nits (non-blocking)
|
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
|
The build 245164 found UI Test snapshots differences: Details
|
morning4coffe-dev
left a comment
There was a problem hiding this comment.
These guard the right thing. WinUI keeps local values in a sparse vector_map<KnownPropertyIndex, EffectiveValue> on CDependencyObject, so per-object cost never depended on where a property's index falls, and this pins the same property for the open-addressed table. Two small test notes inline.
| } | ||
|
|
||
| var dataContext = new object(); | ||
| SUT.DataContext = dataContext; |
There was a problem hiding this comment.
DataContextPropertyDetails is lazily cached, and DataContext is set here only after the 64 attached properties have already grown the table, so the cache is probably filled after the last Grow() and the test never shows it surviving a rehash. Could you set and read DataContext first, then add the attached properties to force growth, then assert AreSame?
| return o; | ||
| } | ||
|
|
||
| private static DependencyPropertyDetailsCollection GetCollection(DependencyObject o) |
There was a problem hiding this comment.
GetEntries below repeats this _properties reflection and also reflects into _entries. Could it be GetCollection(o).GetAllDetails()? That drops the dependency on the private _entries field.
|
Tick the box to add this pull request to the merge queue (same as
|
GitHub Issue: part of #21129
Related: #24754 (closed by #25047), #25047, #25214.
PR Type:
💬 Other... (Please describe): tests only. They guard the perf behavior #25047 shipped.
What changed? 🚀
#25047 replaced
DependencyPropertyDetailsCollection's 16-slot buckets (indexed byDependencyProperty.UniqueId >> 4) with a small open-addressed table. A side effect worth guarding on its own: a property's storage cost no longer depends on when it was registered relative to the other properties an object sets. With buckets, the first property set in an otherwise untouched id range cost a fresh 16-slot bucket (128 B). That is what forced #25184 to delayDependencyObject.Name's registration behind a holder class, and it is what lets #25214 drop that holder.This PR adds only tests (carved out of #25214, where they were mixed with the Name refactor) so the property can't silently regress:
When_Property_Is_Registered_Far_From_The_Others_Then_Storage_Costs_The_Same: an object sets one property plus a neighbor registered just before, just after, or far away from it. Slots and bytes must match.ClearValuekeeps the other properties addressable, and re-setting doesn't duplicate details.DataContextdetails stay correct with many (attached) properties in the table.GetAllDetailslists each set property exactly once.Fails before: with the pre-#25047 storage file (
faeb561948f^1) swapped into currentmaster, the registration-order test fails:Expected:<(16, 1528)>. Actual:<(32, 1960)>(slots, bytes). The two existing sizing tests fail as well (16 slots for one or two properties). The other four new tests pass on both storages; they are correctness guards for the table's probing and snapshot paths.Measured: what #25047 bought on master
Arms, each a Release build of
Uno.UI+ headless Skia host,net10.0, measured with the same harness source:716c3c077f5(faeb561948f^1, master just before perf: Size DependencyProperty storage to the properties set #25047)c00f09910a9with onlyDependencyPropertyDetailsCollection.csreverted to itsfaeb561948f^1version. This isolates perf: Size DependencyProperty storage to the properties set #25047 from the 708 other commits between A and B.c00f09910a9(this PR adds tests only, so its runtime code is identical)Allocation: bytes allocated on the UI thread (
GC.GetAllocatedBytesForCurrentThread()), per object or per dictionary, after a warm-up of the same action. 3 alternating launches per arm. Every row was identical across launches (spread ≤ 0.5 B), and a null arm (byte-identical copy of B in another directory) matched B exactly.new Border()new Border { Name }new SolidColorBrush()ResourceDictionaryin code, per dictionaryResourceDictionaryviaXamlReader, per loadx:Name(A named
SolidColorBrushcan't be measured on master: settingFrameworkElement.NamePropertyon a brush throws there, which #25184 fixes.)CPU: thread cycles per op (
QueryThreadCycleTime) on the UI thread, median of 7 in-process reps after a warm-up rep, 9 alternating launches per arm (DOTNET_TieredCompilation=0). A sweep isGetValueover every public DP on the type's hierarchy plus 12 common attached ones (94 / 123 / 114 DPs), mixing set and unset. Cells are median of the 9 launches [min–max].SetValue(Tag)The null test is the key column: two byte-identical B builds in different directories differ by up to 22% on a median (TextBlock sweep 74.9 vs 61.4) and 11% on
SetValue. Every A′/B delta sits inside that floor and inside overlapping ranges, so CPU: no measurable change; allocation: a real, deterministic win, concentrated where objects set few properties in otherwise untouched id ranges (named elements, brushes in dictionaries, templated controls).Method notes: per-thread allocation counters don't see render-thread allocations (this change doesn't touch that thread). The machine was otherwise idle apart from IDE language servers (no builds), and CPU numbers are per-thread cycles.
Validation
Uno.UI+Uno.UI.UnitTests(net10.0,UnoFastDevBuild), and a Release build ofUno.UI+ headless runtime for the measurements.Uno.UI.UnitTests, 4,524 tests: 4,489 passed, 23 skipped, 12 failed, all 12 the known timezone-dependentWhen_Gregorian_FixedDate*tests.Given_DependencyPropertyDetailsCollection: 12/12 pass on this branch, 3/12 fail on the pre-perf: Size DependencyProperty storage to the properties set #25047 storage (above).PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code