Re: Worried about single-db performance
From: Justin Erenkrantz <justin_at_erenkrantz.com>
Date: Fri, 3 Sep 2010 23:33:11 -0700
On Fri, Sep 3, 2010 at 8:39 AM, Greg Stein <gstein_at_gmail.com> wrote:
I just spent a little bit time with Shark and gdb. A cold run of 'svn
One striking difference in the perf profile between 1.6 & trunk is
From looking at the traces and code, I *think*
/* ### at some point in the future, we may need to find a way to get
I see this stat() call getting called approximately seven times *per*
Shark says this patch saves us about 2.5% time-wise - not a whole lot
I'll keep looking through the timing profiles to see what else I can
--- Remember WC files we've seen before to save on stat() calls. * subversion/libsvn_wc/wc_db_private.h (svn_wc__db_t): Add a hash table to remember file entries. * subversion/libsvn_wc/wc_db_pdh.c (svn_wc__db_open): Create file_data hash. (svn_wc__db_pdh_parse_local_abspath): Use hash to save stat() lookups. Index: wc_db_pdh.c =================================================================== --- wc_db_pdh.c (revision 992534) +++ wc_db_pdh.c (working copy) @@ -216,6 +216,7 @@ svn_wc__db_open(svn_wc__db_t **db, (*db)->auto_upgrade = auto_upgrade; (*db)->enforce_empty_wq = enforce_empty_wq; (*db)->dir_data = apr_hash_make(result_pool); + (*db)->file_data = apr_hash_make(result_pool); (*db)->state_pool = result_pool; return SVN_NO_ERROR; @@ -424,10 +425,21 @@ svn_wc__db_pdh_parse_local_abspath(svn_wc__db_pdh_ return SVN_NO_ERROR; } - /* ### at some point in the future, we may need to find a way to get - ### rid of this stat() call. it is going to happen for EVERY call - ### into wc_db which references a file. calls for directories could - ### get an early-exit in the hash lookup just above. */ + /* Have we already successfully seen this file before? */ + *pdh = apr_hash_get(db->file_data, local_abspath, APR_HASH_KEY_STRING); + if (*pdh != NULL && (*pdh)->wcroot != NULL) { + const char *local_abspath_parent, *dir_relpath; + svn_dirent_split(&local_abspath_parent, &build_relpath, local_abspath, + scratch_pool); + + /* Stashed directory's local_relpath + basename. */ + dir_relpath = svn_wc__db_pdh_compute_relpath(*pdh, NULL); + *local_relpath = svn_relpath_join(dir_relpath, + build_relpath, + result_pool); + return SVN_NO_ERROR; + } + SVN_ERR(svn_io_check_special_path(local_abspath, &kind, &special /* unused */, scratch_pool)); if (kind != svn_node_dir) @@ -440,7 +452,8 @@ svn_wc__db_pdh_parse_local_abspath(svn_wc__db_pdh_ For both of these cases, strip the basename off of the path and move up one level. Keep record of what we strip, though, since we'll need it later to construct local_relpath. */ - svn_dirent_split(&local_abspath, &build_relpath, local_abspath, + const char *local_abspath_parent; + svn_dirent_split(&local_abspath_parent, &build_relpath, local_abspath, scratch_pool); /* ### if *pdh != NULL (from further above), then there is (quite @@ -448,7 +461,8 @@ svn_wc__db_pdh_parse_local_abspath(svn_wc__db_pdh_ ### clear it out? but what if there is an access baton? */ /* Is this directory in our hash? */ - *pdh = apr_hash_get(db->dir_data, local_abspath, APR_HASH_KEY_STRING); + *pdh = apr_hash_get(db->dir_data, local_abspath_parent, + APR_HASH_KEY_STRING); if (*pdh != NULL && (*pdh)->wcroot != NULL) { const char *dir_relpath; @@ -458,6 +472,8 @@ svn_wc__db_pdh_parse_local_abspath(svn_wc__db_pdh_ *local_relpath = svn_relpath_join(dir_relpath, build_relpath, result_pool); + apr_hash_set(db->file_data, local_abspath, APR_HASH_KEY_STRING, + *pdh); return SVN_NO_ERROR; } Index: wc_db_private.h =================================================================== --- wc_db_private.h (revision 992534) +++ wc_db_private.h (working copy) @@ -52,6 +52,10 @@ struct svn_wc__db_t { const char *local_abspath -> svn_wc__db_pdh_t *pdh */ apr_hash_t *dir_data; + /* Map a known working copy file to its parent data. + const char *local_abspath -> svn_wc__db_pdh_t *pdh */ + apr_hash_t *file_data; + /* As we grow the state of this DB, allocate that state here. */ apr_pool_t *state_pool; };Received on 2010-09-04 08:34:40 CEST |
This is an archived mail posted to the Subversion Dev mailing list.
This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.