[foreign-memaccess+abi] RFR: 8264933: Improve stream support in memory segments

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Sat Apr 10 21:17:46 UTC 2021


On 10/04/2021 00:52, John Rose wrote:
> On Apr 9, 2021, at 6:48 AM, Maurizio Cimadamore 
> <mcimadamore at openjdk.java.net <mailto:mcimadamore at openjdk.java.net>> 
> wrote:
>>
>> * for usability, let's add `MemorySegment::slices(MemoryLayout)`, 
>> which returns a _sequential_ stream of all the slices in a segment 
>> (with given element layout).
>> * for advanced use cases, including parallel streams, users will have 
>> to use spliterator + StreamSupport, as before.
>>
>> This doesn't close the door to other stream-ified views to be added 
>> in the future. What do people think?
>
> I like the previous spliterator proposal better for parallel
> streams, because I think it interacts better with parallel
> decomposition.

Please clarify meaning of "previous proposal".

>
> Isn’t it true that spliterators will tend to cut the bulk data
> in half (or other large chunk) recursively until the cores
> are busy, and then iterate?  In that case, you only get enough
> sub-segments to (safely!) manage the parallel decomposition.
> If you stream over small slices, then you are slicing all the
> time.  Where would the per-core vectorized loops get to
> work?

Is this a critique against MemorySegment::stream/slices in general, or?

Maurizio

>
> — John


More information about the panama-dev mailing list