Blame


1 718b3ab0 2018-03-17 stsp /*
2 718b3ab0 2018-03-17 stsp * Copyright (c) 2018 Stefan Sperling <stsp@openbsd.org>
3 718b3ab0 2018-03-17 stsp *
4 718b3ab0 2018-03-17 stsp * Permission to use, copy, modify, and distribute this software for any
5 718b3ab0 2018-03-17 stsp * purpose with or without fee is hereby granted, provided that the above
6 718b3ab0 2018-03-17 stsp * copyright notice and this permission notice appear in all copies.
7 718b3ab0 2018-03-17 stsp *
8 718b3ab0 2018-03-17 stsp * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 718b3ab0 2018-03-17 stsp * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 718b3ab0 2018-03-17 stsp * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 718b3ab0 2018-03-17 stsp * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 718b3ab0 2018-03-17 stsp * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 718b3ab0 2018-03-17 stsp * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 718b3ab0 2018-03-17 stsp * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 718b3ab0 2018-03-17 stsp */
16 718b3ab0 2018-03-17 stsp
17 718b3ab0 2018-03-17 stsp #define GOT_PACKIDX_CACHE_SIZE 64
18 718b3ab0 2018-03-17 stsp #define GOT_PACK_CACHE_SIZE GOT_PACKIDX_CACHE_SIZE
19 718b3ab0 2018-03-17 stsp
20 7bb0daa1 2018-06-21 stsp #define GOT_OBJECT_CACHE_SIZE 8192
21 7bb0daa1 2018-06-21 stsp
22 54f20211 2018-06-22 stsp struct got_object_cache_entry {
23 7bb0daa1 2018-06-21 stsp struct got_object_id id;
24 7bb0daa1 2018-06-21 stsp struct got_object *obj;
25 7bb0daa1 2018-06-21 stsp };
26 7bb0daa1 2018-06-21 stsp
27 54f20211 2018-06-22 stsp struct got_object_cache {
28 54f20211 2018-06-22 stsp struct got_object_idset *set;
29 54f20211 2018-06-22 stsp int ncached;
30 54f20211 2018-06-22 stsp int cache_hit;
31 54f20211 2018-06-22 stsp int cache_miss;
32 54f20211 2018-06-22 stsp };
33 54f20211 2018-06-22 stsp
34 718b3ab0 2018-03-17 stsp struct got_repository {
35 718b3ab0 2018-03-17 stsp char *path;
36 718b3ab0 2018-03-17 stsp char *path_git_dir;
37 718b3ab0 2018-03-17 stsp
38 718b3ab0 2018-03-17 stsp /* The pack index cache speeds up search for packed objects. */
39 6fd11751 2018-06-04 stsp struct got_packidx *packidx_cache[GOT_PACKIDX_CACHE_SIZE];
40 718b3ab0 2018-03-17 stsp
41 6c6d3ed3 2018-04-02 stsp /* Open file handles for pack files. */
42 718b3ab0 2018-03-17 stsp struct got_pack packs[GOT_PACK_CACHE_SIZE];
43 7bb0daa1 2018-06-21 stsp
44 54f20211 2018-06-22 stsp struct got_object_cache objcache;
45 718b3ab0 2018-03-17 stsp };
46 7bb0daa1 2018-06-21 stsp
47 7bb0daa1 2018-06-21 stsp const struct got_error*
48 7bb0daa1 2018-06-21 stsp got_repo_cache_object(struct got_repository *, struct got_object_id *,
49 7bb0daa1 2018-06-21 stsp struct got_object *);
50 7bb0daa1 2018-06-21 stsp struct got_object *got_repo_get_cached_object(struct got_repository *,
51 7bb0daa1 2018-06-21 stsp struct got_object_id *);