Skip to content

Version 3.5 performance#22

Merged
mshimshon merged 10 commits into
mainfrom
version-3.5-performance
May 21, 2026
Merged

Version 3.5 performance#22
mshimshon merged 10 commits into
mainfrom
version-3.5-performance

Conversation

@mshimshon

Copy link
Copy Markdown
Owner

v3.0.0

BREAKING CHANGES

  • IDispatchTracker<TAction> is not longer taking a TAction and the service is no longer register per action but instead as a scope service IDispatchTracker.
  • IDispatcher.Prepare<TAction>().DispatchAsync(CancellationToken ct = default) no longer returns Guid as it was unused artifacts of a idea of a system for cancellations.
  • IDispatcher.Prepare<TAction>().DispatchAsync(bool asSafe = false, CancellationToken ct = default) no longer takes bool as first param instead use fluent api .AsSafe() to achieve the same result.

WARNING CHANGES

  • IDispatcherMiddleware.OnDispatchFailure(Exception exception, object action); renamed arguments to IDispatcherMiddleware.OnDispatchFailure(Exception ex, object action); which could trigger compiler warnings.

New Features

  • Dispatch now supports Cancellation tokens.
  • Token are passed down to all subsequent chain until you define a different one DispatchAsync(false,new CT);.
  • .DoNotAwait() is now available, design for effect sub-dispatches when specific dispatch should not be awaited in case the origin call awaits the full pipeline... some tasks should not be awaited? that's your method.
  • Access Token from effects using dispatcher.CancelToken which is default or correspond to upper chain origin.
  • You can check if you shouldd stop execution of effect using dispatcher.IsCancellationRequested.
  • dispatcher.IsCancellationRequested include now if the anti-duplication chain that was cancelled but slipped through the cracks if any you can now catch it in the effects.
  • dispatcer.AsSafe() replaces the first param IDispatcher.Prepare<TAction>().DispatchAsync(bool asSafe = false, CancellationToken ct = default) to execute the context with race condition resistance.
  • dispatcer.AsUnSafe() turn off the the rc resistance, it is useful to disconnect a usually safe flow to prevent cancellation.

Performance

  • Improved Dispatcher Performance up to 24% by removing class creation via reflection at every dispatch.
  • Improved Dispatch Performance up to 20% by only performing allocation for the middleware class when middlewares are actually present. (Note: the second you start adding middleware slight performance drop is expected).
  • Improved Reducer Performance, we initially tested every single state registered to compare if the running action had reducers... now we get reducers by Action or by State directly.

Major Fixes

  • Await feature did not await the full pipeline, subsequent dispatches were set as normal fire-and-yield unless specified. Now the await feature passes down the await flag thus fully awaiting as the intended feature was design for.

- feat: propagate tokens through chained dispatches unless overridden
- feat: add .DoNotAwait() for fire‑and‑yield sub‑dispatches
- feat: expose active cancellation token via dispatcher.CancelToken
- feat: allow effects to stop early using dispatcher.IsCancellationRequested
- feat: include anti‑duplication cancellations in IsCancellationRequested
- perf: speed up reducer resolution by indexing by action/state
- fix: ensure await propagates through entire dispatch pipeline including nested calls
- Remove bool as first param for DispatchAsync t execute safe pipeline
- Added fluent api AsSafe() and AsUnSafe() to mark pipeline as safe or not.
@mshimshon mshimshon added this to the 3.0.0 milestone May 21, 2026
@mshimshon mshimshon self-assigned this May 21, 2026
@mshimshon mshimshon added the enhancement New feature or request label May 21, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 21, 2026

Copy link
Copy Markdown

Deploying statepulse-net with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9cfe904
Status: ✅  Deploy successful!
Preview URL: https://1189f390.statepulse-net.pages.dev
Branch Preview URL: https://version-3-5-performance.statepulse-net.pages.dev

View logs

@mshimshon mshimshon merged commit bb906bf into main May 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant