Skip to content

Commit 65937b3

Browse files
committed
Call out in spec that growing/shrinking can be more efficient
1 parent 8b81cf5 commit 65937b3

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

oteps/profiles/4947-thread-ctx.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ The intention of this design is to enable flexibility for the writers. We envisi
179179

180180
In both cases, all pointer and validity updates use compiler fences (`atomic_signal_fence` or equivalent) and volatile writes to prevent instruction reordering by the compiler. This design assumes signal handler-like semantics, therefore it is unnecessary to guard against CPU reordering.
181181

182+
##### When growing or shrinking only the attrs-data
183+
184+
Readers only care about the first `attrs-data-size` bytes starting from the `attrs-data`.
185+
A writer that wants to append attributes MAY freely mutate the bytes starting from `attrs-data + attrs-data-size` without detaching the context or even changing `valid`.
186+
187+
In this situation, only appropriate fencing needs to happen to make the final update to `attrs-data-size` (thus making the new attributes visible) happens last.
188+
189+
A similar situation can happen with "shrinking": replacing a `attrs-data-size` value with a smaller one MAY be done without changing `valid`
190+
as long as appropriate fencing ensures it's not reordered with other changes.
191+
182192
#### 3. Context Detachment
183193

184194
When a request context is no longer active on a thread, the SDK either sets the TLS pointer to `NULL`, or sets the `valid` flag to `false`.

0 commit comments

Comments
 (0)