summaryrefslogtreecommitdiff
path: root/src/pack.h
Commit message (Collapse)AuthorAgeFilesLines
* pack: refactor streams to use `git_zstream`Patrick Steinhardt2020-01-091-4/+3
| | | | | | While we do have a `git_zstream` abstraction that encapsulates all the calls to zlib as well as its error handling, we do not use it in our pack file code. Refactor it to make the code a lot easier to understand.
* internal: use off64_t instead of git_off_tethomson/off_tEdward Thomson2019-11-251-11/+11
| | | | Prefer `off64_t` internally.
* maps: use uniform lifecycle management functionsPatrick Steinhardt2019-02-151-3/+1
| | | | | | | | | | | | | | | | Currently, the lifecycle functions for maps (allocation, deallocation, resize) are not named in a uniform way and do not have a uniform function signature. Rename the functions to fix that, and stick to libgit2's naming scheme of saying `git_foo_new`. This results in the following new interface for allocation: - `int git_<t>map_new(git_<t>map **out)` to allocate a new map, returning an error code if we ran out of memory - `void git_<t>map_free(git_<t>map *map)` to free a map - `void git_<t>map_clear(git<t>map *map)` to remove all entries from a map This commit also fixes all existing callers.
* object_type: use new enumeration namesethomson/index_fixesEdward Thomson2018-12-011-5/+5
| | | | Use the new object_type enumeration names within the codebase.
* pack: rename `git_packfile_stream_free`Patrick Steinhardt2018-06-101-1/+1
| | | | | | | | | | | | The function `git_packfile_stream_free` frees all state of the packfile stream without freeing the structure itself. This naming makes it hard to spot whether it will try to free the pointer itself or not, causing potential future errors. Due to this reason, we have decided to name a function freeing state without freeing the actual struture a "dispose" function. Rename `git_packfile_stream_free` to `git_packfile_stream_dispose` as a first example following this rule.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-1/+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.
* indexer: introduce `git_packfile_close`Edward Thomson2017-01-211-0/+1
| | | | Encapsulation!
* odb: only freshen pack files every 2 secondsethomson/refresh_objectsEdward Thomson2016-08-041-0/+2
| | | | | | Since writing multiple objects may all already exist in a single packfile, avoid freshening that packfile repeatedly in a tight loop. Instead, only freshen pack files every 2 seconds.
* Make packfile_unpack_compressed a private APIP.S.V.R2016-01-131-7/+0
|
* Reorder some khash declarationsCarlos Martín Nieto2015-03-111-3/+1
| | | | | | Keep the definitions in the headers, while putting the declarations in the C files. Putting the function definitions in headers causes them to be duplicated if you include two headers with them.
* Remove extra semicolon outside of a functionStefan Widgren2015-02-151-2/+2
| | | | | Without this change, compiling with gcc and pedantic generates warning: ISO C does not allow extra ‘;’ outside of a function.
* Share packs across repository instancescmn/global-mwfCarlos Martín Nieto2014-06-231-0/+3
| | | | | | | | | | | Opening the same repository multiple times will currently open the same file multiple times, as well as map the same region of the file multiple times. This is not necessary, as the packfile data is immutable. Instead of opening and closing packfiles directly, introduce an indirection and allocate packfiles globally. This does mean locking on each packfile open, but we already use this lock for the global mwindow list so it doesn't introduce a new contention point.
* pack: expose a cached delta base directlyCarlos Martín Nieto2014-05-131-4/+0
| | | | | Instead of going through a special entry in the chain, let's pass it as an output parameter.
* pack: use a cache for delta bases when unpackingCarlos Martín Nieto2014-05-091-0/+5
| | | | | | Bring back the use of the delta base cache for unpacking objects. When generating the delta chain, we stop when we find a delta base in the pack's cache and use that as the starting point.
* pack: unpack using a loopCarlos Martín Nieto2014-05-091-0/+9
| | | | | | | | | | | | | | | We currently make use of recursive function calls to unpack an object, resolving the deltas as we come back down the chain. This means that we have unbounded stack growth as we look up objects in a pack. This is now done in two steps: first we figure out what the dependency chain is by looking up the delta bases until we reach a non-delta object, pushing the information we need onto a stack and then we pop from that stack and apply the deltas until there are no more left. This version of the code does not make use of the delta base cache so it is slower than what's in the mainline. A later commit will reintroduce it.
* Drop parsing pack filename SHA1 part, no one cares the filenameLinquize2014-01-231-1/+0
|
* pack: `__object_header` always returns unsigned valuesVicent Marti2013-11-011-1/+1
|
* Fix warning on win64Linquize2013-11-011-1/+1
|
* pack: move the object header function hereCarlos Martín Nieto2013-10-041-0/+2
|
* Consolidate packfile allocation furtherRussell Belfer2013-04-221-1/+2
| | | | | | | Rename git_packfile_check to git_packfile_alloc since it is now being used more in that capacity. Fix the various places that use it. Consolidate some repeated code in odb_pack.c related to the allocation of a new pack_backend.
* Further threading fixesRussell Belfer2013-04-221-1/+1
| | | | | | | | | | | | | This builds on the earlier thread safety work to make it so that setting the odb, index, refdb, or config for a repository is done in a threadsafe manner with minimized locking time. This is done by adding a lock to the repository object and using it to guard the assignment of the above listed pointers. The lock is only held to assign the pointer value. This also contains some minor fixes to the other work with pack files to reduce the time that locks are being held to and fix an apparently memory leak.
* Add mutex around mapping and unmapping pack filesRussell Belfer2013-04-221-0/+1
| | | | | | | | | | | When I was writing threading tests for the new cache, the main error I kept running into was a pack file having it's content unmapped underneath the running thread. This adds a lock around the routines that map and unmap the pack data so that threads can effectively reload the data when they need it. This also required reworking the error handling paths in a couple places in the code which I tried to make consistent.
* indexer: use a hashtable for keeping track of offsetsCarlos Martín Nieto2013-03-031-1/+3
| | | | | | | | | | These offsets are needed for REF_DELTA objects, which encode which object they use as a base, but not where it lies in the packfile, so we need a list. These objects are mostly from older packfiles, before OFS_DELTA was widely spread. The time spent in indexing these packfiles is greatly reduced, though remains above what git is able to do.
* indexer: properly free the packfile resourcesCarlos Martín Nieto2013-01-121-1/+1
| | | | | | | | The indexer needs to call the packfile's free function so it takes care of freeing the caches. We still need to close the mwf descriptor manually so we can rename the packfile into its final name on Windows.
* Revert "pack: packfile_free -> git_packfile_free and use it in the indexers"Carlos Martín Nieto2013-01-111-1/+1
| | | | | | This reverts commit f289f886cb81bb570bed747053d5ebf8aba6bef7, which makes the tests fail on Windows. Revert until we can figure out a solution.
* pack: That declarationVicent Marti2013-01-111-1/+1
|
* pack: limit the amount of memory the base delta cache can useCarlos Martín Nieto2013-01-111-2/+4
| | | | | Currently limited to 16MB (like git) and to objects up to 1MB in size.
* pack: abstract out the cache into its own functionsCarlos Martín Nieto2013-01-111-2/+11
|
* pack: refcount entries and add a mutex around cache accessCarlos Martín Nieto2013-01-111-1/+2
|
* pack: introduce a delta base cacheCarlos Martín Nieto2013-01-111-0/+11
| | | | | | | | Many delta bases are re-used. Cache them to avoid inflating the same data repeatedly. This version doesn't limit the amount of entries to store, so it can end up using a considerable amound of memory.
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Merge pull request #1091 from carlosmn/stream-objectVicent Martí2012-12-071-0/+14
|\ | | | | Indexer speedup with large objects
| * pack: introduce a streaming API for raw objectsCarlos Martín Nieto2012-11-301-0/+14
| | | | | | | | | | This allows us to take objects from the packfile as a stream instead of having to keep it all in memory.
* | pack: add git_packfile_resolve_headerDavid Michael Barr2012-12-031-0/+6
|/ | | | | | | | | | | | | | | | | | To paraphrase @peff: You can get both size and type from a packed object reasonably cheaply. If you have: * An object that is not a delta; both type and size are available in the packfile header. * An object that is a delta. The packfile type will be OBJ_*_DELTA, and you have to resolve back to the base to find the real type. That means potentially a lot of packfile index lookups, but each one is relatively cheap. For the size, you inflate the first few bytes of the delta, whose header will tell you the resulting size of applying the delta to the base. For simplicity, we just decompress the whole delta for now.
* Make git_odb_foreach_cb take const paramRussell Belfer2012-11-271-1/+1
| | | | | This makes the first OID param of the ODB callback a const pointer and also propogates that change all the way to the backends.
* pack: iterate objects in offset orderDavid Michael Barr2012-09-141-0/+1
| | | | Compute the ordering on demand and persist until the index is freed.
* portability: Improve x86/amd64 compatibilitynulltoken2012-07-241-1/+1
|
* odb: add git_odb_foreach()Carlos Martín Nieto2012-07-031-0/+4
| | | | | Go through each backend and list every objects that exists in them. This allows fsck-like uses.
* Add packfile_unpack_compressed() to the internal headerCarlos Martín Nieto2012-04-131-0/+7
|
* Migrate ODB files to new error handlingRussell Belfer2012-03-121-6/+6
| | | | | | | | | | | | | | This migrates odb.c, odb_loose.c, odb_pack.c and pack.c to the new style of error handling. Also got the unix and win32 versions of map.c. There are some minor changes to other files but no others were completely converted. This also contains an update to filebuf so that a zeroed out filebuf will not think that the fd (== 0) is actually open (and inadvertently call close() on fd 0 if cleaned up). Lastly, this was built and tested on win32 and contains a bunch of fixes for the win32 build which was pretty broken.
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* *: correct and codify various file permissionsBrodie Rao2011-10-141-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following files now have 0444 permissions: - loose objects - pack indexes - pack files - packs downloaded by fetch - packs downloaded by the HTTP transport And the following files now have 0666 permissions: - config files - repository indexes - reflogs - refs This brings libgit2 more in line with Git. Note that git_filebuf_commit() and git_filebuf_commit_at() have both gained a new mode parameter. The latter change fixes an important issue where filebufs created with GIT_FILEBUF_TEMPORARY received 0600 permissions (due to mkstemp(3) usage). Now we chmod() the file before renaming it into place. Tests have been added to confirm that new commit, tag, and tree objects are created with the right permissions. I don't have access to Windows, so for now I've guarded the tests with "#ifndef GIT_WIN32".
* Tabify everythingVicent Marti2011-09-191-1/+1
| | | | | | There were quite a few places were spaces were being used instead of tabs. Try to catch them all. This should hopefully not break anything. Except for `git blame`. Oh well.
* Cleanup legal dataVicent Marti2011-09-191-21/+3
| | | | | | | | | | 1. The license header is technically not valid if it doesn't have a copyright signature. 2. The COPYING file has been updated with the different licenses used in the project. 3. The full GPLv2 header in each file annoys me.
* Implement cooperative cachingCarlos Martín Nieto2011-08-181-1/+2
| | | | | | | | | When indexing a file with ref deltas, a temporary cache for the offsets has to be built, as we don't have an index file yet. If the user takes the responsiblity for filling the cache, the packing code will look there first when it finds a ref delta. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* Modify the given offset in git_packfile_unpackCarlos Martín Nieto2011-08-021-1/+1
| | | | | | | | The callers immediately throw away the offset, so we don't need any logical changes in any of them. This will be useful for the indexer, as it does need to know where the compressed data ends. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* Move pack functions to their own fileCarlos Martín Nieto2011-08-021-19/+15
|
* Make packfile_unpack_header more genericCarlos Martín Nieto2011-08-021-2/+26
| | | | | | On the way, store the fd and the size in the mwindow file. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* Move the pack structs to an internal headerCarlos Martín Nieto2011-08-021-0/+94