When one wishes to "get or insert" from/into a HashTable that is behind a RwLock, one typically first attempts to "get" with only a read lock (via the .find API), and only if that fails fallback to a "get or insert" with a write lock (via the .entry API).
However, the .entry call repeats the probing that was undertaken during the .find call: this is necessary because the table could have been modified between release of the read lock and acquisition of the write lock.
But in some cases, one might be able to determine whether the table was modified in the interim and thus avoid such duplicate probing. For example, if the table is append-only and its length has not changed.
The new bucket API almost exposes such an ability, but not quite. Is there any interest it being extended to support this use case, or is this perhaps too niche for hashbrown?
When one wishes to "get or insert" from/into a
HashTablethat is behind aRwLock, one typically first attempts to "get" with only a read lock (via the.findAPI), and only if that fails fallback to a "get or insert" with a write lock (via the.entryAPI).However, the
.entrycall repeats the probing that was undertaken during the.findcall: this is necessary because the table could have been modified between release of the read lock and acquisition of the write lock.But in some cases, one might be able to determine whether the table was modified in the interim and thus avoid such duplicate probing. For example, if the table is append-only and its length has not changed.
The new bucket API almost exposes such an ability, but not quite. Is there any interest it being extended to support this use case, or is this perhaps too niche for hashbrown?