Search Unity

Multi-producer, single consumer hashset

Discussion in 'Data Oriented Technology Stack' started by PublicEnumE, Nov 22, 2019.

  1. PublicEnumE

    PublicEnumE

    Joined:
    Feb 3, 2019
    Posts:
    162
    What's the best DOTS option for a Hashset which can be written to from a single job on multiple threads?

    I've seen people suggesting home-spun Native hashset collections, but it's unclear if those are still supported, or if they support writing the same hash value from multiple threads.

    Elsewhere, people have suggested using a NativeMultiHashMap, then grabbing its keys. But that solution will result in multiple key entries. While not hard to work around, NativeMultiHashMap.GetKeyArray() can also be an expensive call.

    What would you recommend is the best solution, here at the end of 2019?
    Thank you for any advice.
     
    Last edited: Nov 22, 2019
  2. wobes

    wobes

    Joined:
    Mar 9, 2013
    Posts:
    731
  3. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    1,692
    NativeHashMap with empty struct as value (yeah is still 1 byte even if struct empty) it’s just simpler solution. Or write your own HashSet like from blog above.
     
unityunity