You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In various CockroachDB workloads, context.WithValue shows up as a few percentage points in profiles (similar to any other object allocation). In many cases, we also allocate an object for the value that is associated with the context. We would like to consolidate these allocations by embedding valueCtx inside a bigger struct, so that we can allocate both objects together.
Note that we can't have our own implementation of Context without losing some efficiency because parentCancelCtx won't be aware of it.
My proposal is to export the valueCtx type (or an alias) and provide a method or WithValue variant to initialize it. Would this kind of addition to the API be acceptable? (I can post the change if yes)
The text was updated successfully, but these errors were encountered:
It was my impression that CL 196521 modified parentCancelCtx such that it no longer uses known types to traverse upwards, but instead uses a value to look up the parent cancel context.
And it only incur a single allocation (ignoring my placeholder types). On a WithCancel, the value stack is searched for the parent, and that works as before.
In various CockroachDB workloads,
context.WithValue
shows up as a few percentage points in profiles (similar to any other object allocation). In many cases, we also allocate an object for the value that is associated with the context. We would like to consolidate these allocations by embeddingvalueCtx
inside a bigger struct, so that we can allocate both objects together.Note that we can't have our own implementation of
Context
without losing some efficiency becauseparentCancelCtx
won't be aware of it.My proposal is to export the
valueCtx
type (or an alias) and provide a method orWithValue
variant to initialize it. Would this kind of addition to the API be acceptable? (I can post the change if yes)The text was updated successfully, but these errors were encountered: