summaryrefslogtreecommitdiffstats
path: root/tokio/src/sync
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2020-08-11 22:28:43 -0700
committerGitHub <noreply@github.com>2020-08-11 22:28:43 -0700
commit8feebab7cdef2fbeb810d18509b1443b6b9f60b1 (patch)
treea76395dd802bae93fc7ba97e50ba59ed153a1991 /tokio/src/sync
parent674985d9fb87c866d9219297fde35b2e32b40b0b (diff)
io: rewrite slab to support compaction (#2757)
The I/O driver uses a slab to store per-resource state. Doing this provides two benefits. First, allocating state is streamlined. Second, resources may be safely indexed using a `usize` type. The `usize` is used passed to the OS's selector when registering for receiving events. The original slab implementation used a `Vec` backed by `RwLock`. This primarily caused contention when reading state. This implementation also only **grew** the slab capacity but never shrank. In #1625, the slab was rewritten to use a lock-free strategy. The lock contention was removed but this implementation was still grow-only. This change adds the ability to release memory. Similar to the previous implementation, it structures the slab to use a vector of pages. This enables growing the slab without having to move any previous entries. It also adds the ability to release pages. This is done by introducing a lock when allocating/releasing slab entries. This does not impact benchmarks, primarily due to the existing implementation not being "done" and also having a lock around allocating and releasing. A `Slab::compact()` function is added. Pages are iterated. When a page is found with no slots in use, the page is freed. The `compact()` function is called occasionally by the I/O driver. Fixes #2505
Diffstat (limited to 'tokio/src/sync')
0 files changed, 0 insertions, 0 deletions