Skip to content

see if per-thread hashmap is better #4

@chc4

Description

@chc4

currently we have threads just send possible garbage or definitely not garbage updates via a channel to the collector. this works, and is easy, but has a few bad things

  1. collector is a bottleneck for high churn - if we have a bunch of mutators, they might generate traffic faster than we can process it, especially if cpu threads become oversubscribed.
  2. when doing a cycle collection we aren't draining the channel, which means if we take too long the mutators will start blocking...even if all the traffic is just definitely not garbage updates.

instead we should probably just have a pseudo-thread_local hashmap that mutators locally update, and when doing a collection snapshot all the hashmaps from each thread and use that at the deferred map.
this has the benefit of allowing mutators to not block on the collector taking too long, and always be able to optimistically remove definitely not garbage from the deferred set. downside is just if you create objects and create+drop references on n threads it will allocate n map entries - that's sufficiently pathological that i think it's worth not worrying about.

idk if the snapshotting needs a full concurrent hashmap (evmap? flashmap?) or i can just use im::hashmap and clone the hashmap, update map, update pointer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions