Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question BlobAsset or persistent NativeHashMap for config

Discussion in 'Entity Component System' started by somebodySB, Sep 29, 2023.

  1. somebodySB

    somebodySB

    Joined:
    Nov 30, 2018
    Posts:
    13
    I create many persistent NativeHashMap for static config.Just now,I realized BlobAsset is a official config solution and I compared performace between them.

    In BlobAsset test,I stored BlobAssetReference that refers to only one config in component and access config by this component.
    In NativeHashMap test,I stored configId in component and access config by NativeHashMap.

    How ever,persistent NativeHashMap is much better in my test.(100+ Ticks in BlobAsset test and 0 Tick in NativeHashMap one).
    It's a correct result or I just use BlobAsset in a wrong way?
     
    Last edited: Sep 29, 2023
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,574
    I think if you are using blob asset store, you introduce additional overhead. Even tho, should be very tiny. You not only need to check for hash, but also fetch reference to the hashmap from blob asset. Plus you do that for every entity you process on.

    While if you just pass hashmap to the job, you only need to access hash.

    I don't think storing persistent native hash collections in blob asset, is right approach. But I can see, why it may be chosen this way.
     
  3. somebodySB

    somebodySB

    Joined:
    Nov 30, 2018
    Posts:
    13
    I didn't store whole collections in BlobAsset,just only one.Each config has one BlobAsset.Poor English so I maybe confused you.