git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Daniel Barkalow <barkalow@iabervon.org>
Cc: git@vger.kernel.org, Junio C Hamano <junkio@cox.net>
Subject: Re: [PATCH 3/3] Use struct tree in diff-tree
Date: Tue, 31 Jan 2006 08:53:53 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0601310846380.7301@g5.osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0601291405250.25300@iabervon.org>



On Sun, 29 Jan 2006, Daniel Barkalow wrote:
>
> It had been open-coding a tree parser. This updates the programs that
> call diff_tree() to send it the struct tree instead of a buffer and
> size.

Please don't.

parse_tree() is extremely broken, and expensive. 

The "struct tree_desc" is a much better abstraction, and avoids all 
overhead. Yes, it's slightly more opaque, and the interfaces could be 
improved: for example, instead of having a

	desc.buf = read_object_with_reference(new, "tree", &desc.size, NULL);
	if (!desc.buf)
		die("unable to read tree");

it might make make sense to introduce a function that does this for you, 
ie just a

	if (populate_tree_descriptor(new, &desc) < 0)
		die("unable to read tree");
	...
	free_tree_descriptor(&desc);

which is perhaps more readable and maintainable.

The "diff_tree()" functions are _extremely_ performance-critical, arguably 
more so than _any_ other part of git. Diffing two trees is one of _the_ 
most common operations, especially so when you want to follow just a 
subset of files with "git-rev-list -- <filename>*", and it's extremely 
important that you don't do malloc()/free() all the time.

So using "struct tree" and the general tree-parsing functions is _wrong_. 
Really REALLY wrong.

>From what I can tell, your version doesn't even do the "free()". Which 
probably means that not only is it slower, but I bet that if you have a 
big repository like the kernel, and you do a slightly more complex 
git-rev-list with multiple files, you'll use up tons and tons and tons of 
memory.

Junio, please don't apply this.

		Linus

  reply	other threads:[~2006-01-31 16:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-29 19:04 [PATCH 0/3] Remove more parsers Daniel Barkalow
2006-01-29 19:04 ` [PATCH 1/3] Use struct tree in tar-tree Daniel Barkalow
2006-01-29 19:05 ` [PATCH 2/3] Use struct commit " Daniel Barkalow
2006-01-29 19:05 ` [PATCH 3/3] Use struct tree in diff-tree Daniel Barkalow
2006-01-31 16:53   ` Linus Torvalds [this message]
2006-01-31 21:20     ` Junio C Hamano
2006-01-31 21:49       ` Daniel Barkalow
2006-01-31 22:07       ` Linus Torvalds
2006-01-29 20:26 ` [PATCH 0/3] Remove more parsers Junio C Hamano
2006-01-29 22:05   ` Daniel Barkalow
2006-01-31 17:16     ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0601310846380.7301@g5.osdl.org \
    --to=torvalds@osdl.org \
    --cc=barkalow@iabervon.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).