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/02/21 12:18:58 UTC

svn commit: r1448587 - in /subversion/trunk/subversion: include/private/svn_temp_serializer.h libsvn_fs_fs/dag.c libsvn_fs_fs/temp_serializer.c

Author: stefan2
Date: Thu Feb 21 11:18:58 2013
New Revision: 1448587

URL: http://svn.apache.org/r1448587
Log:
Introduce a constant that gives us the memory allocation overhead of
a serialization buffer and use that to specify "round" buffer sizes
(of 1kByte) instead of using seamingly magic sizes.

Once at it, fix a few typos in the doxygen strings.

* subversion/include/private/svn_temp_serializer.h
  (): include svn_string.h to make sure svn_stringbuf_t is defined
  (SVN_TEMP_SERIALIZER__OVERHEAD): define new constant
  (svn_temp_serializer__init,
   svn_temp_serializer__init_append,
   svn_temp_serializer__pop,
   svn_temp_serializer__revolve): fix typos in docstrings

* subversion/libsvn_fs_fs/dag.c
  (svn_fs_fs__dag_serialize): use new constant to calculate initial
   serialization buffer size 

* subversion/libsvn_fs_fs/temp_serializer.c
  (svn_fs_fs__serialize_node_revision): ditto

Suggested by: philip

Modified:
    subversion/trunk/subversion/include/private/svn_temp_serializer.h
    subversion/trunk/subversion/libsvn_fs_fs/dag.c
    subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c

Modified: subversion/trunk/subversion/include/private/svn_temp_serializer.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_temp_serializer.h?rev=1448587&r1=1448586&r2=1448587&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_temp_serializer.h (original)
+++ subversion/trunk/subversion/include/private/svn_temp_serializer.h Thu Feb 21 11:18:58 2013
@@ -31,8 +31,7 @@
 #ifndef SVN_TEMP_SERIALIZER_H
 #define SVN_TEMP_SERIALIZER_H
 
-#include <apr.h>
-#include "svn_types.h"
+#include "svn_string.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -42,6 +41,14 @@ extern "C" {
 struct svn_stringbuf_t;
 
 /**
+ * The amount of extra memory allocated by #svn_temp_serializer__init for
+ * the internal buffer in addition to its suggested_buffer_size parameter.
+ * To allocate a 512 buffer, including overhead, just specify a size of
+ * 512 - SVN_TEMP_SERIALIZER__OVERHEAD.
+ */
+#define SVN_TEMP_SERIALIZER__OVERHEAD (sizeof(svn_stringbuf_t) + 1)
+
+/**
  * Opaque structure controlling the serialization process and holding the
  * intermediate as well as final results.
  */
@@ -68,7 +75,7 @@ typedef struct svn_temp_serializer__cont
  * serialized. This scheme allows only for tree-like, i.e. non-circular
  * data structures.
  *
- * @return the serization context.
+ * @return the serialization context.
  */
 svn_temp_serializer__context_t *
 svn_temp_serializer__init(const void *source_struct,
@@ -94,7 +101,7 @@ svn_temp_serializer__init(const void *so
  * @a source_struct first, get the result from svn_temp_serializer__get()
  * and call svn_temp_serializer__init_append for the next part.
  *
- * @return the serization context.
+ * @return the serialization context.
  */
 svn_temp_serializer__context_t *
 svn_temp_serializer__init_append(void *buffer,
@@ -126,7 +133,7 @@ svn_temp_serializer__push(svn_temp_seria
 
 /**
  * End the serialization of the current sub-structure. The serialization
- * @a context will be focussed back on the parent structure. You may then
+ * @a context will be focused back on the parent structure. You may then
  * add further sub-structures starting from that level.
  *
  * It is not necessary to call this function just for symmetry at the end
@@ -179,7 +186,7 @@ svn_temp_serializer__get(svn_temp_serial
  * automatically) and resolve all pointers to sub-structures.
  *
  * To do the latter, call this function for each of these pointers, giving
- * the start address of the copyied buffer in @a buffer and a reference to
+ * the start address of the copied buffer in @a buffer and a reference to
  * the pointer to resolve in @a ptr.
  */
 void

Modified: subversion/trunk/subversion/libsvn_fs_fs/dag.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/dag.c?rev=1448587&r1=1448586&r2=1448587&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/dag.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/dag.c Thu Feb 21 11:18:58 2013
@@ -1095,7 +1095,7 @@ svn_fs_fs__dag_serialize(void **data,
   svn_temp_serializer__context_t *context =
       svn_temp_serializer__init(node,
                                 sizeof(*node),
-                                1007,
+                                1024 - SVN_TEMP_SERIALIZER__OVERHEAD,
                                 pool);
 
   /* for mutable nodes, we will _never_ cache the noderev */

Modified: subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c?rev=1448587&r1=1448586&r2=1448587&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c Thu Feb 21 11:18:58 2013
@@ -739,9 +739,12 @@ svn_fs_fs__serialize_node_revision(void 
   svn_stringbuf_t *serialized;
   node_revision_t *noderev = item;
 
-  /* create an (empty) serialization context with plenty of buffer space */
+  /* create an (empty) serialization context with plenty of (initial)
+   * buffer space. */
   svn_temp_serializer__context_t *context =
-      svn_temp_serializer__init(NULL, 0, 1007, pool);
+      svn_temp_serializer__init(NULL, 0,
+                                1024 - SVN_TEMP_SERIALIZER__OVERHEAD,
+                                pool);
 
   /* serialize the noderev */
   svn_fs_fs__noderev_serialize(context, &noderev);