diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-04-03 17:31:59 -0500 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-04-04 17:27:10 -0700 |
commit | 2d760a7bff71c46c5aeba37c40d236ea16eefea2 (patch) | |
tree | 31520cecba5722150f8cddfcf627351ea1257f4f /subsurface-core/load-git.c | |
parent | 2b36091599cbc51474e103f14037e5ac44215cf3 (diff) | |
download | subsurface-2d760a7bff71c46c5aeba37c40d236ea16eefea2.tar.gz |
Don't write back dive data that hasn't changed in git
This caches the git ID for the dive on load, and avoids building the
dive directory and hashing it on save as long as nothing has invalidated
the git ID cache.
That should make it much faster to write back data to the git
repository, since the dive tree structure and the divecomputer blobs in
particular are the bulk of it (due to all the sample data). It's not
actually the git operations that are all that expensive, it's literally
generating the big blob with all the snprintf() calls for the data.
The git save used to be a fairly expensive with large data sets,
especially noticeable on mobile with much weaker CPU's. This should
speed things up by at least a factor of two.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core/load-git.c')
-rw-r--r-- | subsurface-core/load-git.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/subsurface-core/load-git.c b/subsurface-core/load-git.c index a78082c07..a1f2d2031 100644 --- a/subsurface-core/load-git.c +++ b/subsurface-core/load-git.c @@ -1236,7 +1236,7 @@ static int dive_trip_directory(const char *root, const char *name) * * The root path will be of the form yyyy/mm[/tripdir], */ -static int dive_directory(const char *root, const char *name, int timeoff) +static int dive_directory(const char *root, const git_tree_entry *entry, const char *name, int timeoff) { int yyyy = -1, mm = -1, dd = -1; int h, m, s; @@ -1314,6 +1314,7 @@ static int dive_directory(const char *root, const char *name, int timeoff) finish_active_dive(); active_dive = create_new_dive(utc_mktime(&tm)); + memcpy(active_dive->git_id, git_tree_entry_id(entry)->id, 20); return GIT_WALK_OK; } @@ -1412,7 +1413,7 @@ static int walk_tree_directory(const char *root, const git_tree_entry *entry) * two digits and a dash */ if (name[len-3] == ':' || name[len-3] == '=') - return dive_directory(root, name, len-8); + return dive_directory(root, entry, name, len-8); if (digits != 2) return GIT_WALK_SKIP; @@ -1470,6 +1471,12 @@ static int parse_divecomputer_entry(git_repository *repo, const git_tree_entry * return 0; } +/* + * NOTE! The "git_id" for the dive is the hash for the whole dive directory. + * As such, it covers not just the dive, but the divecomputers and the + * pictures too. So if any of the dive computers change, the dive cache + * has to be invalidated too. + */ static int parse_dive_entry(git_repository *repo, const git_tree_entry *entry, const char *suffix) { struct dive *dive = active_dive; |