mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-19 04:30:25 +01:00
Open one cache DB part at a time for a multi-part cache to reduce number
of FDs used by the cache. Previously multi-part DB cache instance was
consuming 100 FDs, now it's 2 and cache files are opened when cache
is read or written instead of opening them at the init time.
Fixes: fd9f7b748e ("util/mesa-db: Introduce multipart mesa-db cache")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11776
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30988>
48 lines
1.4 KiB
C
48 lines
1.4 KiB
C
/*
|
|
* Copyright © 2022 Collabora, Ltd.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#ifndef MESA_CACHE_DB_MULTIPART_H
|
|
#define MESA_CACHE_DB_MULTIPART_H
|
|
|
|
#include "mesa_cache_db.h"
|
|
#include "simple_mtx.h"
|
|
|
|
struct mesa_cache_db_multipart {
|
|
struct mesa_cache_db **parts;
|
|
unsigned int num_parts;
|
|
volatile unsigned int last_read_part;
|
|
volatile unsigned int last_written_part;
|
|
const char *cache_path;
|
|
uint64_t max_cache_size;
|
|
simple_mtx_t lock;
|
|
};
|
|
|
|
bool
|
|
mesa_cache_db_multipart_open(struct mesa_cache_db_multipart *db,
|
|
const char *cache_path);
|
|
|
|
void
|
|
mesa_cache_db_multipart_close(struct mesa_cache_db_multipart *db);
|
|
|
|
void
|
|
mesa_cache_db_multipart_set_size_limit(struct mesa_cache_db_multipart *db,
|
|
uint64_t max_cache_size);
|
|
|
|
void *
|
|
mesa_cache_db_multipart_read_entry(struct mesa_cache_db_multipart *db,
|
|
const uint8_t *cache_key_160bit,
|
|
size_t *size);
|
|
|
|
bool
|
|
mesa_cache_db_multipart_entry_write(struct mesa_cache_db_multipart *db,
|
|
const uint8_t *cache_key_160bit,
|
|
const void *blob, size_t blob_size);
|
|
|
|
void
|
|
mesa_cache_db_multipart_entry_remove(struct mesa_cache_db_multipart *db,
|
|
const uint8_t *cache_key_160bit);
|
|
|
|
#endif /* MESA_CACHE_DB_MULTIPART_H */
|