Repository navigation
perf: faster, safer collections and views, with live queries and model tests - #421
Merged
Merged
Conversation
- add CsCheck fuzz harness and filtered, sorted, grouped and dynamic fuzz tests - ViewChangeBuffer retains raw notifications with version coverage and head verification - filtered view tracks membership so inserts, moves and updates keep source order - sorted view uses binary search and stable rebuild, grouped view re-keys items - ViewDispatcher dispatches zero throttle directly and coalesces windows
…nnot be applied exactly - add StreamProjection with count verification and resync, used by ReactiveView - retry source copies that fail under concurrent mutation - add quaternary ReactiveView fuzz tests, immediate and throttled
…ry collections - Model-based tests compare QuaternaryList, QuaternaryDictionary and SecondaryIndex with simple reference models. - Concurrency tests cover linearizability, mixed workloads, notification order, AddIndex races and Clear races. - Lifecycle tests cover dispose, observer faults, enumeration snapshots and argument validation.
…d lazy mirrors - Raise events, streams and PropertyChanged outside the list lock through a single-drainer queue - Make Dispose atomic and idempotent and complete the streams once - Create the Items, history and CurrentItems mirrors on first use - Share one immutable snapshot between enumeration, AsSpan and AsMemory - Validate Move, RemoveRange, CopyTo and IList arguments under the lock - Remove many items in one pass instead of quadratic removal - Keep Reactive2DList rows consistent when row creation fails - Record the AggressiveInlining attribute on Clear in the public API baselines
- Compare ReactiveList with a List model over random operation sequences, with and without observers - Check linearizability, cross-thread callbacks, reentrancy, handler exceptions and concurrent Dispose - Update the coverage test for wrong-type IList.Add and IList.Insert
…correct - Dispose is atomic and idempotent; operations after disposal throw ObjectDisposedException and the stream completes. - Notifications are queued under the shard lock so they keep mutation order; PropertyChanged is raised once per batch after unlocking. - AddIndex builds and registers under all write locks; Clear resets indexes under the lock. - SecondaryIndex keeps duplicates as a multiset, removes stale mutable keys and avoids boxing. - Enumeration, ToArray and Snapshot use point-in-time copies; RemoveMany runs its predicate outside the locks. - RemoveRange and dictionary RemoveKeys/RemoveMany publish BatchRemoved with the removed items. - CollectionChanged add/remove use compare-exchange; observer and handler faults are isolated.
…d harden fuzz reads - number unversioned notifications so a source copy discards changes it already contains - take one confirming copy after racing notifications settle - quarantine the ReactiveList.Edit reorder defect and avoid it in shared generators - read view collections defensively while a scheduler thread updates them
… quaternary benchmarks - SecondaryIndex keeps a per-key bucket with a running total so lookups copy in one pass. - ToArray and Snapshot return the shared empty array without taking locks when the collection is empty. - RemoveRange sizes its per-shard count dictionaries up front. - Add MemoryDiagnoser benchmarks for the zero-item floor, 16 to 128 items with an observer, contended 1,000 to 10,000 items and the secondary index. - Make benchmark classes unsealed so the in-process toolchain can run them. - Replace placeholder XML docs in QuadList and fix the RemoveRange remark.
…rojection and route public factories to it - DynamicReactiveView and the three secondary index views resync from their source and follow key and filter changes - ReactiveListExtensions and QuaternaryExtensions factories build ReactiveView from the source instead of a stream and snapshot - projection discards copied-in notifications, waits for an in-flight drain on dispose and survives source copy races - add dynamic, secondary index and public factory fuzz tests
…benchmarks - Serve indexer, ToArray, AsSpan and AsMemory from the immutable snapshot when one exists - Build the snapshot after repeated reads with no mutation, never on a write-then-read loop - Add floor, interactive and bulk MemoryDiagnoser benchmarks for ReactiveList
…namic notifications - Watch items from add until remove, replace, clear, source end or dispose, with duplicate items counted once - Serialize AutoRefresh output and complete or fail it when the source ends - Subscribe to the stream once in FilterDynamic so a predicate change no longer opens a gap that drops notifications - Translate updates, keep batch actions and run the predicate once per batch item - Correct the AutoRefresh expression overload docs - Add lifecycle, FilterDynamic, AutoRefresh and operator model fuzz tests
…t concurrent mutation - cover dispose during a mutation storm, double dispose, concurrent handler add and remove, and pooled batches queued at dispose - read the source through the bounded retry copy when a list view resets or verifies its mirror - publish count changes without throwing when a view is disposed mid-drain
- expose a resync counter on ReactiveView for tests - cover single and batch changes over reactive and quaternary lists
…lk regimes - measure single and batch notifications and view creation for each view type - measure view creation over a populated quaternary list
- Skip the remaining delivery stages and drop queued changes once the list is disposed - Test synchronous delivery, mutation order under writers, reentrant mutation, throwing handlers and dispose from a handler - Split the Edit benchmark into a net-zero and a net-change case so the cancelling edit is not mistaken for a speedup
…s and snapshot - Check concurrent writers on a deserialized list - Check a list serialized after Dispose comes back usable - Check mirrors and the lock-free snapshot after deserialization
- Say plainly that the result is a point-in-time view that mutations never change - Test mutation, shared snapshots, dispose and concurrent writers
…-pass # Conflicts: # src/tests/ReactiveList.Reactive.Tests/ReactiveList.Reactive.Tests.csproj # src/tests/ReactiveList.Tests/ReactiveList.Tests.csproj
- Move every actions-common workflow pin to e07297f. - Read the list through one enumerator in the reader stress test, because a spread reads Count and then enumerates.
- Add ArgumentExceptionHelper, ArgumentOutOfRangeExceptionHelper and ObjectDisposedExceptionHelper polyfills, compiled only for .NET Framework. - Alias the same names to the base class library types on modern targets. - Move the compiler attribute polyfills to src/Polyfills and drop their placeholder types. - Remove the hand-written guard fallbacks in ReactiveListExtensions and ReactiveList.
…ify batches without a copy - remove each batch item from the mirror instead of rebuilding it from the source - check size and the inserted range against the source, copying only when they disagree or equal items make the order ambiguous - drop unused view helpers
…-pass # Conflicts: # src/tests/ReactiveList.Reactive.Tests/ReactiveList.Reactive.Tests.csproj # src/tests/ReactiveList.Tests/ReactiveList.Tests.csproj
- Rename every ThrowHelper.ThrowIfNull call to ArgumentExceptionHelper.ThrowIfNull. - Delete Internal/ThrowHelper.cs.
…tree-agent-a35562d32ede49f70
…ror ops - Gather added/removed/changed history items only when a mirror exists - Contains, IndexOf and GetEnumerator read the shared snapshot without the lock - RangeObservableCollection uses List.InsertRange and geometric growth via ListCompat - ChangeSet(Change[]) copies on every target - GetEnumerator gains AggressiveInlining (PublicAPI baselines updated)
…tree-agent-a891ae9c4a012e167
… replaced dictionary entries - CopyVersioned copies every shard under all read locks and returns the exact version - the reader exposes the version of the notification it is delivering (NotificationVersion) - AddOrUpdate publishes the replaced entry as Previous - race tests cover every read path against concurrent writers
… replaced dictionary entries - CopyVersioned copies every shard under all read locks and returns the exact version - the reader exposes the version of the notification it is delivering (NotificationVersion) - AddOrUpdate publishes the replaced entry as Previous - race tests cover every read path against concurrent writers
- Read, write and reject a negative batch reset limit on each view type - Add and remove collection and property change handlers on each view type
- Exercise every forwarding member, event detach and constructor failure - Cover reference, equatable and boxed struct searches in ItemComparison
- Extract queue-behind and take-next into a static helper with state passed in - Cover observer failures and dispose during delivery
- a count over a list now rebuilds when an item replaces itself, since its earlier test result is unknown - the live query model tests change items in place and announce the change
- remove query members that nothing reads - drop a disposal check the serialized output already makes
…and quaternary events - Return the mutation-rejected exception instead of calling a throwing helper - Accept any observable in QuaternaryEvents.Attach so a failing pipeline can be tested - Check the disposed flag after starting the event processor
…yers - drive tallies and merges with a scripted source - move group change checks into a static helper and test it - check window rebuilds and large inserts
…onary interfaces - Remove an unreachable empty-input guard from QuaternaryList.AddCore - Expose the secondary index key matchers to tests
- request a drain through a static helper that is tested directly - refresh an item in an engine and check its new position
…ction and deferral rules
…etry and reset filtering - Move the source copy retry loop into a state-passing helper - Expose dispatcher window and run callbacks to tests
- Add a scripted source whose copies and index reads can change or fail mid-read - Cover null items, positional and unpositioned removals, and verification at the head
…and test them - Share the property change publication and signal creation of the pump and the projection - Take retained notifications through a static queue helper - Make the dispatcher callbacks internal so their disposed paths can be driven - Populate a batch collection through its list storage - Cover the pump, projection, engines, relays, gate and source rules
- Populate the batch collection's default list directly instead of a dead enumeration branch
…deterministic - Hold replayed notifications until the snapshot is applied so a late older change cannot overwrite it - Drain without a null sink check, since Start always sets the sink first
- Split lock-protected creation paths into internal helpers so each guard can be tested - Move the disposal-tolerant subscribe into a shared static helper
…n quiet batch end - Move the handler compare-and-swap into helpers that report a stale read
…nd repeated faults
- Keep the view pump, projection and batch collection with their shared static helpers - Keep the dispatcher callbacks and the subscription terminal methods as internal - Combine the relay, pump and source rules tests of both branches
…isposal - Drive the disposed pipeline path of the event attach directly - Create the current items signal from a disposed list
- Pick the handler or a rethrow helper in one expression, so the handler field is read once and no null check repeats.
- Eleven views repeated the same guarded setter. Each now assigns through ReactiveViewHelpers.CheckedResetLimit.
|
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.



