Hash :
b46344bb
Author :
Date :
2023-06-12T13:50:40
Metal: Cache render pipelines at the context level Cache Metal render pipelines in a new mtl::PipelineCache which lives at the context level. This allows us to clean up unused pipelines from programs that are not actively used. The cache limits were chosen based on running Chromium. Without a limit, the total number of pipelines peaks at ~200. With frequent GCs, the active working set usually sits at ~60 pipelines. Bug: chromium:1329376 Change-Id: Ifa83b797c893684294e16dd638f6b3a35e1d043f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4608486 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Quyen Le <lehoangquyen@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
//
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// hash_utils.h: Hashing based helper functions.
#ifndef COMMON_HASHUTILS_H_
#define COMMON_HASHUTILS_H_
#include "common/debug.h"
#include "xxhash.h"
namespace angle
{
// Computes a hash of "key". Any data passed to this function must be multiples of
// 4 bytes, since the PMurHash32 method can only operate increments of 4-byte words.
inline size_t ComputeGenericHash(const void *key, size_t keySize)
{
constexpr unsigned int kSeed = 0xABCDEF98;
// We can't support "odd" alignments. ComputeGenericHash requires aligned types
ASSERT(keySize % 4 == 0);
#if defined(ANGLE_IS_64_BIT_CPU)
return XXH64(key, keySize, kSeed);
#else
return XXH32(key, keySize, kSeed);
#endif // defined(ANGLE_IS_64_BIT_CPU)
}
template <typename T>
size_t ComputeGenericHash(const T &key)
{
static_assert(sizeof(key) % 4 == 0, "ComputeGenericHash requires aligned types");
return ComputeGenericHash(&key, sizeof(key));
}
inline void HashCombine(size_t &seed) {}
template <typename T, typename... Rest>
inline void HashCombine(std::size_t &seed, const T &hashableObject, Rest... rest)
{
std::hash<T> hasher;
seed ^= hasher(hashableObject) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
HashCombine(seed, rest...);
}
template <typename T, typename... Rest>
inline size_t HashMultiple(const T &hashableObject, Rest... rest)
{
size_t seed = 0;
HashCombine(seed, hashableObject, rest...);
return seed;
}
} // namespace angle
#endif // COMMON_HASHUTILS_H_