summaryrefslogtreecommitdiff
path: root/src/cache.c
Commit message (Collapse)AuthorAgeFilesLines
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-3/+3
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* object_type: use new enumeration namesethomson/index_fixesEdward Thomson2018-12-011-10/+10
| | | | Use the new object_type enumeration names within the codebase.
* khash: remove intricate knowledge of khash typesPatrick Steinhardt2018-11-281-3/+3
| | | | | | | Instead of using the `khiter_t`, `git_strmap_iter` and `khint_t` types, simply use `size_t` instead. This decouples code from the khash stuff and makes it possible to move the khash includes into the implementation files.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
* oidmap: remove GIT__USE_OIDMAP macroPatrick Steinhardt2017-02-171-2/+0
|
* khash: avoid using macro magic to get return addressPatrick Steinhardt2017-02-171-1/+1
|
* khash: avoid using `kh_key`/`kh_val` as lvaluePatrick Steinhardt2017-02-171-2/+2
|
* khash: avoid using `kh_del` directlyPatrick Steinhardt2017-02-171-1/+1
|
* khash: avoid using `kh_key` directlyPatrick Steinhardt2017-02-171-4/+2
|
* khash: avoid using `kh_val`/`kh_value` directlyPatrick Steinhardt2017-02-171-5/+5
|
* khash: avoid using `kh_exist` directlyPatrick Steinhardt2017-02-171-1/+1
|
* khash: avoid using `kh_clear` directlyPatrick Steinhardt2017-02-171-1/+1
|
* khash: avoid using `kh_get` directlyPatrick Steinhardt2017-02-171-2/+2
|
* khash: avoid using `kh_end` directlyPatrick Steinhardt2017-02-171-3/+3
|
* khash: avoid using `kh_foreach`/`kh_foreach_value` directlyPatrick Steinhardt2017-02-171-2/+2
|
* khash: avoid using `kh_size` directlyPatrick Steinhardt2017-02-171-5/+5
|
* giterr_set: consistent error messagesEdward Thomson2016-12-291-1/+1
| | | | | | | | Error messages should be sentence fragments, and therefore: 1. Should not begin with a capital letter, 2. Should not conclude with punctuation, and 3. Should not end a sentence and begin a new one
* Fix #3094 - improve use of portable size_t/ssize_t format specifiers.Matthew Plough2015-07-121-4/+4
| | | | The header src/cc-compat.h defines portable format specifiers PRIuZ, PRIdZ, and PRIxZ. The original report highlighted the need to use these specifiers in examples/network/fetch.c. For this commit, I checked all C source and header files not in deps/ and transitioned to the appropriate format specifier where appropriate.
* cache: add a check for a failed allocationCarlos Martín Nieto2015-06-101-0/+1
| | | | Rather minimal change, but it's the kind of thing we should do.
* Refactor git_cache to use an rwlockJustin Spahr-Summers2014-08-261-9/+9
| | | | | This significantly reduces contention when many threads are trying to read from the cache simultaneously.
* util: It's called `memzero`Vicent Marti2013-06-121-1/+1
|
* Add safe memset and use itRussell Belfer2013-06-071-1/+1
| | | | | | This adds a `git__memset` routine that will not be optimized away and updates the places where I memset() right before a free() call to use it.
* Mutex init can failRussell Belfer2013-05-311-1/+4
| | | | | | | It is obviously quite a serious problem if this happens, but mutex initialization can fail and we should detect it. It's a bit like a memory allocation failure, in that you're probably pretty screwed if this occurs, but at least we'll catch it.
* Zero memory for major objects before freeingRussell Belfer2013-05-311-2/+2
| | | | | | | By zeroing out the memory when we free larger objects (i.e. those that serve as collections of other data, such as repos, odb, refdb), I'm hoping that it will be easier for libgit2 bindings to find errors in their object management code.
* Docs for git_libgit2_opts and cache disable tweakRussell Belfer2013-05-241-0/+5
| | | | | | | This adds docs for the cache control options to git_libgit2_opts and also tweaks the cache code so that if the cache is disabled, then the next time we attempt to insert something into the cache in question, we will actually clear any old cached objects.
* git_atomic_ssize for 64-bit atomics only on 64-bit platformsEdward Thomson2013-04-251-6/+7
|
* repo: Add `git_repository__cleanup`Vicent Marti2013-04-241-0/+3
|
* opts: Add getter for cached memoryvmg/atomic64Vicent Marti2013-04-231-2/+1
|
* cache: More aggressive defaultVicent Marti2013-04-221-1/+1
|
* cache: Shared meter for memory usageVicent Marti2013-04-221-4/+12
|
* cache: Max cache size, and evict when the cache fills upvmg/new-cacheVicent Marti2013-04-221-7/+18
|
* Add callback to git_objects_tableRussell Belfer2013-04-221-6/+8
| | | | | | | | | | This adds create and free callback to the git_objects_table so that more of the creation and destruction of objects can be table driven instead of using switch statements. This also makes the semantics of certain object creation functions consistent so that we can make better use of function pointers. This also fixes a theoretical error case where an object allocation fails and we end up storing NULL into the cache.
* Add range checking around cache optsRussell Belfer2013-04-221-6/+17
| | | | | | | Add a git_cache_set_max_object_size method that does more checking around setting the max object size. Also add a git_cache_size to read the number of objects currently in the cache. This makes it easier to write tests.
* Global option settersVicent Marti2013-04-221-6/+4
|
* Clear the cache when there are too many items to expireVicent Marti2013-04-221-1/+20
|
* Some statsVicent Marti2013-04-221-0/+21
|
* Per-object max sizeVicent Marti2013-04-221-28/+28
|
* What has science done.Vicent Marti2013-04-221-2/+2
|
* Random evictionVicent Marti2013-04-221-1/+18
|
* Per-object filteringVicent Marti2013-04-221-6/+31
|
* lol this worked first try wtfVicent Marti2013-04-221-61/+108
|
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* orite C89Justin Spahr-Summers2012-12-091-2/+2
|
* Always check the result of git_mutex_lockJustin Spahr-Summers2012-12-091-5/+13
|
* Fix a mutex/critical section leakPhilip Kelley2012-11-091-0/+1
|
* cache: fix race conditionMichael Schubert2012-09-111-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Example: a cached node is owned only by the cache (refcount == 1). Thread A holds the lock and determines that the entry which should get cached equals the node (git_oid_cmp(&node->oid, &entry->oid) == 0). It frees the given entry to instead return the cached node to the user (entry = node). Now, before Thread A happens to increment the refcount of the node *outside* the cache lock, Thread B tries to store another entry and hits the slot of the node before, decrements its refcount and frees it *before* Thread A gets a chance to increment for the user. git_cached_obj_incref(entry); git_mutex_lock(&cache->lock); { git_cached_obj *node = cache->nodes[hash & cache->size_mask]; if (node == NULL) { cache->nodes[hash & cache->size_mask] = entry; } else if (git_oid_cmp(&node->oid, &entry->oid) == 0) { git_cached_obj_decref(entry, cache->free_obj); entry = node; } else { git_cached_obj_decref(node, cache->free_obj); // Thread B is here cache->nodes[hash & cache->size_mask] = entry; } } git_mutex_unlock(&cache->lock); // Thread A is here /* increase the refcount again, because we are * returning it to the user */ git_cached_obj_incref(entry);
* oid: Explicitly include `oid.h` for the inlined CMPVicent Marti2012-08-091-0/+1
|
* misc: Fix warnings from PVS Studio trialVicent Martí2012-06-071-1/+1
|
* Moving power-of-two bit utilities into util.hRussell Belfer2012-04-251-9/+2
|
* Convert attr, ignore, mwindow, status to new errorsRussell Belfer2012-03-161-3/+2
| | | | | Also cleaned up some previously converted code that still had little things to polish.