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 2015/05/17 16:16:47 UTC
svn commit: r1679862 - in /subversion/branches/1.9-cache-improvements: ./
subversion/libsvn_subr/cache-membuffer.c
Author: stefan2
Date: Sun May 17 14:16:47 2015
New Revision: 1679862
URL: http://svn.apache.org/r1679862
Log:
On the 1.9-cache-improvements branch:
Merge r1679859 from the 1.10-cache-improvements branch and resolve
text conflicts. Update the combine_key function, see below.
* subversion/libsvn_subr/cache-membuffer.c
(combine_key): As in combine_long_key, use size_t with key lengths
and remove the obsolete key length limiter code.
Modified:
subversion/branches/1.9-cache-improvements/ (props changed)
subversion/branches/1.9-cache-improvements/subversion/libsvn_subr/cache-membuffer.c
Propchange: subversion/branches/1.9-cache-improvements/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun May 17 14:16:47 2015
@@ -1,4 +1,4 @@
-/subversion/branches/1.10-cache-improvements:1675666-1677522,1679679,1679681
+/subversion/branches/1.10-cache-improvements:1675666-1677522,1679679,1679681,1679859
/subversion/branches/1.5.x-r30215:870312
/subversion/branches/1.7.x-fs-verify:1146708,1161180
/subversion/branches/10Gb:1388102,1388163-1388190,1388195,1388202,1388205,1388211,1388276,1388362,1388375,1388394,1388636,1388639-1388640,1388643-1388644,1388654,1388720,1388789,1388795,1388801,1388805,1388807,1388810,1388816,1389044,1389276,1389289,1389662,1389867,1390017,1390209,1390216,1390407,1390409,1390414,1390419,1390955
Modified: subversion/branches/1.9-cache-improvements/subversion/libsvn_subr/cache-membuffer.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.9-cache-improvements/subversion/libsvn_subr/cache-membuffer.c?rev=1679862&r1=1679861&r2=1679862&view=diff
==============================================================================
--- subversion/branches/1.9-cache-improvements/subversion/libsvn_subr/cache-membuffer.c (original)
+++ subversion/branches/1.9-cache-improvements/subversion/libsvn_subr/cache-membuffer.c Sun May 17 14:16:47 2015
@@ -197,7 +197,7 @@ typedef struct entry_key_t
/* Length of the full key. This value is aligned to ITEM_ALIGNMENT to
* make sure the subsequent item content is properly aligned. */
- apr_uint32_t key_len;
+ apr_size_t key_len;
} entry_key_t;
/* A full key, i.e. the combination of the cache's key prefix with some
@@ -383,7 +383,7 @@ typedef struct entry_t
* above ensures that there will be no overflows.
* Only valid for used entries.
*/
- apr_uint32_t size;
+ apr_size_t size;
/* Number of (read) hits for this entry. Will be reset upon write.
* Only valid for used entries.
@@ -2029,7 +2029,7 @@ membuffer_cache_set_internal(svn_membuff
* negative value.
*/
cache->data_used += (apr_uint64_t)size - entry->size;
- entry->size = (apr_uint32_t) size;
+ entry->size = size;
entry->priority = priority;
#ifdef SVN_DEBUG_CACHE_MEMBUFFER
@@ -2062,7 +2062,7 @@ membuffer_cache_set_internal(svn_membuff
* the serialized item's (future) position within data buffer.
*/
entry = find_entry(cache, group_index, to_find, TRUE);
- entry->size = (apr_uint32_t) size;
+ entry->size = size;
entry->offset = level->current_data;
entry->priority = priority;
@@ -2488,7 +2488,7 @@ membuffer_cache_set_partial_internal(svn
/* Write the new entry.
*/
entry = find_entry(cache, group_index, to_find, TRUE);
- entry->size = (apr_uint32_t) (item_size + key_len);
+ entry->size = item_size + key_len;
entry->offset = cache->l1.current_data;
if (key_len)
@@ -2612,32 +2612,14 @@ combine_long_key(svn_membuffer_cache_t *
{
apr_uint32_t *digest_buffer;
char *key_copy;
- apr_uint32_t prefix_len = cache->prefix.entry_key.key_len;
- apr_uint32_t aligned_key_len;
+ apr_size_t prefix_len = cache->prefix.entry_key.key_len;
+ apr_size_t aligned_key_len;
/* handle variable-length keys */
if (key_len == APR_HASH_KEY_STRING)
key_len = strlen((const char *) key);
- /* Paranoia: Ridiculously long keys.
- *
- * We can't cache combined keys of 4GB and longer anyways. So, putting
- * a cap on them just above the maximum cachable value keeps them still
- * non-cachable but allows us to cast to u32.
- */
- assert(MAX_ITEM_SIZE < APR_UINT32_MAX);
- if (APR_UINT32_MAX - prefix_len <= key_len)
- {
- /* Non-cachable. Cap values. No data alignment needed. */
- key_len = APR_UINT32_MAX - prefix_len;
- aligned_key_len = key_len;
- }
- else
- {
- /* Cast is safe.
- * Key and item may be cachable, so item alignment is necessary. */
- aligned_key_len = ALIGN_VALUE((apr_uint32_t)key_len);
- }
+ aligned_key_len = ALIGN_VALUE(key_len);
/* Combine keys. */
svn_membuf__ensure(&cache->combined_key.full_key,
@@ -2670,7 +2652,7 @@ combine_key(svn_membuffer_cache_t *cache
/* short, fixed-size keys are the most common case */
if (key_len != APR_HASH_KEY_STRING && key_len <= 16)
{
- const apr_uint32_t prefix_len = cache->prefix.entry_key.key_len;
+ const apr_size_t prefix_len = cache->prefix.entry_key.key_len;
/* Copy of *key, padded with 0.
* We put it just behind the prefix already copied into the COMBINED_KEY.
@@ -2678,21 +2660,7 @@ combine_key(svn_membuffer_cache_t *cache
apr_uint64_t *data = (void *)((char *)cache->combined_key.full_key.data +
prefix_len);
assert(prefix_len <= cache->combined_key.full_key.size - 16);
-
- /* Paranoia: Ridiculously long keys.
- *
- * We can't cache combined keys of 4GB and longer anyways. So, putting
- * a cap on them just above the maximum cachable value keeps them still
- * non-cachable but allows us to cast to u32.
- */
- assert(MAX_ITEM_SIZE < APR_UINT32_MAX);
- if (APR_UINT32_MAX - 16 < prefix_len)
- {
- /* Non-cachable. Cap values. No data alignment needed.
- * Even the combined key will not be used. */
- cache->combined_key.entry_key.key_len = APR_UINT32_MAX;
- return;
- }
+ cache->combined_key.entry_key.key_len = prefix_len + 16;
data[0] = 0;
data[1] = 0;
@@ -3180,19 +3148,6 @@ svn_cache__create_membuffer_cache(svn_ca
prefix_orig_len = strlen(prefix) + 1;
prefix_len = ALIGN_VALUE(prefix_orig_len);
- assert(MAX_ITEM_SIZE < APR_UINT32_MAX);
- if (prefix_len > MAX_ITEM_SIZE)
- {
- /* We should never ever get here but the above check makes the cast
- * to u32 further down safe. We may also catch missing parameter
- * initializations here. */
- return svn_error_createf(SVN_ERR_INCORRECT_PARAMS, NULL,
- "Cache prefix length of %" APR_UINT64_T_FMT
- " exceeds maximum of %" APR_UINT64_T_FMT
- " bytes\n", (apr_uint64_t)prefix_len,
- (apr_uint64_t)MAX_ITEM_SIZE);
- }
-
svn_membuf__create(&cache->prefix.full_key, prefix_len, result_pool);
memcpy((char *)cache->prefix.full_key.data, prefix, prefix_orig_len);
memset((char *)cache->prefix.full_key.data + prefix_orig_len, 0,
@@ -3206,7 +3161,7 @@ svn_cache__create_membuffer_cache(svn_ca
scratch_pool));
memcpy(cache->prefix.entry_key.fingerprint, checksum->digest,
sizeof(cache->prefix.entry_key.fingerprint));
- cache->prefix.entry_key.key_len = (apr_uint32_t)prefix_len;
+ cache->prefix.entry_key.key_len = prefix_len;
/* Initialize the combined key. Pre-allocate some extra room in the full
* key such that we probably don't need to re-alloc. */