Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

hash collisions in program cache don't seem relevant #12

Open
nunoplopes opened this issue Oct 26, 2021 · 0 comments
Open

hash collisions in program cache don't seem relevant #12

nunoplopes opened this issue Oct 26, 2021 · 0 comments

Comments

@nunoplopes
Copy link
Owner

Tried a better hash:

#define HASH_COMBINE(hash, ty, v) hash * 31 + std::hash<ty>()(v)
  for (unsigned i = 0; i < key.num_ops; ++i) {
    hash = HASH_COMBINE(hash, uint16_t, key.ops[i].id);
    for (auto &arg : key.ops[i].args) {
      if (auto *v = get_if<int64_t>(&arg)) {
        hash = HASH_COMBINE(hash, int64_t, *v);
      } else if (auto *v = get_if<vector<long>>(&arg)) {
        for (auto n : *v) {
          hash = HASH_COMBINE(hash, long, n);
        }
      }
    }
  }
#undef HASH_COMBINE

Reduced collisions to almost zero, but zero perf difference.

@nunoplopes nunoplopes changed the title has collisions in program cache don't seem relevant hash collisions in program cache don't seem relevant Oct 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant