[External] : Re: User model stacking
John Rose
john.r.rose at oracle.com
Sun May 1 03:22:20 UTC 2022
On 27 Apr 2022, at 16:12, Brian Goetz wrote:
> We can divide the VM flattening strategy into three rough categories (would you like some milk with your eclair?):
>
> - non-flat — use a pointer
> - full-flat — inline the layout into the enclosing container, access with narrow loads
> - low-flat — use some combination of atomic operations to cram multiple fields into 64 or 128 bits, access with wide loads
There’s a another kind of strategy here, call it “fat-flat”. That would encompass any hardware and/or software transaction memory mechanism that uses storage of more than 64 bits. I think all such techniques include a fast and slow path, which means unpredictable performance. Such techniques usually require “slack” of some sort in the data structure, either otherwise unencoded states (like pseudo-oops) or extra words (injected STM headers). This is not completely off the table, because (remember) we are often going to inject an extra word just to represent the null state. In for a penny, in for a pound: If we add a word to encode the null state, it can also encode an inflated “synchronized access” state. That’s part of the “VM physics” that Dan is asking about.
>
> B1 will always take the non-flat strategy. Non-volatile B3 that are smaller than some threshold (e.g., full cache line) will prefer the full-flat strategy. Non-atomic B2 can also pursue the full-flat strategy, but may have an extra field for the null channel. Atomic B2/B3 may try the low-flat strategy, and fall back to non-flat where necessary. Volatiles will likely choose non-flat, unless they fit in the CAS window. But it is always VM’s choice.
A fat-flat strategy can cover atomic B2/B3, even volatiles.
Thing to remember: Even if a class designer selects the non-atomic option, a use-site volatile annotation surely overrides that. A non-atomic B2 is a funny type: It is usually non-atomic, except for volatile variables. That suggests to me there’s a hole in the user model, a way to select atomic-but-not-volatile use sites (variables and array elements, in particular) for non-atomic B2’s.
More information about the valhalla-spec-experts
mailing list