You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by "C. Michael Pilato" <cm...@collab.net> on 2011/05/24 17:30:39 UTC

[PATCH] Server-transmitted "final SHA1 checksums" (Was: "large number of large binary files in subversion")

On 05/24/2011 04:23 AM, Stefan Sperling wrote:
> On Tue, May 24, 2011 at 12:04:26PM +0530, Arwin Arni wrote:
>> Why can't we send the recorded checksum from the server instead of
>> sending the whole file and then calculating it on the client side?
>>
>> If the checksum matches one of the pristine files, then use that to
>> populate the nodes table. If there is no match, only then do we
>> spool to a temporary file and what not.
>>
>> This seems like a straightforward idea. Any pitfalls to this approach?
> 
> The pitfall is that you need to change the client<->server interface.
> 
> The current interface at subversion/include/svn_delta.h only transmits
> checksums before and after applying deltas. First it transmits the checksum
> of the expected base text for the delta (apply_textdelta), and then,
> after the delta has been applied, it sends the expected checksum of the
> content resulting from application of the delta to the base (close_file).
> This interface doesn't prevent data from being transmitted.

Heheh... I'm sitting on a patch which transmits the "final sha1 checksum"
*before* file contents would be transmitted over DAV.  Something I whipped
up before hopping on the plane out of Berlin.  I was hoping to slip in
support for avoiding those text transfers altogether where possible.  But I
ran into the obvious problems with the editor interface.  (Also, I became
concerned about the possibility of a race condition in the pristines table
-- client says "Yep, I've got that text already!", edit continues while
simultaneously in some other part of the tree that text is removed, edit
goes to reference the supposedly redundant checksum and it ain't there no mo'.)

I held off on committing my RA work because there were no consumers.  But
I've still considering making the change because a) there's no penalty for
doing so, and b) maybe if we add the requisite client-side magic in 1.8, 1.7
servers would already be advertising the sha1 checksum that code would need.

Thoughts?

I'll attach my patch which, if accepted in 1.7, should probably be expanded
to cover svnserve, too.

-- 
C. Michael Pilato <cm...@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand

Re: [PATCH] Server-transmitted "final SHA1 checksums" (Was: "large number of large binary files in subversion")

Posted by "C. Michael Pilato" <cm...@collab.net>.
On 05/24/2011 11:47 AM, Stefan Sperling wrote:
> On Tue, May 24, 2011 at 11:30:39AM -0400, C. Michael Pilato wrote:
>> I held off on committing my RA work because there were no consumers.  But
>> I've still considering making the change because a) there's no penalty for
>> doing so, and b) maybe if we add the requisite client-side magic in 1.8, 1.7
>> servers would already be advertising the sha1 checksum that code would need.
> 
> Sounds like an excellent plan to me, if there really is no penalty.

I call the FS function in a way that says, "give me the SHA1 if you have it
handy, but don't go calculate it if you don't."  So, a little bit of FS
query cost, some additional bytes on the wire, but that's about it.

-- 
C. Michael Pilato <cm...@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand


Re: [PATCH] Server-transmitted "final SHA1 checksums" (Was: "large number of large binary files in subversion")

Posted by Greg Stein <gs...@gmail.com>.
On May 24, 2011 11:47 AM, "Stefan Sperling" <st...@elego.de> wrote:
>
> On Tue, May 24, 2011 at 11:30:39AM -0400, C. Michael Pilato wrote:
> > I held off on committing my RA work because there were no consumers.
 But
> > I've still considering making the change because a) there's no penalty
for
> > doing so, and b) maybe if we add the requisite client-side magic in 1.8,
1.7
> > servers would already be advertising the sha1 checksum that code would
need.
>
> Sounds like an excellent plan to me, if there really is no penalty.

Agreed!

Re: [PATCH] Server-transmitted "final SHA1 checksums" (Was: "large number of large binary files in subversion")

Posted by Stefan Sperling <st...@elego.de>.
On Tue, May 24, 2011 at 11:30:39AM -0400, C. Michael Pilato wrote:
> I held off on committing my RA work because there were no consumers.  But
> I've still considering making the change because a) there's no penalty for
> doing so, and b) maybe if we add the requisite client-side magic in 1.8, 1.7
> servers would already be advertising the sha1 checksum that code would need.

