Module regex_automata::util::pool::inner

source Β·

Structs§

  • CacheLine πŸ”’
    This puts each stack in the pool below into its own cache line. This is an absolutely critical optimization that tends to have the most impact in high contention workloads. Without forcing each mutex protected into its own cache line, high contention exacerbates the performance problem by causing β€œfalse sharing.” By putting each mutex in its own cache-line, we avoid the false sharing problem and the affects of contention are greatly reduced.
  • Pool πŸ”’
    A thread safe pool utilizing std-only features.
  • PoolGuard πŸ”’
    A guard that is returned when a caller requests a value from the pool.

Constants§

  • MAX_POOL_STACKS πŸ”’
    The number of stacks we use inside of the pool. These are only used for non-owners. That is, these represent the β€œslow” path.
  • THREAD_ID πŸ”’
    A thread local used to assign an ID to a thread.

Statics§

  • COUNTER πŸ”’
    An atomic counter used to allocate thread IDs.
  • This sentinel is used to indicate that a guard has already been dropped and should not be re-dropped. We use this because our drop code can be called outside of Drop and thus there could be a bug in the internal implementation that results in trying to put the same guard back into the same pool multiple times, and that could result in UB if we didn’t mark the guard as already having been put back in the pool.
  • THREAD_ID_INUSE πŸ”’
    A thread ID indicating that the special owner value is in use and not available. This state is useful for avoiding a case where the owner of a pool calls get before putting the result of a previous get call back into the pool.
  • A thread ID indicating that there is no owner. This is the initial state of a pool. Once a pool has an owner, there is no way to change it.