pub(crate) struct Builder {
only_fat: Option<bool>,
only_256bit: Option<bool>,
heuristic_pattern_limits: bool,
}
Expand description
A builder for constructing a Teddy matcher.
The builder primarily permits fine grained configuration of the Teddy matcher. Most options are made only available for testing/benchmarking purposes. In reality, options are automatically determined by the nature and number of patterns given to the builder.
Fields§
§only_fat: Option<bool>
When none, this is automatically determined. Otherwise, false
means
slim Teddy is used (8 buckets) and true
means fat Teddy is used
(16 buckets). Fat Teddy requires AVX2, so if that CPU feature isn’t
available and Fat Teddy was requested, no matcher will be built.
only_256bit: Option<bool>
When none, this is automatically determined. Otherwise, false
means
that 128-bit vectors will be used (up to SSSE3 instructions) where as
true
means that 256-bit vectors will be used. As with fat
, if
256-bit vectors are requested and they aren’t available, then a
searcher will not be built.
heuristic_pattern_limits: bool
When true (the default), the number of patterns will be used as a heuristic for refusing construction of a Teddy searcher. The point here is that too many patterns can overwhelm Teddy. But this can be disabled in cases where the caller knows better.
Implementations§
source§impl Builder
impl Builder
sourcepub(crate) fn build(&self, patterns: Arc<Patterns>) -> Option<Searcher>
pub(crate) fn build(&self, patterns: Arc<Patterns>) -> Option<Searcher>
Build a matcher for the set of patterns given. If a matcher could not
be built, then None
is returned.
Generally, a matcher isn’t built if the necessary CPU features aren’t available, an unsupported target or if the searcher is believed to be slower than standard techniques (i.e., if there are too many literals).
sourcepub(crate) fn only_fat(&mut self, yes: Option<bool>) -> &mut Builder
pub(crate) fn only_fat(&mut self, yes: Option<bool>) -> &mut Builder
Require the use of Fat (true) or Slim (false) Teddy. Fat Teddy uses 16 buckets where as Slim Teddy uses 8 buckets. More buckets are useful for a larger set of literals.
None
is the default, which results in an automatic selection based
on the number of literals and available CPU features.
sourcepub(crate) fn only_256bit(&mut self, yes: Option<bool>) -> &mut Builder
pub(crate) fn only_256bit(&mut self, yes: Option<bool>) -> &mut Builder
Request the use of 256-bit vectors (true) or 128-bit vectors (false). Generally, a larger vector size is better since it either permits matching more patterns or matching more bytes in the haystack at once.
None
is the default, which results in an automatic selection based on
the number of literals and available CPU features.
sourcepub(crate) fn heuristic_pattern_limits(&mut self, yes: bool) -> &mut Builder
pub(crate) fn heuristic_pattern_limits(&mut self, yes: bool) -> &mut Builder
Request that heuristic limitations on the number of patterns be employed. This useful to disable for benchmarking where one wants to explore how Teddy performs on large number of patterns even if the heuristics would otherwise refuse construction.
This is enabled by default.