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

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

@nunoplopes

Description

@nunoplopes

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions