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 2011/04/23 15:44:53 UTC

svn commit: r1096147 - in /subversion/trunk/subversion: include/private/svn_cache.h libsvn_subr/cache.c

Author: stefan2
Date: Sat Apr 23 13:44:53 2011
New Revision: 1096147

URL: http://svn.apache.org/viewvc?rev=1096147&view=rev
Log:
Fix conversion and potential overflow warnings in cache stats:
caches may be outside the current process -> use 64 bits for sizes
and counts as well as doubles for internal calculations.

* subversion/include/private/svn_cache.h
  (svn_cache__info_t): extend all sizes to 64 bits
* subversion/libsvn_subr/cache.c:
  (svn_cache__format_info): adjust format strings, 
   use doubles for calculations

Modified:
    subversion/trunk/subversion/include/private/svn_cache.h
    subversion/trunk/subversion/libsvn_subr/cache.c

Modified: subversion/trunk/subversion/include/private/svn_cache.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_cache.h?rev=1096147&r1=1096146&r2=1096147&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_cache.h (original)
+++ subversion/trunk/subversion/include/private/svn_cache.h Sat Apr 23 13:44:53 2011
@@ -149,28 +149,28 @@ typedef struct svn_cache__info_t
   /** Size of the data currently stored in the cache.
    * May be 0 if that information is not available.
    */
-  apr_size_t used_size;
+  apr_uint64_t used_size;
 
   /** Amount of memory currently reserved for cached data.
    * Will be equal to @a used_size if no precise information is available.
    */
-  apr_size_t data_size;
+  apr_uint64_t data_size;
 
   /** Lower threshold of the total size of memory allocated to the cache and
    * its index as well as management structures. The actual memory allocated
    * by the cache may be larger.
    */
-  apr_size_t total_size;
+  apr_uint64_t total_size;
 
   /** Number of cache entries.
    * May be 0 if that information is not available.
    */
-  apr_size_t used_entries;
+  apr_uint64_t used_entries;
 
   /** Maximum numbers of cache entries.
    * May be 0 if that information is not available.
    */
-  apr_size_t total_entries;
+  apr_uint64_t total_entries;
 } svn_cache__info_t;
 
 /**

Modified: subversion/trunk/subversion/libsvn_subr/cache.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/cache.c?rev=1096147&r1=1096146&r2=1096147&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/cache.c (original)
+++ subversion/trunk/subversion/libsvn_subr/cache.c Sat Apr 23 13:44:53 2011
@@ -212,14 +212,14 @@ svn_cache__format_info(const svn_cache__
   enum { _1MB = 1024 * 1024 };
 
   apr_uint64_t misses = info->gets - info->hits;
-  float hit_rate = (100.0 * info->hits)
-                 / (info->gets ? info->gets : 1);
-  float write_rate = (100.0 * info->sets)
-                   / (misses ? misses : 1);
-  float data_usage_rate = (100.0 * info->used_size)
-                        / (info->data_size ? info->data_size : 1);
-  float data_entry_rate = (100.0 * info->used_entries)
-                        / (info->total_entries ? info->total_entries : 1);
+  double hit_rate = (100.0 * info->hits)
+                  / (info->gets ? info->gets : 1);
+  double write_rate = (100.0 * info->sets)
+                    / (misses ? misses : 1);
+  double data_usage_rate = (100.0 * info->used_size)
+                         / (info->data_size ? info->data_size : 1);
+  double data_entry_rate = (100.0 * info->used_entries)
+                         / (info->total_entries ? info->total_entries : 1);
 
   return svn_string_createf(pool,
 
@@ -229,11 +229,11 @@ svn_cache__format_info(const svn_cache__
                             "sets    : %" APR_UINT64_T_FMT
                             " (%5.2f%% of misses)\n"
                             "failures: %" APR_UINT64_T_FMT "\n"
-                            "used    : %" APR_SIZE_T_FMT " MB (%5.2f%%)"
-                            " of %" APR_SIZE_T_FMT " MB data cache"
-                            " / %" APR_SIZE_T_FMT " MB total cache memory\n"
-                            "          %" APR_SIZE_T_FMT " entries (%5.2f%%)"
-                            " of %" APR_SIZE_T_FMT " total\n",
+                            "used    : %" APR_UINT64_T_FMT " MB (%5.2f%%)"
+                            " of %" APR_UINT64_T_FMT " MB data cache"
+                            " / %" APR_UINT64_T_FMT " MB total cache memory\n"
+                            "          %" APR_UINT64_T_FMT " entries (%5.2f%%)"
+                            " of %" APR_UINT64_T_FMT " total\n",
 
                             info->id,