Checkout these simple timings:
~~~~~
_start = time()
a = self._get_refs(self._git.branches)
print("Time using fsck : {}".format(time() - _start))
_start = time()
b = [Object(name=b.name, object_id=b.commit.hexsha) for b in
self._git.branches if b.is_valid()]
print("Validation Time (the old way): {}".format(time() - _start))
print(a == b)
## Results
# Time using fsck : 1.61762309074
# Validation Time (the old way): 2.93375897408
# True
~~~~~
Of the time it took to get the list with `self._get_refs(self._git.branches)`,
fsck only accounted for: **0.121250049591** -- In that time, it checked 256
directories and 3498 objects (the result of which is cached via lazyprop so
tags can make use of it too).
The only time the fsck method will be slower is the case where there is an
actual error -- then it's the sum of both fsck and is_valid times. But that is
supposedly an edge case anyways, right?
If you guys think it'll cause issues down the road, I have no problem going
another route, but it seems to scale better than our existing implementation.
Also, I really like the idea of using mongo as a 'smart cache' and invalidating
via repo_refresh!
---
** [tickets:#7873] Git branch & tag speedups**
**Status:** in-progress
**Milestone:** unreleased
**Labels:** performance sf-current sf-4
**Created:** Fri Apr 17, 2015 09:23 PM UTC by Dave Brondsema
**Last Updated:** Wed Jun 10, 2015 05:20 PM UTC
**Owner:** Heith Seewald
I saw that git pages on forge-allura.apache.org were slow, so I looked at
stats.log and saw that the sidebar was the slowest part. I did some additional
digging and found 2 specific areas for improvement:
* in `git_main.py` change `default_branch_name` to a `@LazyProperty` since it
is called many times inside a loop in `RepositoryApp.sidebar_menu`
* Since `sidebar_menu` only requests a certain number of branches, pass that
"limit" all the way through to `git_repo.py`'s `branches` method so that
`is_valid()` is only called a minimum number of times needed.
* make sure the default branch logic to put it at the top of the list still
works (e.g. always put it at the top first)
In addition to those changes, generalize and apply the same approach to the
tags. And also check ForgeHg to see if mercurial can benefit the same way.
---
Sent from forge-allura.apache.org because [email protected] is subscribed
to https://forge-allura.apache.org/p/allura/tickets/
To unsubscribe from further messages, a project admin can change settings at
https://forge-allura.apache.org/p/allura/admin/tickets/options. Or, if this is
a mailing list, you can unsubscribe from the mailing list.