Cyan4973 / xxHash

Extremely fast non-cryptographic hash algorithm
http://www.xxhash.com/
Other
9.04k stars 773 forks source link

A memcpy fused version would be nice. #896

Open Emjayen opened 11 months ago

Emjayen commented 11 months ago

As per the title: for performance reasons (single pass & overlapping writes) a version which performs xxh3 and memcpy would be nice to have. Ideally with the option for nt stores where available.

Cyan4973 commented 11 months ago

What do you mean ? a "safer" memcpy() followed by a memcmp() ?

t-mat commented 11 months ago

I have no idea what is actually asked in this issue.

But I'm just guessing "fused" function means:

memcpy(dst, data, dataSize);
xxh_update(&state, dst, dataSize);

More specific example:

uint8_t*  p     = ...;
xxh_state state = ...;

while(...) {
  // Store some data to tmp[]
  uint8_t tmp[...];
  my_magic_func(tmp, sizeof(tmp), ...);

  // LHS ("performance reason") may happen
  // - https://en.wikipedia.org/wiki/Load-Hit-Store
  // We can reverse the order of invocation in this case though.
  memcpy(p, tmp, sizeof(tmp));
  xxh_update(&state, p, sizeof(tmp));

  p += sizeof(tmp);
}

hash = xxh_digest(&state);