Commit dad687f7 authored by Nathan Bronson's avatar Nathan Bronson Committed by Facebook Github Bot

document transferrability of F14HashToken between instances

Summary:
F14HashToken encapsulates the work of hash_function(), which
is the same across F14 containers that have the same key_type and equal
hash_function() (same type and operator==).  This diff adds documentation
that callers may rely on this fact, which means they can use this feature
to reduce work if a single key is access in multiple maps/sets.

(Note: this ignores all push blocking failures!)

Reviewed By: shixiao

Differential Revision: D7506737

fbshipit-source-id: 321032d619434501b1e0544962e54732bfc4c970
parent 9a31b9e8
......@@ -570,6 +570,20 @@ class F14BasicMap {
return table_.find(key).atEnd() ? 0 : 1;
}
/// prehash(key) does the work of evaluating hash_function()(key)
/// (including additional bit-mixing for non-avalanching hash functions),
/// wraps the result of that work in a token for later reuse, and
/// begins prefetching the first steps of looking for key into the
/// local CPU cache.
///
/// The returned token may be used at any time, may be used more than
/// once, and may be used in other F14 sets and maps. Tokens are
/// transferrable between any F14 containers (maps and sets) with the
/// same key_type and equal hash_function()s.
///
/// Hash tokens are not hints -- it is a bug to call any method on this
/// class with a token t and key k where t isn't the result of a call
/// to prehash(k2) with k2 == k.
F14HashToken prehash(key_type const& key) const {
return table_.prehash(key);
}
......
......@@ -369,6 +369,20 @@ class F14BasicSet {
return table_.find(key).atEnd() ? 0 : 1;
}
/// prehash(key) does the work of evaluating hash_function()(key)
/// (including additional bit-mixing for non-avalanching hash functions),
/// wraps the result of that work in a token for later reuse, and
/// begins prefetching of the first steps of looking for key into the
/// local CPU cache.
///
/// The returned token may be used at any time, may be used more than
/// once, and may be used in other F14 sets and maps. Tokens are
/// transferrable between any F14 containers (maps and sets) with the
/// same key_type and equal hash_function()s.
///
/// Hash tokens are not hints -- it is a bug to call any method on this
/// class with a token t and key k where t isn't the result of a call
/// to prehash(k2) with k2 == k.
F14HashToken prehash(key_type const& key) const {
return table_.prehash(key);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment