Re: I'm a total push-over..

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Tuesday, January 22, 2008 - 7:58 pm

On Tue, 22 Jan 2008, Junio C Hamano wrote:

I really hate that. 

Basically, I dislike having two copies of the same data. If something can 
be computed from something else, then only the original data should exist, 
and the other thing should be recomputed. Otherwise you easily get into 
situations where you spend a lot of time maintaining the other copy, or 
worse, you have inconsistent data and it's really subtle what is going on.

Also, one of the ideas behind the index is that would depend on your 
notion of what is "equivalent", which is actually somehing fairly fluid. 
In fact, it's likely going to depend on a config option.

So encoding the indexing on disk, when it can change when you do a simple 
"git config", or even just depending on your LANG environment variable, 
seems like a singularly bad idea, even if it wasn't for the coherence.

I did consider doing the indexing only on demand, and we can certainly 
simply just "turn it off" when we know it's never going to get used (ie 
"git ls-files"). So in that sense, it's easy to get rid of the overhead, 
but it didn't really seem like the conceptual complexity (even if it's 
just a couple of lines) is really worth it. It's not like git ls-files is 
really performance-critical anyway.


Now this, of course, is obviously true.

And the patch to do that is very simple too. No need to walk any chains, 
since the "free(istate->alloc);" will release all the pre-allocated 
cache_entry structures, and the rest are (necessarily) leaked anyway.

[ Side note for non-Junios: the leaking of cache_entry structures isn't 
  new, we've always done it, and it's even done on purpose. The common 
  case is that there is one *big* allocation (istate->alloc) that contains 
  all the original cache entries.

  There are usually none, or only a very few individual allocations, and 
  we don't even keep track of them. With the new in-memory format, we 
  could make a special flag that does "is this cache-entry an individual 
  allocation or not" (or we could even just see if they are inside the 
  "alloc" range), but the common case really should be that there's just a 
  couple of them, and we just drop them rather than tracking them. ]

Here.

		Linus

---
 read-cache.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/read-cache.c b/read-cache.c
index 33a8ca5..abee0fc 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1142,6 +1142,7 @@ int discard_index(struct index_state *istate)
 	istate->cache_nr = 0;
 	istate->cache_changed = 0;
 	istate->timestamp = 0;
+	free_hash(&istate->name_hash);
 	cache_tree_free(&(istate->cache_tree));
 	free(istate->alloc);
 	istate->alloc = NULL;
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
I'm a total push-over.., Linus Torvalds, (Tue Jan 22, 4:37 pm)
Re: I'm a total push-over.., Kevin Ballard, (Tue Jan 22, 6:35 pm)
Re: I'm a total push-over.., Junio C Hamano, (Tue Jan 22, 7:23 pm)
Re: I'm a total push-over.., Junio C Hamano, (Tue Jan 22, 7:36 pm)
Re: I'm a total push-over.., Linus Torvalds, (Tue Jan 22, 7:58 pm)
Re: I'm a total push-over.., Linus Torvalds, (Tue Jan 22, 8:19 pm)
Re: I'm a total push-over.., Junio C Hamano, (Wed Jan 23, 12:23 am)
Re: I'm a total push-over.., Andreas Ericsson, (Wed Jan 23, 1:32 am)
Re: I'm a total push-over.., Dmitry Potapov, (Wed Jan 23, 2:15 am)
Re: I'm a total push-over.., Andreas Ericsson, (Wed Jan 23, 2:31 am)
Re: I'm a total push-over.., Johannes Schindelin, (Wed Jan 23, 5:24 am)
Re: I'm a total push-over.., Johannes Schindelin, (Wed Jan 23, 5:25 am)
Re: I'm a total push-over.., David Kastrup, (Wed Jan 23, 5:28 am)
Re: I'm a total push-over.., Theodore Tso, (Wed Jan 23, 5:56 am)
Re: I'm a total push-over.., Marko Kreen, (Wed Jan 23, 7:01 am)
Re: I'm a total push-over.., Andreas Ericsson, (Wed Jan 23, 7:39 am)
Re: I'm a total push-over.., Linus Torvalds, (Wed Jan 23, 9:06 am)
Re: I'm a total push-over.., Linus Torvalds, (Wed Jan 23, 9:25 am)
Re: I'm a total push-over.., Johannes Schindelin, (Wed Jan 23, 9:34 am)
Re: I'm a total push-over.., Linus Torvalds, (Wed Jan 23, 10:09 am)
Re: I'm a total push-over.., Dmitry Potapov, (Wed Jan 23, 10:10 am)
Re: I'm a total push-over.., Linus Torvalds, (Wed Jan 23, 10:29 am)
Re: I'm a total push-over.., Luke Lu, (Wed Jan 23, 11:51 pm)
Re: I'm a total push-over.., Andreas Ericsson, (Thu Jan 24, 3:24 am)
Re: I'm a total push-over.., Andreas Ericsson, (Thu Jan 24, 3:39 am)
Re: I'm a total push-over.., Marko Kreen, (Thu Jan 24, 6:19 am)
Re: I'm a total push-over.., Andreas Ericsson, (Thu Jan 24, 9:00 am)
Re: I'm a total push-over.., Marko Kreen, (Thu Jan 24, 9:13 am)
Re: I'm a total push-over.., Dmitry Potapov, (Thu Jan 24, 9:28 am)
Re: I'm a total push-over.., Linus Torvalds, (Thu Jan 24, 10:15 am)
Re: I'm a total push-over.., Dmitry Potapov, (Thu Jan 24, 11:45 am)
Re: I'm a total push-over.., Linus Torvalds, (Thu Jan 24, 12:08 pm)
Re: I'm a total push-over.., Jeremy Maitin-Shepard, (Thu Jan 24, 10:21 pm)
Re: I'm a total push-over.., Junio C Hamano, (Thu Jan 24, 11:50 pm)
Re: I'm a total push-over.., Johannes Schindelin, (Fri Jan 25, 5:51 am)
Re: I'm a total push-over.., Linus Torvalds, (Fri Jan 25, 9:24 am)
Re: I'm a total push-over.., Jeremy Maitin-Shepard, (Fri Jan 25, 11:19 am)
Re: I'm a total push-over.., Johannes Schindelin, (Fri Jan 25, 11:24 am)
Re: I'm a total push-over.., Junio C Hamano, (Fri Jan 25, 12:07 pm)
Re: I'm a total push-over.., Marko Kreen, (Fri Jan 25, 1:08 pm)
Re: I'm a total push-over.., Marko Kreen, (Fri Jan 25, 1:52 pm)
Re: I'm a total push-over.., Linus Torvalds, (Fri Jan 25, 3:16 pm)
Re: I'm a total push-over.., Linus Torvalds, (Fri Jan 25, 3:35 pm)
Re: I'm a total push-over.., Marko Kreen, (Sat Jan 26, 5:16 am)
Re: I'm a total push-over.., Marko Kreen, (Sat Jan 26, 5:37 am)
Re: I'm a total push-over.., Linus Torvalds, (Sat Jan 26, 11:51 pm)
Re: I'm a total push-over.., Dmitry Potapov, (Sun Jan 27, 1:21 am)
Re: I'm a total push-over.., Marko Kreen, (Sun Jan 27, 2:45 am)
Re: I'm a total push-over.., Johannes Schindelin, (Sun Jan 27, 7:07 am)
Re: I'm a total push-over.., Dmitry Potapov, (Sun Jan 27, 7:48 am)
Re: I'm a total push-over.., Dmitry Potapov, (Sun Jan 27, 8:06 am)