"Works" insofar that it will alter the packed_git_window_size variable in environment.c when the environment is set up. It /doesn't/ work when commands like git-diff(1) and git-log(1) call get_revision() which seems to disregard the setting if the packed_window_size is set to something low (i.e. ulimit -v 32768) Signed-off-by: R. Tyler Ballance <tyler@xxxxxxxxx> --- environment.c | 10 ++++++++++ git-compat-util.h | 4 ++++ 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/environment.c b/environment.c index e278bce..a3b6bab 100644 --- a/environment.c +++ b/environment.c @@ -7,6 +7,9 @@ * even if you might want to know where the git directory etc * are. */ +#include <sys/time.h> +#include <sys/resource.h> + #include "cache.h" char git_default_email[MAX_GITNAME]; @@ -75,6 +78,13 @@ static void setup_git_env(void) git_graft_file = getenv(GRAFT_ENVIRONMENT); if (!git_graft_file) git_graft_file = git_pathdup("info/grafts"); + + if (DYNAMIC_WINDOW_SIZE) { + struct rlimit *as = malloc(sizeof(struct rlimit)); + if ( (getrlimit(RLIMIT_AS, as) == 0) && ((int)(as->rlim_cur) > 0) ) + packed_git_window_size = (unsigned int)(as->rlim_cur * DYNAMIC_WINDOW_SIZE_PERCENTAGE); + free(as); + } } int is_bare_repository(void) diff --git a/git-compat-util.h b/git-compat-util.h index e20b1e8..9603ca6 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -182,6 +182,8 @@ extern int git_munmap(void *start, size_t length); /* This value must be multiple of (pagesize * 2) */ #define DEFAULT_PACKED_GIT_WINDOW_SIZE (1 * 1024 * 1024) +#define DYNAMIC_WINDOW_SIZE 0 +#define DYNAMIC_WINDOW_SIZE_PERCENTAGE 0 #else /* NO_MMAP */ @@ -192,6 +194,8 @@ extern int git_munmap(void *start, size_t length); (sizeof(void*) >= 8 \ ? 1 * 1024 * 1024 * 1024 \ : 32 * 1024 * 1024) +#define DYNAMIC_WINDOW_SIZE 1 +#define DYNAMIC_WINDOW_SIZE_PERCENTAGE 0.85 #endif /* NO_MMAP */ -- -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html