From 5fc2fc8fa22312efca46ed5321fa1d3b4d537a72 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Fri, 13 Jun 2014 19:19:36 +0700 Subject: read-cache: split-index mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This split-index mode is designed to keep write cost proportional to the number of changes the user has made, not the size of the work tree. (Read cost is another matter, to be dealt separately.) This mode stores index info in a pair of $GIT_DIR/index and $GIT_DIR/sharedindex.. sharedindex is large and unchanged over time while "index" is smaller and updated often. Format details are in index-format.txt, although not everything is implemented in this patch. Shared indexes are not automatically removed, because it's unclear if the shared index is needed by any (even temporary) indexes by just looking at it. After a while you'll collect stale shared indexes. The good news is one shared index is useable for long, until $GIT_DIR/index becomes too big and sluggish that the new shared index must be created. The safest way to clean shared indexes is to turn off split index mode, so shared files are all garbage, delete them all, then turn on split index mode again. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- split-index.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 split-index.h (limited to 'split-index.h') diff --git a/split-index.h b/split-index.h new file mode 100644 index 000000000..8d7404117 --- /dev/null +++ b/split-index.h @@ -0,0 +1,25 @@ +#ifndef SPLIT_INDEX_H +#define SPLIT_INDEX_H + +struct index_state; +struct strbuf; + +struct split_index { + unsigned char base_sha1[20]; + struct index_state *base; + unsigned int saved_cache_nr; + int refcount; +}; + +struct split_index *init_split_index(struct index_state *istate); +int read_link_extension(struct index_state *istate, + const void *data, unsigned long sz); +int write_link_extension(struct strbuf *sb, + struct index_state *istate); +void move_cache_to_base_index(struct index_state *istate); +void merge_base_index(struct index_state *istate); +void prepare_to_write_split_index(struct index_state *istate); +void finish_writing_split_index(struct index_state *istate); +void discard_split_index(struct index_state *istate); + +#endif -- cgit v1.2.3