Sounds like an excellent plan to me, if there really is no penalty.

Re: [PATCH] Server-transmitted "final SHA1 checksums" (Was: "large number of large binary files in subversion")

Posted by Julian Foad <ju...@wandisco.com>.
On Tue, 2011-05-24 at 18:21 +0200, Branko Čibej wrote:
> On 24.05.2011 17:53, Arwin Arni wrote:
> >> I was hoping to slip in
> >> support for avoiding those text transfers altogether where possible. 
> >> But I
> >> ran into the obvious problems with the editor interface.  (Also, I
> >> became
> >> concerned about the possibility of a race condition in the pristines
> >> table
> >> -- client says "Yep, I've got that text already!", edit continues while
> >> simultaneously in some other part of the tree that text is removed, edit
> >> goes to reference the supposedly redundant checksum and it ain't
> >> there no mo'.)
> >>
> >
> > Can't we increase the ref-count of the pristine node on getting the
> > <add-file...> element... this way, we need not worry about a parallel
> > <delete-file..> (IIUC delete-file will only reduce the ref-count, and
> > the actual removal of the pristine node is taken care of after the
> > entire editor drive.. atleast.. this is the way it is in my head)
> 
> <add-file> ... inc(refcount) ... commit ... ^C .... eep!
> 
> In other words, 'tain't that simple ... on the other hand, the worst
> that can happen is that an unused pristine never gets removed from disk.

The ref-count in the DB is an "internal" ref-count: that is, it only
counts the references that are present in the DB itself (in the NODES
table), and not logical references that the program might be holding in
its volatile memory.  This was a decision in order to keep the design of
that subcomponent simple.

- Julian



Re: [PATCH] Server-transmitted "final SHA1 checksums" (Was: "large number of large binary files in subversion")

Posted by "C. Michael Pilato" <cm...@collab.net>.
On 05/25/2011 10:42 AM, Bert Huijben wrote:
> To resolve this and similar problems we defined that we are not allowed
> to remove pristines with refcount zero until there are no more workqueue
> items, and nobody else has a working copy lock.
> 
> (During update the only reference to a pristine is in memory. In some
> other cases the only reference might be in a skel in the workqueue).
> 
> So no need to update the refcount.

Brilliant!

-- 
C. Michael Pilato <cm...@collab.net>
CollabNet   <>   www.collab.net   <>   Distributed Development On Demand


RE: [PATCH] Server-transmitted "final SHA1 checksums" (Was: "large number of large binary files in subversion")

Posted by Bert Huijben <be...@qqmail.nl>.

> -----Original Message-----
> From: Branko Čibej [mailto:brane@xbc.nu] On Behalf Of Branko Cibej
> Sent: dinsdag 24 mei 2011 18:22
> To: dev@subversion.apache.org
> Subject: Re: [PATCH] Server-transmitted "final SHA1 checksums" (Was: "large
> number of large binary files in subversion")
> 
> On 24.05.2011 17:53, Arwin Arni wrote:
> >> I was hoping to slip in
> >> support for avoiding those text transfers altogether where possible.
> >> But I
> >> ran into the obvious problems with the editor interface.  (Also, I
> >> became
> >> concerned about the possibility of a race condition in the pristines
> >> table
> >> -- client says "Yep, I've got that text already!", edit continues while
> >> simultaneously in some other part of the tree that text is removed, edit
> >> goes to reference the supposedly redundant checksum and it ain't
> >> there no mo'.)
> >>
> >
> > Can't we increase the ref-count of the pristine node on getting the
> > <add-file...> element... this way, we need not worry about a parallel
> > <delete-file..> (IIUC delete-file will only reduce the ref-count, and
> > the actual removal of the pristine node is taken care of after the
> > entire editor drive.. atleast.. this is the way it is in my head)
> 
> <add-file> ... inc(refcount) ... commit ... ^C .... eep!
> 
> In other words, 'tain't that simple ... on the other hand, the worst
> that can happen is that an unused pristine never gets removed from disk.

To resolve this and similar problems we defined that we are not allowed to remove pristines with refcount zero until there are no more workqueue items, and nobody else has a working copy lock.

(During update the only reference to a pristine is in memory. In some other cases the only reference might be in a skel in the workqueue).

So no need to update the refcount.

	Bert



Re: [PATCH] Server-transmitted "final SHA1 checksums" (Was: "large number of large binary files in subversion")

Posted by Branko Čibej <br...@e-reka.si>.
On 24.05.2011 17:53, Arwin Arni wrote:
>> I was hoping to slip in
>> support for avoiding those text transfers altogether where possible. 
>> But I
>> ran into the obvious problems with the editor interface.  (Also, I
>> became
>> concerned about the possibility of a race condition in the pristines
>> table
>> -- client says "Yep, I've got that text already!", edit continues while
>> simultaneously in some other part of the tree that text is removed, edit
>> goes to reference the supposedly redundant checksum and it ain't
>> there no mo'.)
>>
>
> Can't we increase the ref-count of the pristine node on getting the
> <add-file...> element... this way, we need not worry about a parallel
> <delete-file..> (IIUC delete-file will only reduce the ref-count, and
> the actual removal of the pristine node is taken care of after the
> entire editor drive.. atleast.. this is the way it is in my head)

<add-file> ... inc(refcount) ... commit ... ^C .... eep!

In other words, 'tain't that simple ... on the other hand, the worst
that can happen is that an unused pristine never gets removed from disk.

-- Brane


Re: [PATCH] Server-transmitted "final SHA1 checksums" (Was: "large number of large binary files in subversion")

Posted by Arwin Arni <ar...@collab.net>.
On Tuesday 24 May 2011 09:00 PM, C. Michael Pilato wrote:
> On 05/24/2011 04:23 AM, Stefan Sperling wrote:
>> On Tue, May 24, 2011 at 12:04:26PM +0530, Arwin Arni wrote:
>>> Why can't we send the recorded checksum from the server instead of
>>> sending the whole file and then calculating it on the client side?
>>>
>>> If the checksum matches one of the pristine files, then use that to
>>> populate the nodes table. If there is no match, only then do we
>>> spool to a temporary file and what not.
>>>
>>> This seems like a straightforward idea. Any pitfalls to this approach?
>> The pitfall is that you need to change the client<->server interface.
>>
>> The current interface at subversion/include/svn_delta.h only transmits
>> checksums before and after applying deltas. First it transmits the checksum
>> of the expected base text for the delta (apply_textdelta), and then,
>> after the delta has been applied, it sends the expected checksum of the
>> content resulting from application of the delta to the base (close_file).
>> This interface doesn't prevent data from being transmitted.
> Heheh... I'm sitting on a patch which transmits the "final sha1 checksum"
> *before* file contents would be transmitted over DAV.  Something I whipped
> up before hopping on the plane out of Berlin.

Nice :)

> I was hoping to slip in
> support for avoiding those text transfers altogether where possible.  But I
> ran into the obvious problems with the editor interface.  (Also, I became
> concerned about the possibility of a race condition in the pristines table
> -- client says "Yep, I've got that text already!", edit continues while
> simultaneously in some other part of the tree that text is removed, edit
> goes to reference the supposedly redundant checksum and it ain't there no mo'.)
>

Can't we increase the ref-count of the pristine node on getting the 
<add-file...> element... this way, we need not worry about a parallel 
<delete-file..> (IIUC delete-file will only reduce the ref-count, and 
the actual removal of the pristine node is taken care of after the 
entire editor drive.. atleast.. this is the way it is in my head)

> I held off on committing my RA work because there were no consumers.  But
> I've still considering making the change because a) there's no penalty for
> doing so, and b) maybe if we add the requisite client-side magic in 1.8, 1.7
> servers would already be advertising the sha1 checksum that code would need.
>
> Thoughts?
>
> I'll attach my patch which, if accepted in 1.7, should probably be expanded
> to cover svnserve, too.
>