You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2013/10/18 18:30:20 UTC

svn commit: r1533539 - in /subversion/branches/log-addressing/subversion: include/private/svn_io_private.h libsvn_subr/stream.c

Author: stefan2
Date: Fri Oct 18 16:30:20 2013
New Revision: 1533539

URL: http://svn.apache.org/r1533539
Log:
On the log-addressing branch:
Make LINE_CHUNK_SIZE part of our private I/O API.  Other parts such as
the FSFS f7 code may use this information to e.g. optimize data layout.

* subversion/include/private/svn_io_private.h
  (SVN__LINE_CHUNK_SIZE): move, rename & document constant taken from ...

* subversion/libsvn_subr/stream.c
  (LINE_CHUNK_SIZE): ... here
  (stream_readline_bytewise,
   stream_readline_chunky): update users

Modified:
    subversion/branches/log-addressing/subversion/include/private/svn_io_private.h
    subversion/branches/log-addressing/subversion/libsvn_subr/stream.c

Modified: subversion/branches/log-addressing/subversion/include/private/svn_io_private.h
URL: http://svn.apache.org/viewvc/subversion/branches/log-addressing/subversion/include/private/svn_io_private.h?rev=1533539&r1=1533538&r2=1533539&view=diff
==============================================================================
--- subversion/branches/log-addressing/subversion/include/private/svn_io_private.h (original)
+++ subversion/branches/log-addressing/subversion/include/private/svn_io_private.h Fri Oct 18 16:30:20 2013
@@ -44,6 +44,15 @@ extern "C" {
 #define SVN__APR_FINFO_MASK_OUT (0)
 #endif
 
+/* 90% of the lines we encounter will be less than this many chars.
+ *
+ * Line-based functions like svn_stream_readline should fetch data in
+ * blocks no longer than this.  Although using a larger prefetch size is
+ * not illegal and must not break any functionality, it may be
+ * significantly less efficient in certain situations.
+ */
+#define SVN__LINE_CHUNK_SIZE 80
+
 
 /** Set @a *executable TRUE if @a file_info is executable for the
  * user, FALSE otherwise.

Modified: subversion/branches/log-addressing/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/branches/log-addressing/subversion/libsvn_subr/stream.c?rev=1533539&r1=1533538&r2=1533539&view=diff
==============================================================================
--- subversion/branches/log-addressing/subversion/libsvn_subr/stream.c (original)
+++ subversion/branches/log-addressing/subversion/libsvn_subr/stream.c Fri Oct 18 16:30:20 2013
@@ -259,11 +259,6 @@ svn_stream_printf_from_utf8(svn_stream_t
   return svn_error_trace(svn_stream_puts(stream, translated));
 }
 
-/* Size that 90% of the lines we encounter will be not longer than.
-   used by stream_readline_bytewise() and stream_readline_chunky().
- */
-#define LINE_CHUNK_SIZE 80
-
 /* Guts of svn_stream_readline().
  * Returns the line read from STREAM in *STRINGBUF, and indicates
  * end-of-file in *EOF.  If DETECT_EOL is TRUE, the end-of-line indicator
@@ -286,7 +281,7 @@ stream_readline_bytewise(svn_stringbuf_t
      optimize for the 90% case.  90% of the time, we can avoid the
      stringbuf ever having to realloc() itself if we start it out at
      80 chars.  */
-  str = svn_stringbuf_create_ensure(LINE_CHUNK_SIZE, pool);
+  str = svn_stringbuf_create_ensure(SVN__LINE_CHUNK_SIZE, pool);
 
   /* Read into STR up to and including the next EOL sequence. */
   match = eol;
@@ -330,7 +325,7 @@ stream_readline_chunky(svn_stringbuf_t *
    * larger value because filling the buffer from the stream takes
    * time as well.
    */
-  char buffer[LINE_CHUNK_SIZE+1];
+  char buffer[SVN__LINE_CHUNK_SIZE+1];
 
   /* variables */
   svn_stream_mark_t *mark;
@@ -347,7 +342,7 @@ stream_readline_chunky(svn_stringbuf_t *
   SVN_ERR(svn_stream_mark(stream, &mark, pool));
 
   /* Read the first chunk. */
-  numbytes = LINE_CHUNK_SIZE;
+  numbytes = SVN__LINE_CHUNK_SIZE;
   SVN_ERR(svn_stream_read(stream, buffer, &numbytes));
   buffer[numbytes] = '\0';
 
@@ -359,7 +354,7 @@ stream_readline_chunky(svn_stringbuf_t *
       *stringbuf = svn_stringbuf_ncreate(buffer, eol_pos - buffer, pool);
       total_parsed = eol_pos - buffer + eol_len;
     }
-  else if (numbytes < LINE_CHUNK_SIZE)
+  else if (numbytes < SVN__LINE_CHUNK_SIZE)
     {
       /* We hit EOF but not EOL.
        */
@@ -371,7 +366,7 @@ stream_readline_chunky(svn_stringbuf_t *
     {
       /* A larger buffer for the string is needed. */
       svn_stringbuf_t *str;
-      str = svn_stringbuf_create_ensure(2*LINE_CHUNK_SIZE, pool);
+      str = svn_stringbuf_create_ensure(2*SVN__LINE_CHUNK_SIZE, pool);
       svn_stringbuf_appendbytes(str, buffer, numbytes);
       *stringbuf = str;
 
@@ -381,8 +376,8 @@ stream_readline_chunky(svn_stringbuf_t *
       {
         /* Append the next chunk to the string read so far.
          */
-        svn_stringbuf_ensure(str, str->len + LINE_CHUNK_SIZE);
-        numbytes = LINE_CHUNK_SIZE;
+        svn_stringbuf_ensure(str, str->len + SVN__LINE_CHUNK_SIZE);
+        numbytes = SVN__LINE_CHUNK_SIZE;
         SVN_ERR(svn_stream_read(stream, str->data + str->len, &numbytes));
         str->len += numbytes;
         str->data[str->len] = '\0';
@@ -393,7 +388,7 @@ stream_readline_chunky(svn_stringbuf_t *
          */
         eol_pos = strstr(str->data + str->len - numbytes - (eol_len-1), eol);
 
-        if ((numbytes < LINE_CHUNK_SIZE) && (eol_pos == NULL))
+        if ((numbytes < SVN__LINE_CHUNK_SIZE) && (eol_pos == NULL))
         {
           /* We hit EOF instead of EOL. */
           *eof = TRUE;