From: Kjetil Barvik <barvik@broadpark.no>
To: git@vger.kernel.org
Cc: Kjetil Barvik <barvik@broadpark.no>
Subject: [PATCH/RFC v1 6/6] lstat_cache(): print a warning if doing ping-pong between cache types
Date: Mon, 26 Jan 2009 22:18:42 +0100 [thread overview]
Message-ID: <1233004722-15142-1-git-send-email-barvik@broadpark.no> (raw)
This is a debug patch which is only to be used while the lstat_cache()
is in the test stage, and should be removed/reverted before the final
relase.
I think it should be useful to catch these warnings, as I it could be
an indication of that the cache would not be very effective if it is
doing ping-pong by switching between different cache types too many
times.
Also, if someone is experimenting with the lstat_cache(), this patch
will maybe be useful while debugging.
If someone is able to trigger the warning, then send a mail to the GIT
mailing list, containing the first 15 lines of the warning, and a
short description of the GIT commands to trigger the warnings.
This patch is against the 'next' branch. I hope someone is willing to
use this patch for a while, to be able to catch possible ping-pong's.
Signed-off-by: Kjetil Barvik <barvik@broadpark.no>
---
Hmmm, it seems that 'git send-email' always fails for this mail, with
the following error message:
Died at /usr/local/libexec/git-core/git-send-email line 882.
So I send this as a separate command from 'git send-email', sorry
abouth that.
symlinks.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/symlinks.c b/symlinks.c
index 81f490c..1c07ae0 100644
--- a/symlinks.c
+++ b/symlinks.c
@@ -49,6 +49,11 @@ static inline void reset_lstat_cache(int track_flags, int prefix_len_stat_func)
cache.prefix_len_stat_func = prefix_len_stat_func;
}
+#define SWITCHES_BEFORE_WARNING 10
+static unsigned int cache_switches = 0, number_of_warnings = 0;
+static unsigned int current_cache_func = 0, last_cache_func = 0;
+static unsigned int total_calls = 0;
+
#define FL_DIR (1 << 0)
#define FL_NOENT (1 << 1)
#define FL_SYMLINK (1 << 2)
@@ -75,6 +80,7 @@ static int lstat_cache(int len, const char *name,
int match_flags, ret_flags, save_flags, max_len, ret;
struct stat st;
+ total_calls++;
if (cache.track_flags != track_flags ||
cache.prefix_len_stat_func != prefix_len_stat_func) {
/*
@@ -84,6 +90,17 @@ static int lstat_cache(int len, const char *name,
*/
reset_lstat_cache(track_flags, prefix_len_stat_func);
match_len = last_slash = 0;
+ cache_switches++;
+ if (cache_switches > SWITCHES_BEFORE_WARNING) {
+ if (number_of_warnings < 10 || number_of_warnings % 1000 == 0)
+ printf("warning from %s:%d cache_switches:%u > %u "\
+ "(current:%u last:%u total:%u)\n",
+ __FILE__, __LINE__,
+ cache_switches, SWITCHES_BEFORE_WARNING,
+ current_cache_func, last_cache_func,
+ total_calls);
+ number_of_warnings++;
+ }
} else {
/*
* Check to see if we have a match from the cache for
@@ -211,6 +228,8 @@ void clear_lstat_cache(void)
*/
int has_symlink_leading_path(int len, const char *name)
{
+ last_cache_func = current_cache_func;
+ current_cache_func = 1;
return lstat_cache(len, name,
FL_SYMLINK|FL_DIR, USE_ONLY_LSTAT) &
FL_SYMLINK;
@@ -222,6 +241,8 @@ int has_symlink_leading_path(int len, const char *name)
*/
int has_symlink_or_noent_leading_path(int len, const char *name)
{
+ last_cache_func = current_cache_func;
+ current_cache_func = 2;
return lstat_cache(len, name,
FL_SYMLINK|FL_NOENT|FL_DIR, USE_ONLY_LSTAT) &
(FL_SYMLINK|FL_NOENT);
@@ -236,6 +257,8 @@ int has_symlink_or_noent_leading_path(int len, const char *name)
*/
int has_dirs_only_path(int len, const char *name, int prefix_len)
{
+ last_cache_func = current_cache_func;
+ current_cache_func = 3;
return lstat_cache(len, name,
FL_DIR|FL_FULLPATH, prefix_len) &
FL_DIR;
--
1.6.1.349.g99fa5
reply other threads:[~2009-01-26 21:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1233004722-15142-1-git-send-email-barvik@broadpark.no \
--to=barvik@broadpark.no \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).