X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=include%2Fwimlib%2Flz_sarray.h;h=30dc2b30a480ea64d943ab73e6baedf71bfa86f6;hb=0f7725a7cd14830b484b241d56f66bf7743d7351;hp=5b63ae7c74e9dcafbb075d7ba2ab4559ac36284d;hpb=55d02ebb05358214d12cd98136fe55ca6019f33c;p=wimlib diff --git a/include/wimlib/lz_sarray.h b/include/wimlib/lz_sarray.h index 5b63ae7c..30dc2b30 100644 --- a/include/wimlib/lz_sarray.h +++ b/include/wimlib/lz_sarray.h @@ -34,7 +34,8 @@ #ifndef _WIMLIB_LZ_SARRAY_H #define _WIMLIB_LZ_SARRAY_H -#include "wimlib/compiler.h" /* must define '_always_inline_attribute' */ +#include "wimlib/compiler.h" /* must define '_always_inline_attribute', + 'likely()', and 'prefetch()'. */ #include "wimlib/lz.h" /* must define 'struct raw_match' and LZ_ASSERT() */ #include "wimlib/types.h" /* must define 'bool', 'u8', 'u16, and 'u32' */ @@ -285,6 +286,19 @@ lz_sarray_get_matches(struct lz_sarray *mf, /* Prepare for searching the current position. */ lz_sarray_update_salink(r, link); +#if 1 + /* Prefetch next position in SA and link. + * + * This can improve performance on large windows since the locations in + * SA and link at which each successive search begins are in general + * randomly distributed. */ + if (likely(i + 1 < mf->window_size)) { + const lz_sarray_pos_t next_r = ISA[i + 1]; + prefetch(&SA[next_r]); + prefetch(&link[next_r]); + } +#endif + /* L = rank of next suffix to the left; * R = rank of next suffix to the right; * lenL = length of match between current position and the suffix with rank L;