Re: [RFC \ WISH] Add -o option to git-rev-list

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linus Torvalds
Date: Sunday, December 10, 2006 - 3:53 pm

On Sun, 10 Dec 2006, Marco Costalba wrote:

That's because fread() will block until it gets all data. Did you actually 
ever try this with a uncached tree and did you compare what you got with a 
plain "read()". 

On older kernels, I guarantee that you get 4kB at a time for reads, even 
for a blocking pipe. Because we have bigger pipe buffers these days, it 
_may_ return 64kB at a time every time, but only if the writer is much 
faster than the reader.

Based on the fact that you say that "read()" was ten times slower than 
fread(), I very much suspect you got 4kB at a time, and then slept 100ms 
each time or something.

Anyway, you should seriously also check the case when "git rev-list" is 
slow because you have cold caches and unpacked objects. You can't wait for 
it to synchronously write a thousand lines or so - that could take 
seconds.


something like

	fcntl(fileno(file), F_SETFL, O_NONBLOCK);

will do it, and then your loop should look something like

	for (;;) {
		int count = read(fileno(file), buf, BUFSIZE);
		if (!count) {
			/* All done, no more to read */
			return 0;
		}
		if (count < 0) {
			if (errno == EAGAIN)
				break;
			if (errno == EINTR)
				continue;
			/* Anything else is fatal - report error */
			return -1;
		}
		... handle 'count' new bytes here ...
	}
	.. this is the EAGAIN case ..
	either set polling on the file descriptor, or use a
	timer here yo get back to this loop eventually.

looks about right.

		Linus
-
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:
[RFC \ WISH] Add -o option to git-rev-list, Marco Costalba, (Sun Dec 10, 4:38 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Alex Riesen, (Sun Dec 10, 7:54 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Linus Torvalds, (Sun Dec 10, 11:16 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Marco Costalba, (Sun Dec 10, 12:51 pm)
globs in partial checkout?, Michael S. Tsirkin, (Sun Dec 10, 1:00 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Linus Torvalds, (Sun Dec 10, 1:08 pm)
Re: globs in partial checkout?, Linus Torvalds, (Sun Dec 10, 1:13 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Linus Torvalds, (Sun Dec 10, 1:19 pm)
Re: globs in partial checkout?, Michael S. Tsirkin, (Sun Dec 10, 2:07 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Marco Costalba, (Sun Dec 10, 3:05 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Marco Costalba, (Sun Dec 10, 3:09 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Linus Torvalds, (Sun Dec 10, 3:16 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Marco Costalba, (Sun Dec 10, 3:35 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Linus Torvalds, (Sun Dec 10, 3:53 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Marco Costalba, (Sun Dec 10, 5:15 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Linus Torvalds, (Sun Dec 10, 5:51 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Marco Costalba, (Mon Dec 11, 12:17 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Josef Weidendorfer, (Mon Dec 11, 2:26 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Alex Riesen, (Mon Dec 11, 3:00 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Andreas Ericsson, (Mon Dec 11, 4:39 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Marco Costalba, (Mon Dec 11, 5:52 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Marco Costalba, (Mon Dec 11, 5:59 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Josef Weidendorfer, (Mon Dec 11, 6:28 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Andreas Ericsson, (Mon Dec 11, 6:40 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Linus Torvalds, (Mon Dec 11, 9:59 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Linus Torvalds, (Mon Dec 11, 10:07 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Marco Costalba, (Mon Dec 11, 10:28 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Marco Costalba, (Mon Dec 11, 10:39 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Linus Torvalds, (Mon Dec 11, 11:15 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Marco Costalba, (Mon Dec 11, 11:59 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Linus Torvalds, (Mon Dec 11, 12:25 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Josef Weidendorfer, (Mon Dec 11, 1:28 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Linus Torvalds, (Mon Dec 11, 1:40 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Josef Weidendorfer, (Mon Dec 11, 1:54 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Linus Torvalds, (Mon Dec 11, 2:14 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Marco Costalba, (Fri Dec 15, 11:45 am)
Re: [RFC \ WISH] Add -o option to git-rev-list, Linus Torvalds, (Fri Dec 15, 12:20 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Marco Costalba, (Fri Dec 15, 1:41 pm)
Re: [RFC \ WISH] Add -o option to git-rev-list, Marco Costalba, (Fri Dec 15, 2:04 pm)