Author: hwright Date: Mon Aug 8 20:36:47 2011 New Revision: 1155082 URL: http://svn.apache.org/viewvc?rev=1155082&view=rev Log: On the fs-py branch: With appologies to Stefan Fuhrmann, rip out the caching ability inside of libsvn_fs_py. It is an implemenation detail that could be added to the Python implementation in whatever way make sense at a later date.
* subversion/libsvn_fs_py/: Remove caching implementation, initialization and use throughout. Removed: subversion/branches/fs-py/subversion/libsvn_fs_py/caching.c Modified: subversion/branches/fs-py/subversion/libsvn_fs_py/fs.c subversion/branches/fs-py/subversion/libsvn_fs_py/fs.h subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.h subversion/branches/fs-py/subversion/libsvn_fs_py/tree.c Modified: subversion/branches/fs-py/subversion/libsvn_fs_py/fs.c URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_fs_py/fs.c?rev=1155082&r1=1155081&r2=1155082&view=diff ============================================================================== --- subversion/branches/fs-py/subversion/libsvn_fs_py/fs.c (original) +++ subversion/branches/fs-py/subversion/libsvn_fs_py/fs.c Mon Aug 8 20:36:47 2011 @@ -196,7 +196,6 @@ fs_create(svn_fs_t *fs, const char *path SVN_ERR(svn_fs_py__create(fs, path, pool)); - SVN_ERR(svn_fs_py__initialize_caches(fs, pool)); return fs_serialized_init(fs, common_pool, pool); } @@ -216,7 +215,6 @@ fs_open(svn_fs_t *fs, const char *path, SVN_ERR(svn_fs_py__open(fs, path, pool)); - SVN_ERR(svn_fs_py__initialize_caches(fs, pool)); return fs_serialized_init(fs, common_pool, pool); } @@ -257,7 +255,6 @@ fs_upgrade(svn_fs_t *fs, const char *pat SVN_ERR(svn_fs__check_fs(fs, FALSE)); SVN_ERR(initialize_fs_struct(fs)); SVN_ERR(svn_fs_py__open(fs, path, pool)); - SVN_ERR(svn_fs_py__initialize_caches(fs, pool)); SVN_ERR(fs_serialized_init(fs, common_pool, pool)); return svn_fs_py__upgrade(fs, pool); } @@ -272,7 +269,6 @@ fs_verify(svn_fs_t *fs, const char *path SVN_ERR(svn_fs__check_fs(fs, FALSE)); SVN_ERR(initialize_fs_struct(fs)); SVN_ERR(svn_fs_py__open(fs, path, pool)); - SVN_ERR(svn_fs_py__initialize_caches(fs, pool)); SVN_ERR(fs_serialized_init(fs, common_pool, pool)); return svn_fs_py__verify(fs, cancel_func, cancel_baton, pool); } @@ -289,7 +285,6 @@ fs_pack(svn_fs_t *fs, SVN_ERR(svn_fs__check_fs(fs, FALSE)); SVN_ERR(initialize_fs_struct(fs)); SVN_ERR(svn_fs_py__open(fs, path, pool)); - SVN_ERR(svn_fs_py__initialize_caches(fs, pool)); SVN_ERR(fs_serialized_init(fs, pool, pool)); return svn_fs_py__pack(fs, notify_func, notify_baton, cancel_func, cancel_baton, pool); Modified: subversion/branches/fs-py/subversion/libsvn_fs_py/fs.h URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_fs_py/fs.h?rev=1155082&r1=1155081&r2=1155082&view=diff ============================================================================== --- subversion/branches/fs-py/subversion/libsvn_fs_py/fs.h (original) +++ subversion/branches/fs-py/subversion/libsvn_fs_py/fs.h Mon Aug 8 20:36:47 2011 @@ -221,44 +221,9 @@ typedef struct fs_fs_data_t /* The fsfs.conf file, parsed. Allocated in FS->pool. */ svn_config_t *config; - /* Caches of immutable data. (Note that if these are created with - svn_cache__create_memcache, the data can be shared between - multiple svn_fs_t's for the same filesystem.) */ - - /* A cache of revision root IDs, mapping from (svn_revnum_t *) to - (svn_fs_id_t *). (Not threadsafe.) */ - svn_cache__t *rev_root_id_cache; - - /* DAG node cache for immutable nodes */ - svn_cache__t *rev_node_cache; - - /* A cache of the contents of immutable directories; maps from - unparsed FS ID to ###x. */ - svn_cache__t *dir_cache; - - /* Fulltext cache; currently only used with memcached. Maps from - rep key to svn_string_t. */ - svn_cache__t *fulltext_cache; - - /* Pack manifest cache; a cache mapping (svn_revnum_t) shard number to - a manifest; and a manifest is a mapping from (svn_revnum_t) revision - number offset within a shard to (apr_off_t) byte-offset in the - respective pack file. */ - svn_cache__t *packed_offset_cache; - - /* Cache for txdelta_window_t objects; the key is (revFilePath, offset) */ - svn_cache__t *txdelta_window_cache; - - /* Cache for node_revision_t objects; the key is (revision, id offset) */ - svn_cache__t *node_revision_cache; - /* If set, there are or have been more than one concurrent transaction */ svn_boolean_t concurrent_transactions; - /* Tempoary cache for changed directories yet to be committed; maps from - unparsed FS ID to ###x. NULL outside transactions. */ - svn_cache__t *txn_dir_cache; - /* Data shared between all svn_fs_t objects for a given filesystem. */ fs_fs_shared_data_t *shared; Modified: subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c?rev=1155082&r1=1155081&r2=1155082&view=diff ============================================================================== --- subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c (original) +++ subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.c Mon Aug 8 20:36:47 2011 @@ -869,7 +869,6 @@ purge_shared_txn_body(svn_fs_t *fs, cons const char *txn_id = baton; free_shared_txn(fs, txn_id); - svn_fs_py__reset_txn_caches(fs); return SVN_NO_ERROR; } @@ -1881,7 +1880,6 @@ get_packed_offset(apr_off_t *rev_offset, { fs_fs_data_t *ffd = fs->fsap_data; svn_stream_t *manifest_stream; - svn_boolean_t is_cached; svn_revnum_t shard; apr_int64_t shard_pos; apr_array_header_t *manifest; @@ -1892,16 +1890,6 @@ get_packed_offset(apr_off_t *rev_offset, /* position of the shard within the manifest */ shard_pos = rev % ffd->max_files_per_dir; - /* fetch exactly that element into *rev_offset, if the manifest is found - in the cache */ - SVN_ERR(svn_cache__get_partial((void **) rev_offset, &is_cached, - ffd->packed_offset_cache, &shard, - svn_fs_py__get_sharded_offset, &shard_pos, - pool)); - - if (is_cached) - return SVN_NO_ERROR; - /* Open the manifest file. */ SVN_ERR(svn_stream_open_readonly(&manifest_stream, path_rev_packed(fs, rev, "manifest", pool), @@ -1937,7 +1925,7 @@ get_packed_offset(apr_off_t *rev_offset, /* Close up shop and cache the array. */ SVN_ERR(svn_stream_close(manifest_stream)); - return svn_cache__set(ffd->packed_offset_cache, &shard, manifest, pool); + return SVN_NO_ERROR; } /* Open the revision file for revision REV in filesystem FS and store @@ -2149,64 +2137,6 @@ err_dangling_id(svn_fs_t *fs, const svn_ id_str->data, fs->path); } -/* Return a string that uniquely identifies the noderev with the - * given ID, for use as a cache key. - */ -static const char * -get_noderev_cache_key(const svn_fs_id_t *id, apr_pool_t *pool) -{ - const svn_string_t *id_unparsed = svn_fs_py__id_unparse(id, pool); - return id_unparsed->data; -} - -/* Look up the NODEREV_P for ID in FS' node revsion cache. If noderev - * caching has been enabled and the data can be found, IS_CACHED will - * be set to TRUE. The noderev will be allocated from POOL. - * - * Non-permanent ids (e.g. ids within a TXN) will not be cached. - */ -static svn_error_t * -get_cached_node_revision_body(node_revision_t **noderev_p, - svn_fs_t *fs, - const svn_fs_id_t *id, - svn_boolean_t *is_cached, - apr_pool_t *pool) -{ - fs_fs_data_t *ffd = fs->fsap_data; - if (! ffd->node_revision_cache || svn_fs_py__id_txn_id(id)) - *is_cached = FALSE; - else - SVN_ERR(svn_cache__get((void **) noderev_p, - is_cached, - ffd->node_revision_cache, - get_noderev_cache_key(id, pool), - pool)); - - return SVN_NO_ERROR; -} - -/* If noderev caching has been enabled, store the NODEREV_P for the given ID - * in FS' node revsion cache. SCRATCH_POOL is used for temporary allcations. - * - * Non-permanent ids (e.g. ids within a TXN) will not be cached. - */ -static svn_error_t * -set_cached_node_revision_body(node_revision_t *noderev_p, - svn_fs_t *fs, - const svn_fs_id_t *id, - apr_pool_t *scratch_pool) -{ - fs_fs_data_t *ffd = fs->fsap_data; - - if (ffd->node_revision_cache && !svn_fs_py__id_txn_id(id)) - return svn_cache__set(ffd->node_revision_cache, - get_noderev_cache_key(id, scratch_pool), - noderev_p, - scratch_pool); - - return SVN_NO_ERROR; -} - /* Get the node-revision for the node ID in FS. Set *NODEREV_P to the new node-revision structure, allocated in POOL. See svn_fs_py__get_node_revision, which wraps this and adds another @@ -2219,12 +2149,6 @@ get_node_revision_body(node_revision_t * { apr_file_t *revision_file; svn_error_t *err; - svn_boolean_t is_cached = FALSE; - - /* First, try a cache lookup. If that succeeds, we are done here. */ - SVN_ERR(get_cached_node_revision_body(noderev_p, fs, id, &is_cached, pool)); - if (is_cached) - return SVN_NO_ERROR; if (svn_fs_py__id_txn_id(id)) { @@ -2257,8 +2181,7 @@ get_node_revision_body(node_revision_t * pool), pool)); - /* The noderev is not in cache, yet. Add it, if caching has been enabled. */ - return set_cached_node_revision_body(*noderev_p, fs, id, pool); + return SVN_NO_ERROR; } svn_error_t * @@ -2907,19 +2830,12 @@ svn_fs_py__rev_get_root(svn_fs_id_t **ro svn_revnum_t rev, apr_pool_t *pool) { - fs_fs_data_t *ffd = fs->fsap_data; apr_file_t *revision_file; apr_off_t root_offset; svn_fs_id_t *root_id = NULL; - svn_boolean_t is_cached; SVN_ERR(ensure_revision_exists(fs, rev, pool)); - SVN_ERR(svn_cache__get((void **) root_id_p, &is_cached, - ffd->rev_root_id_cache, &rev, pool)); - if (is_cached) - return SVN_NO_ERROR; - SVN_ERR(open_pack_or_rev_file(&revision_file, fs, rev, pool)); SVN_ERR(get_root_changes_offset(&root_offset, NULL, revision_file, fs, rev, pool)); @@ -2929,8 +2845,6 @@ svn_fs_py__rev_get_root(svn_fs_id_t **ro SVN_ERR(svn_io_file_close(revision_file, pool)); - SVN_ERR(svn_cache__set(ffd->rev_root_id_cache, &rev, root_id, pool)); - *root_id_p = root_id; return SVN_NO_ERROR; @@ -3060,7 +2974,6 @@ struct rep_state { apr_file_t *file; /* The txdelta window cache to use or NULL. */ - svn_cache__t *window_cache; apr_off_t start; /* The starting offset for the raw svndiff/plaintext data minus header. */ apr_off_t off; /* The current offset into the file. */ @@ -3077,13 +2990,11 @@ create_rep_state_body(struct rep_state * svn_fs_t *fs, apr_pool_t *pool) { - fs_fs_data_t *ffd = fs->fsap_data; struct rep_state *rs = apr_pcalloc(pool, sizeof(*rs)); struct rep_args *ra; unsigned char buf[4]; SVN_ERR(open_and_seek_representation(&rs->file, fs, rep, pool)); - rs->window_cache = ffd->txdelta_window_cache; SVN_ERR(read_rep_line(&ra, rs->file, pool)); SVN_ERR(get_file_offset(&rs->start, rs->file, pool)); @@ -3325,78 +3236,6 @@ get_window_key(struct rep_state *rs, apr return svn_fs_py__combine_number_and_string(offset, name, pool); } -/* Read the WINDOW_P for the rep state RS from the current FSFS session's - * cache. This will be a no-op and IS_CACHED will be set to FALSE if no - * cache has been given. If a cache is available IS_CACHED will inform - * the caller about the success of the lookup. Allocations (of the window - * in particualar) will be made from POOL. - * - * If the information could be found, put RS and the position within the - * rev file into the same state as if the data had just been read from it. - */ -static svn_error_t * -get_cached_window(svn_txdelta_window_t **window_p, - struct rep_state *rs, - svn_boolean_t *is_cached, - apr_pool_t *pool) -{ - if (! rs->window_cache) - { - /* txdelta window has not been enabled */ - *is_cached = FALSE; - } - else - { - /* ask the cache for the desired txdelta window */ - svn_fs_py__txdelta_cached_window_t *cached_window; - SVN_ERR(svn_cache__get((void **) &cached_window, - is_cached, - rs->window_cache, - get_window_key(rs, rs->off, pool), - pool)); - - if (*is_cached) - { - /* found it. Pass it back to the caller. */ - *window_p = cached_window->window; - - /* manipulate the RS as if we just read the data */ - rs->chunk_index++; - rs->off = cached_window->end_offset; - - /* manipulate the rev file as if we just read from it */ - SVN_ERR(svn_io_file_seek(rs->file, APR_SET, &rs->off, pool)); - } - } - - return SVN_NO_ERROR; -} - -/* Store the WINDOW read at OFFSET for the rep state RS in the current - * FSFS session's cache. This will be a no-op if no cache has been given. - * Temporary allocations will be made from SCRATCH_POOL. */ -static svn_error_t * -set_cached_window(svn_txdelta_window_t *window, - struct rep_state *rs, - apr_off_t offset, - apr_pool_t *scratch_pool) -{ - if (rs->window_cache) - { - /* store the window and the first offset _past_ it */ - svn_fs_py__txdelta_cached_window_t cached_window = { window, rs->off }; - - /* but key it with the start offset because that is the known state - * when we will look it up */ - return svn_cache__set(rs->window_cache, - get_window_key(rs, offset, scratch_pool), - &cached_window, - scratch_pool); - } - - return SVN_NO_ERROR; -} - /* Skip forwards to THIS_CHUNK in REP_STATE and then read the next delta window into *NWIN. */ static svn_error_t * @@ -3404,7 +3243,6 @@ read_window(svn_txdelta_window_t **nwin, apr_pool_t *pool) { svn_stream_t *stream; - svn_boolean_t is_cached; apr_off_t old_offset; SVN_ERR_ASSERT(rs->chunk_index <= this_chunk); @@ -3422,11 +3260,6 @@ read_window(svn_txdelta_window_t **nwin, "representation")); } - /* Read the next window. But first, try to find it in the cache. */ - SVN_ERR(get_cached_window(nwin, rs, &is_cached, pool)); - if (is_cached) - return SVN_NO_ERROR; - /* Actually read the next window. */ old_offset = rs->off; stream = svn_stream_from_aprfile2(rs->file, TRUE, pool); @@ -3439,9 +3272,7 @@ read_window(svn_txdelta_window_t **nwin, _("Reading one svndiff window read beyond " "the end of the representation")); - /* the window has not been cached before, thus cache it now - * (if caching is used for them at all) */ - return set_cached_window(*nwin, rs, old_offset, pool); + return SVN_NO_ERROR; } /* Get one delta window that is a result of combining all but the last deltas @@ -3486,16 +3317,6 @@ get_combined_window(svn_txdelta_window_t return SVN_NO_ERROR; } -/* Returns whether or not the expanded fulltext of the file is cachable - * based on its size SIZE. The decision depends on the cache used by RB. - */ -static svn_boolean_t -fulltext_size_is_cachable(fs_fs_data_t *ffd, svn_filesize_t size) -{ - return (size < APR_SIZE_MAX) - && svn_cache__is_cachable(ffd->fulltext_cache, (apr_size_t)size); -} - /* Close method used on streams returned by read_representation(). */ static svn_error_t * @@ -3695,12 +3516,7 @@ rep_read_contents(void *baton, } if (rb->off == rb->len && rb->current_fulltext) - { - fs_fs_data_t *ffd = rb->fs->fsap_data; - SVN_ERR(svn_cache__set(ffd->fulltext_cache, rb->fulltext_cache_key, - rb->current_fulltext, rb->pool)); - rb->current_fulltext = NULL; - } + rb->current_fulltext = NULL; return SVN_NO_ERROR; } @@ -3727,27 +3543,9 @@ read_representation(svn_stream_t **conte } else { - fs_fs_data_t *ffd = fs->fsap_data; const char *fulltext_key = NULL; - svn_filesize_t len = rep->expanded_size ? rep->expanded_size : rep->size; struct rep_read_baton *rb; - if (ffd->fulltext_cache && SVN_IS_VALID_REVNUM(rep->revision) - && fulltext_size_is_cachable(ffd, len)) - { - svn_string_t *fulltext; - svn_boolean_t is_cached; - fulltext_key = apr_psprintf(pool, "%ld/%" APR_OFF_T_FMT, - rep->revision, rep->offset); - SVN_ERR(svn_cache__get((void **) &fulltext, &is_cached, - ffd->fulltext_cache, fulltext_key, pool)); - if (is_cached) - { - *contents_p = svn_stream_from_string(fulltext, pool); - return SVN_NO_ERROR; - } - } - SVN_ERR(rep_read_get_baton(&rb, fs, rep, fulltext_key, pool)); *contents_p = svn_stream_create(rb, pool); @@ -3985,18 +3783,6 @@ parse_dir_entries(apr_hash_t **entries_p return SVN_NO_ERROR; } -/* Return the cache object in FS responsible to storing the directory - * the NODEREV. If none exists, return NULL. */ -static svn_cache__t * -locate_dir_cache(svn_fs_t *fs, - node_revision_t *noderev) -{ - fs_fs_data_t *ffd = fs->fsap_data; - return svn_fs_py__id_txn_id(noderev->id) - ? ffd->txn_dir_cache - : ffd->dir_cache; -} - svn_error_t * svn_fs_py__rep_contents_dir(apr_hash_t **entries_p, svn_fs_t *fs, @@ -4006,29 +3792,12 @@ svn_fs_py__rep_contents_dir(apr_hash_t * const char *unparsed_id = NULL; apr_hash_t *unparsed_entries, *parsed_entries; - /* find the cache we may use */ - svn_cache__t *cache = locate_dir_cache(fs, noderev); - if (cache) - { - svn_boolean_t found; - - unparsed_id = svn_fs_py__id_unparse(noderev->id, pool)->data; - SVN_ERR(svn_cache__get((void **) entries_p, &found, cache, - unparsed_id, pool)); - if (found) - return SVN_NO_ERROR; - } - /* Read in the directory hash. */ unparsed_entries = apr_hash_make(pool); SVN_ERR(get_dir_contents(unparsed_entries, fs, noderev, pool)); SVN_ERR(parse_dir_entries(&parsed_entries, unparsed_entries, unparsed_id, pool)); - /* Update the cache, if we are to use one. */ - if (cache) - SVN_ERR(svn_cache__set(cache, unparsed_id, parsed_entries, pool)); - *entries_p = parsed_entries; return SVN_NO_ERROR; } @@ -4042,23 +3811,6 @@ svn_fs_py__rep_contents_dir_entry(svn_fs { svn_boolean_t found = FALSE; - /* find the cache we may use */ - svn_cache__t *cache = locate_dir_cache(fs, noderev); - if (cache) - { - const char *unparsed_id = - svn_fs_py__id_unparse(noderev->id, pool)->data; - - /* Cache lookup. */ - SVN_ERR(svn_cache__get_partial((void **)dirent, - &found, - cache, - unparsed_id, - svn_fs_py__extract_dir_entry, - (void*)name, - pool)); - } - /* fetch data from disk if we did not find it in the cache */ if (! found) { @@ -5206,7 +4958,6 @@ svn_fs_py__set_entry(svn_fs_t *fs, const char *filename = path_txn_node_children(fs, parent_noderev->id, pool); apr_file_t *file; svn_stream_t *out; - fs_fs_data_t *ffd = fs->fsap_data; if (!rep || !rep->txn_id) { @@ -5248,30 +4999,6 @@ svn_fs_py__set_entry(svn_fs_t *fs, out = svn_stream_from_aprfile2(file, TRUE, pool); } - /* if we have a directory cache for this transaction, update it */ - if (ffd->txn_dir_cache) - { - apr_pool_t *subpool = svn_pool_create(pool); - - /* build parameters: (name, new entry) pair */ - const char *key = - svn_fs_py__id_unparse(parent_noderev->id, subpool)->data; - replace_baton_t baton = {name, NULL}; - - if (id) - { - baton.new_entry = apr_pcalloc(subpool, sizeof(*baton.new_entry)); - baton.new_entry->name = name; - baton.new_entry->kind = kind; - baton.new_entry->id = id; - } - - /* actually update the cached directory (if cached) */ - SVN_ERR(svn_cache__set_partial(ffd->txn_dir_cache, key, svn_fs_py__replace_dir_entry, &baton, subpool)); - - svn_pool_destroy(subpool); - } - /* Append an incremental hash entry for the entry change. */ if (id) { @@ -7369,16 +7096,8 @@ svn_fs_py__delete_node_revision(svn_fs_t if (noderev->data_rep && noderev->data_rep->txn_id && noderev->kind == svn_node_dir) { - fs_fs_data_t *ffd = fs->fsap_data; SVN_ERR(svn_io_remove_file2(path_txn_node_children(fs, id, pool), FALSE, pool)); - - /* remove the corresponding entry from the cache, if such exists */ - if (ffd->txn_dir_cache) - { - const char *key = svn_fs_py__id_unparse(id, pool)->data; - SVN_ERR(svn_cache__set(ffd->txn_dir_cache, key, NULL, pool)); - } } return svn_io_remove_file2(path_txn_node_rev(fs, id, pool), FALSE, pool); Modified: subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.h URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.h?rev=1155082&r1=1155081&r2=1155082&view=diff ============================================================================== --- subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.h (original) +++ subversion/branches/fs-py/subversion/libsvn_fs_py/fs_fs.h Mon Aug 8 20:36:47 2011 @@ -502,31 +502,6 @@ svn_fs_py__get_node_origin(const svn_fs_ const char *node_id, apr_pool_t *pool); - -/* Initialize all session-local caches in FS according to the global - cache settings. Use POOL for allocations. - - Please note that it is permissible for this function to set some - or all of these caches to NULL, regardless of any setting. */ -svn_error_t * -svn_fs_py__initialize_caches(svn_fs_t *fs, apr_pool_t *pool); - -/* Initialize all transaction-local caches in FS according to the global - cache settings and make TXN_ID part of their key space. Use POOL for - allocations. - - Please note that it is permissible for this function to set some or all - of these caches to NULL, regardless of any setting. */ -svn_error_t * -svn_fs_py__initialize_txn_caches(svn_fs_t *fs, - const char *txn_id, - apr_pool_t *pool); - -/* Resets the svn_cache__t structures local to the current transaction in FS. - Calling it more than once per txn or from outside any txn is allowed. */ -void -svn_fs_py__reset_txn_caches(svn_fs_t *fs); - /* Possibly pack the repository at PATH. This just take full shards, and combines all the revision files into a single one, with a manifest header. Use optional CANCEL_FUNC/CANCEL_BATON for cancellation support. Modified: subversion/branches/fs-py/subversion/libsvn_fs_py/tree.c URL: http://svn.apache.org/viewvc/subversion/branches/fs-py/subversion/libsvn_fs_py/tree.c?rev=1155082&r1=1155081&r2=1155082&view=diff ============================================================================== --- subversion/branches/fs-py/subversion/libsvn_fs_py/tree.c (original) +++ subversion/branches/fs-py/subversion/libsvn_fs_py/tree.c Mon Aug 8 20:36:47 2011 @@ -132,145 +132,6 @@ static svn_error_t *make_txn_root(svn_fs svn_revnum_t base_rev, apr_uint32_t flags, apr_pool_t *pool); - -/*** Node Caching ***/ - -/* Find and return the DAG node cache for ROOT and the key that - should be used for PATH. */ -static void -locate_cache(svn_cache__t **cache, - const char **key, - svn_fs_root_t *root, - const char *path, - apr_pool_t *pool) -{ - if (root->is_txn_root) - { - fs_txn_root_data_t *frd = root->fsap_data; - if (cache) *cache = frd->txn_node_cache; - if (key && path) *key = path; - } - else - { - fs_fs_data_t *ffd = root->fs->fsap_data; - if (cache) *cache = ffd->rev_node_cache; - if (key && path) *key = apr_psprintf(pool, "%ld%s", - root->rev, path); - } -} - -/* Return NODE for PATH from ROOT's node cache, or NULL if the node - isn't cached; the node is copied into POOL. */ -static svn_error_t * -dag_node_cache_get(dag_node_t **node_p, - svn_fs_root_t *root, - const char *path, - apr_pool_t *pool) -{ - svn_boolean_t found; - dag_node_t *node; - svn_cache__t *cache; - const char *key; - - SVN_ERR_ASSERT(*path == '/'); - - locate_cache(&cache, &key, root, path, pool); - - SVN_ERR(svn_cache__get((void **) &node, &found, cache, key, pool)); - if (found && node) - { - /* Patch up the FS, since this might have come from an old FS - * object. */ - svn_fs_py__dag_set_fs(node, root->fs); - *node_p = node; - } - else - *node_p = NULL; - return SVN_NO_ERROR; -} - - -/* Add the NODE for PATH to ROOT's node cache. */ -static svn_error_t * -dag_node_cache_set(svn_fs_root_t *root, - const char *path, - dag_node_t *node, - apr_pool_t *pool) -{ - svn_cache__t *cache; - const char *key; - - SVN_ERR_ASSERT(*path == '/'); - - locate_cache(&cache, &key, root, path, pool); - - return svn_cache__set(cache, key, node, pool); -} - - -/* Baton for find_descendents_in_cache. */ -struct fdic_baton { - const char *path; - apr_array_header_t *list; - apr_pool_t *pool; -}; - -/* If the given item is a descendent of BATON->PATH, push - * it onto BATON->LIST (copying into BATON->POOL). Implements - * the svn_iter_apr_hash_cb_t prototype. */ -static svn_error_t * -find_descendents_in_cache(void *baton, - const void *key, - apr_ssize_t klen, - void *val, - apr_pool_t *pool) -{ - struct fdic_baton *b = baton; - const char *item_path = key; - - if (svn_dirent_is_ancestor(b->path, item_path)) - APR_ARRAY_PUSH(b->list, const char *) = apr_pstrdup(b->pool, item_path); - - return SVN_NO_ERROR; -} - -/* Invalidate cache entries for PATH and any of its children. This - should *only* be called on a transaction root! */ -static svn_error_t * -dag_node_cache_invalidate(svn_fs_root_t *root, - const char *path, - apr_pool_t *pool) -{ - struct fdic_baton b; - svn_cache__t *cache; - apr_pool_t *iterpool; - int i; - - b.path = path; - b.pool = svn_pool_create(pool); - b.list = apr_array_make(b.pool, 1, sizeof(const char *)); - - SVN_ERR_ASSERT(root->is_txn_root); - locate_cache(&cache, NULL, root, NULL, b.pool); - - - SVN_ERR(svn_cache__iter(NULL, cache, find_descendents_in_cache, - &b, b.pool)); - - iterpool = svn_pool_create(b.pool); - - for (i = 0; i < b.list->nelts; i++) - { - const char *descendent = APR_ARRAY_IDX(b.list, i, const char *); - svn_pool_clear(iterpool); - SVN_ERR(svn_cache__set(cache, descendent, NULL, iterpool)); - } - - svn_pool_destroy(iterpool); - svn_pool_destroy(b.pool); - return SVN_NO_ERROR; -} - /* Creating transaction and revision root nodes. */ @@ -633,16 +494,11 @@ open_path(parent_path_t **parent_path_p, copy_id_inherit_t inherit; const char *copy_path = NULL; svn_error_t *err = SVN_NO_ERROR; - dag_node_t *cached_node; /* If we found a directory entry, follow it. First, we check our node cache, and, failing that, we hit the DAG layer. */ - SVN_ERR(dag_node_cache_get(&cached_node, root, path_so_far, pool)); - if (cached_node) - child = cached_node; - else - err = svn_fs_py__dag_open(&child, here, entry, pool); + err = svn_fs_py__dag_open(&child, here, entry, pool); /* "file not found" requires special handling. */ if (err && err->apr_err == SVN_ERR_FS_NOT_FOUND) @@ -680,10 +536,6 @@ open_path(parent_path_t **parent_path_p, parent_path->copy_inherit = inherit; parent_path->copy_src_path = apr_pstrdup(pool, copy_path); } - - /* Cache the node we found (if it wasn't already cached). */ - if (! cached_node) - SVN_ERR(dag_node_cache_set(root, path_so_far, child, pool)); } /* Are we finished traversing the path? */ @@ -783,10 +635,6 @@ make_path_mutable(svn_fs_root_t *root, copy_id, txn_id, is_parent_copyroot, pool)); - - /* Update the path cache. */ - SVN_ERR(dag_node_cache_set(root, parent_path_path(parent_path, pool), - clone, pool)); } else { @@ -816,17 +664,10 @@ get_dag(dag_node_t **dag_node_p, /* Canonicalize the input PATH. */ path = svn_fs__canonicalize_abspath(path, pool); - /* First we look for the DAG in our cache. */ - SVN_ERR(dag_node_cache_get(&node, root, path, pool)); - if (! node) - { - /* Call open_path with no flags, as we want this to return an error - if the node for which we are searching doesn't exist. */ - SVN_ERR(open_path(&parent_path, root, path, 0, NULL, pool)); - node = parent_path->node; - - /* No need to cache our find -- open_path() will do that for us. */ - } + /* Call open_path with no flags, as we want this to return an error + if the node for which we are searching doesn't exist. */ + SVN_ERR(open_path(&parent_path, root, path, 0, NULL, pool)); + node = parent_path->node; *dag_node_p = node; return SVN_NO_ERROR; @@ -1729,8 +1570,6 @@ svn_fs_py__commit_txn(const char **confl cleanup: - svn_fs_py__reset_txn_caches(fs); - svn_pool_destroy(iterpool); return svn_error_trace(err); } @@ -1872,10 +1711,6 @@ fs_make_dir(svn_fs_root_t *root, txn_id, pool)); - /* Add this directory to the path cache. */ - SVN_ERR(dag_node_cache_set(root, parent_path_path(parent_path, pool), - sub_dir, pool)); - /* Make a record of this modification in the changes table. */ return add_change(root->fs, txn_id, path, svn_fs_py__dag_get_id(sub_dir), svn_fs_path_change_add, FALSE, FALSE, svn_node_dir, @@ -1922,10 +1757,6 @@ fs_delete_node(svn_fs_root_t *root, parent_path->entry, txn_id, pool)); - /* Remove this node and any children from the path cache. */ - SVN_ERR(dag_node_cache_invalidate(root, parent_path_path(parent_path, pool), - pool)); - /* Update mergeinfo counts for parents */ if (svn_fs_py__fs_supports_mergeinfo(root->fs) && mergeinfo_count > 0) SVN_ERR(increment_mergeinfo_up_tree(parent_path->parent, @@ -2060,11 +1891,6 @@ copy_helper(svn_fs_root_t *from_root, from_canonpath, txn_id, pool)); - if (kind == svn_fs_path_change_replace) - SVN_ERR(dag_node_cache_invalidate(to_root, - parent_path_path(to_parent_path, - pool), pool)); - if (svn_fs_py__fs_supports_mergeinfo(to_root->fs) && mergeinfo_start != mergeinfo_end) SVN_ERR(increment_mergeinfo_up_tree(to_parent_path->parent, @@ -2225,10 +2051,6 @@ fs_make_file(svn_fs_root_t *root, txn_id, pool)); - /* Add this file to the path cache. */ - SVN_ERR(dag_node_cache_set(root, parent_path_path(parent_path, pool), child, - pool)); - /* Make a record of this modification in the changes table. */ return add_change(root->fs, txn_id, path, svn_fs_py__dag_get_id(child), svn_fs_path_change_add, TRUE, FALSE, svn_node_file, @@ -3914,12 +3736,6 @@ make_txn_root(svn_fs_root_t **root_p, apr_pstrcat(pool, txn, ":TXN", (char *)NULL), root->pool)); - /* Initialize transaction-local caches in FS. - - Note that we cannot put those caches in frd because that content - fs root object is not available where we would need it. */ - SVN_ERR(svn_fs_py__initialize_txn_caches(fs, txn, pool)); - root->fsap_data = frd; *root_p = root;