You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ph...@apache.org on 2013/04/23 15:04:43 UTC
svn commit: r1470936 - in /subversion/trunk/subversion: include/svn_io.h
libsvn_subr/stream.c libsvn_wc/adm_ops.c libsvn_wc/update_editor.c
Author: philip
Date: Tue Apr 23 13:04:42 2013
New Revision: 1470936
URL: http://svn.apache.org/r1470936
Log:
Significantly reduce the number of open files during a typical update
over ra_serf by using lazy-opening streams to delay opening until the
HTTP response is received. This changes the new-in-1.8 lazy-open API.
* subversion/include/svn_io.h
(svn_stream_lazyopen_create): Add open_on_close boolean parameter.
* subversion/libsvn_subr/stream.c
(struct lazyopen_baton_t): Add open_on_close boolean member.
(close_handler_lazyopen): Open if required.
(svn_stream_lazyopen_create): Add open_on_close boolean parameter.
* subversion/libsvn_wc/update_editor.c
(lazy_open_source, lazy_open_target, struct lazy_target_baton): New.
(apply_textdelta): Use lazy-open streams for source and target.
* subversion/libsvn_wc/adm_ops.c
(svn_wc__get_pristine_contents_by_checksum): Adjust call.
Modified:
subversion/trunk/subversion/include/svn_io.h
subversion/trunk/subversion/libsvn_subr/stream.c
subversion/trunk/subversion/libsvn_wc/adm_ops.c
subversion/trunk/subversion/libsvn_wc/update_editor.c
Modified: subversion/trunk/subversion/include/svn_io.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_io.h?rev=1470936&r1=1470935&r2=1470936&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_io.h (original)
+++ subversion/trunk/subversion/include/svn_io.h Tue Apr 23 13:04:42 2013
@@ -1387,14 +1387,15 @@ typedef svn_error_t *
* invoked upon the first read of @a *stream which are used to open the
* "real" source stream.
*
- * @note If the only "access" the returned stream gets is to close it,
- * @a open_func will not be called.
+ * @note If the only "access" the returned stream gets is to close it
+ * then @a open_func will only be called if @a open_on_close is TRUE.
*
* @since New in 1.8.
*/
svn_stream_t *
svn_stream_lazyopen_create(svn_stream_lazyopen_func_t open_func,
void *open_baton,
+ svn_boolean_t open_on_close,
apr_pool_t *result_pool);
/** @} */
Modified: subversion/trunk/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/stream.c?rev=1470936&r1=1470935&r2=1470936&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/stream.c (original)
+++ subversion/trunk/subversion/libsvn_subr/stream.c Tue Apr 23 13:04:42 2013
@@ -1676,6 +1676,9 @@ typedef struct lazyopen_baton_t {
svn_stream_t *real_stream;
apr_pool_t *pool;
+ /* Whether to open the wrapped stream on a close call. */
+ svn_boolean_t open_on_close;
+
} lazyopen_baton_t;
@@ -1747,7 +1750,9 @@ close_handler_lazyopen(void *baton)
{
lazyopen_baton_t *b = baton;
- if (b->real_stream != NULL)
+ if (b->open_on_close)
+ SVN_ERR(lazyopen_if_unopened(b));
+ if (b->real_stream)
SVN_ERR(svn_stream_close(b->real_stream));
return SVN_NO_ERROR;
@@ -1796,6 +1801,7 @@ is_buffered_lazyopen(void *baton)
svn_stream_t *
svn_stream_lazyopen_create(svn_stream_lazyopen_func_t open_func,
void *open_baton,
+ svn_boolean_t open_on_close,
apr_pool_t *result_pool)
{
lazyopen_baton_t *lob = apr_pcalloc(result_pool, sizeof(*lob));
@@ -1805,6 +1811,7 @@ svn_stream_lazyopen_create(svn_stream_la
lob->open_baton = open_baton;
lob->real_stream = NULL;
lob->pool = result_pool;
+ lob->open_on_close = open_on_close;
stream = svn_stream_create(lob, result_pool);
svn_stream_set_read(stream, read_handler_lazyopen);
Modified: subversion/trunk/subversion/libsvn_wc/adm_ops.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/adm_ops.c?rev=1470936&r1=1470935&r2=1470936&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/adm_ops.c (original)
+++ subversion/trunk/subversion/libsvn_wc/adm_ops.c Tue Apr 23 13:04:42 2013
@@ -1155,7 +1155,7 @@ svn_wc__get_pristine_contents_by_checksu
gpl_baton->checksum = checksum;
*contents = svn_stream_lazyopen_create(get_pristine_lazyopen_func,
- gpl_baton, result_pool);
+ gpl_baton, FALSE, result_pool);
}
return SVN_NO_ERROR;
Modified: subversion/trunk/subversion/libsvn_wc/update_editor.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/update_editor.c?rev=1470936&r1=1470935&r2=1470936&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
+++ subversion/trunk/subversion/libsvn_wc/update_editor.c Tue Apr 23 13:04:42 2013
@@ -3525,6 +3525,46 @@ open_file(const char *path,
return SVN_NO_ERROR;
}
+static svn_error_t *
+lazy_open_source(svn_stream_t **stream,
+ void *baton,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ struct file_baton *fb = baton;
+
+ SVN_ERR(svn_wc__db_pristine_read(stream, NULL, fb->edit_baton->db,
+ fb->local_abspath,
+ fb->original_checksum,
+ result_pool, scratch_pool));
+
+
+ return SVN_NO_ERROR;
+}
+
+struct lazy_target_baton {
+ struct file_baton *fb;
+ struct handler_baton *hb;
+ struct edit_baton *eb;
+};
+
+static svn_error_t *
+lazy_open_target(svn_stream_t **stream,
+ void *baton,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
+{
+ struct lazy_target_baton *tb = baton;
+
+ SVN_ERR(svn_wc__open_writable_base(stream, &tb->hb->new_text_base_tmp_abspath,
+ NULL, &tb->hb->new_text_base_sha1_checksum,
+ tb->fb->edit_baton->db,
+ tb->eb->wcroot_abspath,
+ result_pool, scratch_pool));
+
+ return SVN_NO_ERROR;
+}
+
/* An svn_delta_editor_t function. */
static svn_error_t *
apply_textdelta(void *file_baton,
@@ -3537,10 +3577,10 @@ apply_textdelta(void *file_baton,
apr_pool_t *handler_pool = svn_pool_create(fb->pool);
struct handler_baton *hb = apr_pcalloc(handler_pool, sizeof(*hb));
struct edit_baton *eb = fb->edit_baton;
- svn_error_t *err;
const svn_checksum_t *recorded_base_checksum;
svn_checksum_t *expected_base_checksum;
svn_stream_t *source;
+ struct lazy_target_baton *tb;
svn_stream_t *target;
if (fb->skip_this)
@@ -3607,10 +3647,8 @@ apply_textdelta(void *file_baton,
SVN_ERR_ASSERT(!fb->original_checksum
|| fb->original_checksum->kind == svn_checksum_sha1);
- SVN_ERR(svn_wc__db_pristine_read(&source, NULL, fb->edit_baton->db,
- fb->local_abspath,
- fb->original_checksum,
- handler_pool, handler_pool));
+ source = svn_stream_lazyopen_create(lazy_open_source, fb, FALSE,
+ handler_pool);
}
else
{
@@ -3636,16 +3674,11 @@ apply_textdelta(void *file_baton,
hb->source_checksum_stream = source;
}
- /* Open the text base for writing (this will get us a temporary file). */
- err = svn_wc__open_writable_base(&target, &hb->new_text_base_tmp_abspath,
- NULL, &hb->new_text_base_sha1_checksum,
- fb->edit_baton->db, eb->wcroot_abspath,
- handler_pool, pool);
- if (err)
- {
- svn_pool_destroy(handler_pool);
- return svn_error_trace(err);
- }
+ tb = apr_palloc(handler_pool, sizeof(struct lazy_target_baton));
+ tb->hb = hb;
+ tb->fb = fb;
+ tb->eb = eb;
+ target = svn_stream_lazyopen_create(lazy_open_target, tb, TRUE, handler_pool);
/* Prepare to apply the delta. */
svn_txdelta_apply(source, target,
Re: svn commit: r1470936 - in /subversion/trunk/subversion: include/svn_io.h
libsvn_subr/stream.c libsvn_wc/adm_ops.c libsvn_wc/update_editor.c
Posted by "C. Michael Pilato" <cm...@collab.net>.
On 04/23/2013 09:04 AM, philip@apache.org wrote:
> Author: philip
> Date: Tue Apr 23 13:04:42 2013
> New Revision: 1470936
>
> URL: http://svn.apache.org/r1470936
> Log:
> Significantly reduce the number of open files during a typical update
> over ra_serf by using lazy-opening streams to delay opening until the
> HTTP response is received. This changes the new-in-1.8 lazy-open API.
Good change. I like it.
--
C. Michael Pilato <cm...@collab.net>
CollabNet <> www.collab.net <> Enterprise Cloud Development
RE: svn commit: r1470936 - in /subversion/trunk/subversion: include/svn_io.h libsvn_subr/stream.c libsvn_wc/adm_ops.c libsvn_wc/update_editor.c
Posted by Bert Huijben <be...@qqmail.nl>.
> -----Original Message-----
> From: MARTIN PHILIP [mailto:codematters@ntlworld.com] On Behalf Of
> Philip Martin
> Sent: woensdag 24 april 2013 12:44
> To: Bert Huijben
> Cc: 'Branko Čibej'; dev@subversion.apache.org
> Subject: Re: svn commit: r1470936 - in /subversion/trunk/subversion:
> include/svn_io.h libsvn_subr/stream.c libsvn_wc/adm_ops.c
> libsvn_wc/update_editor.c
>
> "Bert Huijben" <be...@qqmail.nl> writes:
>
> > Well, explicitly not initializing variables is another way of adding
> > undefined behavior.
>
> You are suggesting that all heap variables be explicitly initialised to
> zero before being initialised to the correct values. We don't do that
> for stack variables, why is it so important to do it for heap variables?
How long do stack variables live?
How many functions do use them directly?
How much warnings does a common compiler give on using uninitialized
variables on the stack?
How long do head variables live?
How many functions do use them directly?
How much warnings does a common compiler give on using uninitialized
variables on the heap?
Especially because that last number is 0 and the number for stack variable
diagnosis is usually higher (and at least one of our buildbots continuously
uses compiler generated checks for unset stack variables), I think
initializing on the heap doesn't cost much but makes behavior more stable.
Really large blobs might be an exception, but in other cases initializing to
0 makes sense.
And I'd rather be a tiny bit more safe than sorry in these cases.
Bert
Re: svn commit: r1470936 - in /subversion/trunk/subversion: include/svn_io.h libsvn_subr/stream.c libsvn_wc/adm_ops.c libsvn_wc/update_editor.c
Posted by Philip Martin <ph...@wandisco.com>.
"Bert Huijben" <be...@qqmail.nl> writes:
> Well, explicitly not initializing variables is another way of adding
> undefined behavior.
You are suggesting that all heap variables be explicitly initialised to
zero before being initialised to the correct values. We don't do that
for stack variables, why is it so important to do it for heap variables?
--
Certified & Supported Apache Subversion Downloads:
http://www.wandisco.com/subversion/download
RE: svn commit: r1470936 - in /subversion/trunk/subversion: include/svn_io.h libsvn_subr/stream.c libsvn_wc/adm_ops.c libsvn_wc/update_editor.c
Posted by Bert Huijben <be...@qqmail.nl>.
> -----Original Message-----
> From: Branko Čibej [mailto:brane@wandisco.com]
> Sent: woensdag 24 april 2013 07:37
> To: dev@subversion.apache.org
> Subject: Re: svn commit: r1470936 - in /subversion/trunk/subversion:
> include/svn_io.h libsvn_subr/stream.c libsvn_wc/adm_ops.c
> libsvn_wc/update_editor.c
>
> On 23.04.2013 21:06, Bert Huijben wrote:
> >
> >> -----Original Message-----
> >> From: Ivan Zhakov [mailto:ivan@visualsvn.com]
> >> Sent: dinsdag 23 april 2013 20:47
> >> To: Philip Martin
> >> Cc: dev@subversion.apache.org
> >> Subject: Re: svn commit: r1470936 - in /subversion/trunk/subversion:
> >> include/svn_io.h libsvn_subr/stream.c libsvn_wc/adm_ops.c
> >> libsvn_wc/update_editor.c
> >>
> >> On Tue, Apr 23, 2013 at 9:09 PM, Philip Martin
> >> <ph...@wandisco.com> wrote:
> >>> Ivan Zhakov <iv...@visualsvn.com> writes:
> >>>
> >>>> On Tue, Apr 23, 2013 at 5:04 PM, <ph...@apache.org> wrote:
> >>>>> Author: philip
> >>>>> Date: Tue Apr 23 13:04:42 2013
> >>>>> New Revision: 1470936
> >>>>>
> >>>>> URL: http://svn.apache.org/r1470936
> >>>>> Log:
> >>>>> Significantly reduce the number of open files during a typical update
> >>>>> over ra_serf by using lazy-opening streams to delay opening until the
> >>>>> HTTP response is received. This changes the new-in-1.8 lazy-open
> API.
> >>>>>
> >>>> [...]
> >>>>
> >>>>> --- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
> >>>>> +++ subversion/trunk/subversion/libsvn_wc/update_editor.c Tue
> Apr
> >> 23 13:04:42 2013
> >>>>> @@ -3525,6 +3525,46 @@ open_file(const char *path,
> >>>>> return SVN_NO_ERROR;
> >>>>> }
> >>>>>
> >>>> [...]
> >>>>
> >>>>> + tb = apr_palloc(handler_pool, sizeof(struct lazy_target_baton));
> >>>> apr_pcalloc() ? Otherwise it looks like needless premature
> optimization.
> >>> I prefer alloc with explicit initialisation unless we know zero is a
> >>> correct initialisation. Adding initialisation to zero makes it harder
> >>> to use a tool like valgrind to identify missing initialisations.
> >>>
> >> Ok, but on the other apr_pcalloc() makes code execution stable and
> >> code will crash if not initialized properly instead of accessing
> >> garbage.
> > Maybe we should add our own define for these cases, to have the stable
> behavior of initializing to NULL in released code while still being able to
> disable this for debugging?
>
> That's a /great/ way of making release builds behave differently from
> debug builds.
Well, explicitly not initializing variables is another way of adding undefined behavior.
And I'm not suggesting that we should not enable this for debug builds.
But making things easier to run to valgrind shouldn't be the reason to deliberately deliver less secure code.
The tools should help deliver secure/correct code; not making us rely on undefined behavior in untested code paths.
Bert
RE: svn commit: r1470936 - in /subversion/trunk/subversion: include/svn_io.h libsvn_subr/stream.c libsvn_wc/adm_ops.c libsvn_wc/update_editor.c
Posted by Bert Huijben <be...@qqmail.nl>.
> -----Original Message-----
> From: Markus Schaber [mailto:m.schaber@codesys.com]
> Sent: woensdag 24 april 2013 10:24
> To: dev@subversion.apache.org
> Subject: AW: svn commit: r1470936 - in /subversion/trunk/subversion:
> include/svn_io.h libsvn_subr/stream.c libsvn_wc/adm_ops.c
> libsvn_wc/update_editor.c
>
> Hi,
>
> Von: Branko Čibej [mailto:brane@wandisco.com]
> [...]
> > >>> I prefer alloc with explicit initialisation unless we know zero is a
> > >>> correct initialisation. Adding initialisation to zero makes it
> > >>> harder to use a tool like valgrind to identify missing
> > initialisations.
> > >>>
> > >> Ok, but on the other apr_pcalloc() makes code execution stable and
> > >> code will crash if not initialized properly instead of accessing
> > >> garbage.
> > > Maybe we should add our own define for these cases, to have the stable
> > behavior of initializing to NULL in released code while still being able
> > to disable this for debugging?
> >
> > That's a /great/ way of making release builds behave differently from
> > debug builds.
>
> Maybe we can always initialize with zero, and find a way to mark it with
> VALGRIND_MAKE_MEM_UNDEFINED from memcheck.h during debug
> builds.
>
> That way, we have the same behaviour during release and debug builds,
> and valgrind still knows that the memory is not correctly initialized
> at that point.
And this is an even better suggestion: just initialize to 0, but learn valgrind to handle this...
Bert
AW: svn commit: r1470936 - in /subversion/trunk/subversion:
include/svn_io.h libsvn_subr/stream.c libsvn_wc/adm_ops.c
libsvn_wc/update_editor.c
Posted by Markus Schaber <m....@codesys.com>.
Hi,
Von: Branko Čibej [mailto:brane@wandisco.com]
[...]
> >>> I prefer alloc with explicit initialisation unless we know zero is a
> >>> correct initialisation. Adding initialisation to zero makes it
> >>> harder to use a tool like valgrind to identify missing
> initialisations.
> >>>
> >> Ok, but on the other apr_pcalloc() makes code execution stable and
> >> code will crash if not initialized properly instead of accessing
> >> garbage.
> > Maybe we should add our own define for these cases, to have the stable
> behavior of initializing to NULL in released code while still being able
> to disable this for debugging?
>
> That's a /great/ way of making release builds behave differently from
> debug builds.
Maybe we can always initialize with zero, and find a way to mark it with
VALGRIND_MAKE_MEM_UNDEFINED from memcheck.h during debug builds.
That way, we have the same behaviour during release and debug builds,
and valgrind still knows that the memory is not correctly initialized
at that point.
Best regards
Markus Schaber
CODESYS® a trademark of 3S-Smart Software Solutions GmbH
Inspiring Automation Solutions
3S-Smart Software Solutions GmbH
Dipl.-Inf. Markus Schaber | Product Development Core Technology
Memminger Str. 151 | 87439 Kempten | Germany
Tel. +49-831-54031-979 | Fax +49-831-54031-50
E-Mail: m.schaber@codesys.com | Web: http://www.codesys.com | CODESYS store: http://store.codesys.com
CODESYS forum: http://forum.codesys.com
Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner | Trade register: Kempten HRB 6186 | Tax ID No.: DE 167014915
Re: svn commit: r1470936 - in /subversion/trunk/subversion: include/svn_io.h
libsvn_subr/stream.c libsvn_wc/adm_ops.c libsvn_wc/update_editor.c
Posted by Branko Čibej <br...@wandisco.com>.
On 23.04.2013 21:06, Bert Huijben wrote:
>
>> -----Original Message-----
>> From: Ivan Zhakov [mailto:ivan@visualsvn.com]
>> Sent: dinsdag 23 april 2013 20:47
>> To: Philip Martin
>> Cc: dev@subversion.apache.org
>> Subject: Re: svn commit: r1470936 - in /subversion/trunk/subversion:
>> include/svn_io.h libsvn_subr/stream.c libsvn_wc/adm_ops.c
>> libsvn_wc/update_editor.c
>>
>> On Tue, Apr 23, 2013 at 9:09 PM, Philip Martin
>> <ph...@wandisco.com> wrote:
>>> Ivan Zhakov <iv...@visualsvn.com> writes:
>>>
>>>> On Tue, Apr 23, 2013 at 5:04 PM, <ph...@apache.org> wrote:
>>>>> Author: philip
>>>>> Date: Tue Apr 23 13:04:42 2013
>>>>> New Revision: 1470936
>>>>>
>>>>> URL: http://svn.apache.org/r1470936
>>>>> Log:
>>>>> Significantly reduce the number of open files during a typical update
>>>>> over ra_serf by using lazy-opening streams to delay opening until the
>>>>> HTTP response is received. This changes the new-in-1.8 lazy-open API.
>>>>>
>>>> [...]
>>>>
>>>>> --- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
>>>>> +++ subversion/trunk/subversion/libsvn_wc/update_editor.c Tue Apr
>> 23 13:04:42 2013
>>>>> @@ -3525,6 +3525,46 @@ open_file(const char *path,
>>>>> return SVN_NO_ERROR;
>>>>> }
>>>>>
>>>> [...]
>>>>
>>>>> + tb = apr_palloc(handler_pool, sizeof(struct lazy_target_baton));
>>>> apr_pcalloc() ? Otherwise it looks like needless premature optimization.
>>> I prefer alloc with explicit initialisation unless we know zero is a
>>> correct initialisation. Adding initialisation to zero makes it harder
>>> to use a tool like valgrind to identify missing initialisations.
>>>
>> Ok, but on the other apr_pcalloc() makes code execution stable and
>> code will crash if not initialized properly instead of accessing
>> garbage.
> Maybe we should add our own define for these cases, to have the stable behavior of initializing to NULL in released code while still being able to disable this for debugging?
That's a /great/ way of making release builds behave differently from
debug builds.
-- Brane
--
Branko Čibej
Director of Subversion | WANdisco | www.wandisco.com
RE: svn commit: r1470936 - in /subversion/trunk/subversion: include/svn_io.h libsvn_subr/stream.c libsvn_wc/adm_ops.c libsvn_wc/update_editor.c
Posted by Bert Huijben <be...@qqmail.nl>.
> -----Original Message-----
> From: Ivan Zhakov [mailto:ivan@visualsvn.com]
> Sent: dinsdag 23 april 2013 20:47
> To: Philip Martin
> Cc: dev@subversion.apache.org
> Subject: Re: svn commit: r1470936 - in /subversion/trunk/subversion:
> include/svn_io.h libsvn_subr/stream.c libsvn_wc/adm_ops.c
> libsvn_wc/update_editor.c
>
> On Tue, Apr 23, 2013 at 9:09 PM, Philip Martin
> <ph...@wandisco.com> wrote:
> > Ivan Zhakov <iv...@visualsvn.com> writes:
> >
> >> On Tue, Apr 23, 2013 at 5:04 PM, <ph...@apache.org> wrote:
> >>> Author: philip
> >>> Date: Tue Apr 23 13:04:42 2013
> >>> New Revision: 1470936
> >>>
> >>> URL: http://svn.apache.org/r1470936
> >>> Log:
> >>> Significantly reduce the number of open files during a typical update
> >>> over ra_serf by using lazy-opening streams to delay opening until the
> >>> HTTP response is received. This changes the new-in-1.8 lazy-open API.
> >>>
> >> [...]
> >>
> >>> --- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
> >>> +++ subversion/trunk/subversion/libsvn_wc/update_editor.c Tue Apr
> 23 13:04:42 2013
> >>> @@ -3525,6 +3525,46 @@ open_file(const char *path,
> >>> return SVN_NO_ERROR;
> >>> }
> >>>
> >> [...]
> >>
> >>> + tb = apr_palloc(handler_pool, sizeof(struct lazy_target_baton));
> >> apr_pcalloc() ? Otherwise it looks like needless premature optimization.
> >
> > I prefer alloc with explicit initialisation unless we know zero is a
> > correct initialisation. Adding initialisation to zero makes it harder
> > to use a tool like valgrind to identify missing initialisations.
> >
> Ok, but on the other apr_pcalloc() makes code execution stable and
> code will crash if not initialized properly instead of accessing
> garbage.
Maybe we should add our own define for these cases, to have the stable behavior of initializing to NULL in released code while still being able to disable this for debugging?
I prefer NULL references over using uninitialized pointers and variables.
Bert
Re: svn commit: r1470936 - in /subversion/trunk/subversion:
include/svn_io.h libsvn_subr/stream.c libsvn_wc/adm_ops.c libsvn_wc/update_editor.c
Posted by Ivan Zhakov <iv...@visualsvn.com>.
On Tue, Apr 23, 2013 at 9:09 PM, Philip Martin
<ph...@wandisco.com> wrote:
> Ivan Zhakov <iv...@visualsvn.com> writes:
>
>> On Tue, Apr 23, 2013 at 5:04 PM, <ph...@apache.org> wrote:
>>> Author: philip
>>> Date: Tue Apr 23 13:04:42 2013
>>> New Revision: 1470936
>>>
>>> URL: http://svn.apache.org/r1470936
>>> Log:
>>> Significantly reduce the number of open files during a typical update
>>> over ra_serf by using lazy-opening streams to delay opening until the
>>> HTTP response is received. This changes the new-in-1.8 lazy-open API.
>>>
>> [...]
>>
>>> --- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
>>> +++ subversion/trunk/subversion/libsvn_wc/update_editor.c Tue Apr 23 13:04:42 2013
>>> @@ -3525,6 +3525,46 @@ open_file(const char *path,
>>> return SVN_NO_ERROR;
>>> }
>>>
>> [...]
>>
>>> + tb = apr_palloc(handler_pool, sizeof(struct lazy_target_baton));
>> apr_pcalloc() ? Otherwise it looks like needless premature optimization.
>
> I prefer alloc with explicit initialisation unless we know zero is a
> correct initialisation. Adding initialisation to zero makes it harder
> to use a tool like valgrind to identify missing initialisations.
>
Ok, but on the other apr_pcalloc() makes code execution stable and
code will crash if not initialized properly instead of accessing
garbage.
--
Ivan Zhakov
CTO | VisualSVN | http://www.visualsvn.com
Re: svn commit: r1470936 - in /subversion/trunk/subversion: include/svn_io.h libsvn_subr/stream.c libsvn_wc/adm_ops.c libsvn_wc/update_editor.c
Posted by Philip Martin <ph...@wandisco.com>.
Ivan Zhakov <iv...@visualsvn.com> writes:
> On Tue, Apr 23, 2013 at 5:04 PM, <ph...@apache.org> wrote:
>> Author: philip
>> Date: Tue Apr 23 13:04:42 2013
>> New Revision: 1470936
>>
>> URL: http://svn.apache.org/r1470936
>> Log:
>> Significantly reduce the number of open files during a typical update
>> over ra_serf by using lazy-opening streams to delay opening until the
>> HTTP response is received. This changes the new-in-1.8 lazy-open API.
>>
> [...]
>
>> --- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
>> +++ subversion/trunk/subversion/libsvn_wc/update_editor.c Tue Apr 23 13:04:42 2013
>> @@ -3525,6 +3525,46 @@ open_file(const char *path,
>> return SVN_NO_ERROR;
>> }
>>
> [...]
>
>> + tb = apr_palloc(handler_pool, sizeof(struct lazy_target_baton));
> apr_pcalloc() ? Otherwise it looks like needless premature optimization.
I prefer alloc with explicit initialisation unless we know zero is a
correct initialisation. Adding initialisation to zero makes it harder
to use a tool like valgrind to identify missing initialisations.
--
Certified & Supported Apache Subversion Downloads:
http://www.wandisco.com/subversion/download
Re: svn commit: r1470936 - in /subversion/trunk/subversion:
include/svn_io.h libsvn_subr/stream.c libsvn_wc/adm_ops.c libsvn_wc/update_editor.c
Posted by Ivan Zhakov <iv...@visualsvn.com>.
On Tue, Apr 23, 2013 at 5:04 PM, <ph...@apache.org> wrote:
> Author: philip
> Date: Tue Apr 23 13:04:42 2013
> New Revision: 1470936
>
> URL: http://svn.apache.org/r1470936
> Log:
> Significantly reduce the number of open files during a typical update
> over ra_serf by using lazy-opening streams to delay opening until the
> HTTP response is received. This changes the new-in-1.8 lazy-open API.
>
[...]
> --- subversion/trunk/subversion/libsvn_wc/update_editor.c (original)
> +++ subversion/trunk/subversion/libsvn_wc/update_editor.c Tue Apr 23 13:04:42 2013
> @@ -3525,6 +3525,46 @@ open_file(const char *path,
> return SVN_NO_ERROR;
> }
>
[...]
> + tb = apr_palloc(handler_pool, sizeof(struct lazy_target_baton));
apr_pcalloc() ? Otherwise it looks like needless premature optimization.
--
Ivan Zhakov
CTO | VisualSVN | http://www.visualsvn.com