mgravell / FASTERCache

IDistributedCache implementation on FASTER
MIT License
30 stars 2 forks source link

perform async transitions #4

Closed mgravell closed 5 months ago

mgravell commented 5 months ago

fast-paths the sync route

Tornhoof commented 5 months ago

Nice idea to unify the states in one method, I'm still not sure if it is worth the hassle to do so, too much code.

Now that your main path is without async, you can change your WriteKey method to use a stackalloc array and only convert it to a memory if you call AsyncGetTransition. Faster has helper methods for that, if you want to go the MemoryPool route.

var lease = fixedKey.ToMemoryOwner(MemoryPool<byte>.Shared);

Afaik you don't need session.CompletePendingAsync, see https://github.com/microsoft/FASTER/issues/355#issuecomment-713204965 for comment

mgravell commented 5 months ago

@Tornhoof it is a work in progress :p but you're right, I haven't yet reapplied the stackalloc, working it

mgravell commented 5 months ago

thanks for the tip on CompletePendingAsync - I'll update

Tornhoof commented 5 months ago

If you want to know why no completependingaync on upsert. For your comment here: https://github.com/mgravell/FASTERCache/blob/8aa2d3affbf4a5944261e0222817066a3cdc8aa6/src/FASTERCache/DistributedCache.cs#L150 Same issue, Just a few lines above, https://github.com/microsoft/FASTER/issues/355#issuecomment-713199732

"Upsert never returns pending"

mgravell commented 5 months ago

well, it is moot; I've switched to RMW (see "main" or https://github.com/mgravell/FASTERCache/commit/d41daaf26ab1f3bd5da01042e6eb0d4a72d131dd)