What this does
A performance and reliability pass over the collections, views and notification paths. It also adds a live query API and CsCheck model tests.
Reliability and thread safety
Countcan no longer go negative.DisposalGatestops work on other threads beforeDisposereturns.New API (additive, except where noted)
Livequeries with LINQ names (Where,Select,OrderBy,GroupBy,SelectMany,Skip,Take,Count,Any) and query syntax support.IVersionedSnapshotSource<T>(CopyVersioned,VersionedStream), implemented byReactiveList<T>,Reactive2DList<T>and the sharded collections.DeferNotifications()on the list, the 2D list and the sharded collections. Scopes nest, and the last release publishes one reset.BatchResetLimiton views.Tests
ReactiveList.Testsand 2,510 inReactiveList.Reactive.Testspass on .NET 10 and .NET 11, on Linux, macOS and Windows.Timings
BenchmarkDotNet, A-B-B-A against
4463701, .NET 11, pinned cores, one run per area.BaseandNeware the first pass of each. Allocation is bytes per operation. .NET 10 moved the same way. Some runs shared the machine with builds, so treat differences under about 1.3x as noise.Core list
Add_Remove_Single(no observers)Indexer_WriteEnumerate_SingleContains_SingleCreate_DisposeAddRange_NoObservers(10,000)RemoveMany_Predicate(10,000)Remove_Enumerable(10,000)Enumerate(10,000)Add_Remove_Observed(128)Edit_NetZero_Observed(128)ReplaceAll_Mirror(1,000)RemoveRange_InsertRange_Mirror(1,000)Reactive2DList.TotalCount(128 rows)Reactive2DList.Add_Remove_Row(16 rows)Views
CreateDisposesorted (4,096)CreateDisposegrouped (4,096)CreateDisposefiltered (64)SingleAddRemovesource (4,096)SingleAddRemovesorted (4,096)BatchAddRemovesource (4,096)BatchAddRemovesorted (4,096)BatchAddRemoveByValuegroupedFilteredViewCreateDispose(4,096)Sharded collections under contention
List_ParallelAdd_Clear(1,000)List_ParallelAdd_Clear(10,000)List_ParallelMixed_Clear(10,000)Dictionary_ParallelAdd_Clear(1,000)Dictionary_ParallelAdd_Clear(10,000)A sharded
ToArrayof 10,000intvalues also dropped from about 1.9 us to 1.15 us.Known regressions
RemoveRange_InsertRange_MirrorallocationReactiveListIndexer_ReadCountSingleAddRemoveat 1 and 64 items (filtered, sorted, grouped)BatchAddRemovegrouped (1 item)