-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix #1091] performance boost for big repos #1275
base: master
Are you sure you want to change the base?
Conversation
… are too aggressive
@@ -71,9 +71,8 @@ exports.registerApi = (env) => { | |||
}); | |||
} | |||
}).then(() => { | |||
const watcher = fs.watch(pathToWatch, options || {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the file watcher events which I added. See #1263 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah.... why? API documentation does not mention error event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The returned fs.FSWatcher
does have the events: https://nodejs.org/api/fs.html#fs_class_fs_fswatcher
And it is important to listen for the error event otherwise the process would crash if the event isn't handled. This was a source of clicktest failures because we deleted the temp directory while the directory was still openend in ungit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I find this api design to be confusing... multiple places to register events and when you register change
event listener, it would multiple sub event types? This is bit odd especially when fswatcher{}
is not shared anywhere else.
It would be much more sensible if listener
argument of fs.watch()
has "error" events rather than expose it via entirely separate function
Yeah I will fix it up later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
Nice opportunities to speed up ungit for both repos 👍 Though could you split the PR in different branches (PRs) so that they can be tested individually? |
Yeah you are right, let me break this one out to two: one with But inevitably |
this.graph = graph; | ||
this.sha1 = sha1; | ||
this.isInited = false; | ||
this.title = ko.observable(); | ||
this.parents = ko.observableArray(); | ||
this.commitTime = undefined; // commit time in string | ||
this.date = undefined; // commit time in numeric format for sort | ||
this.timestamp = undefined; // commit time in numeric format for sort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the "numeric format"?
Is that ISO or yyyyMMddhhmm
?
This PR definitely changes and challenges how things are being calculated. Definitely needs lots testing and incubations. Will keep my eyes out for these kind of problems |
Few things are done here.
/gitlog
api callignore 'rename' filewatch event as it can cause constant update and refresh loop
This one is bit tricky as some OS, git and node version behave differently and the
fs.watch()
doc itself does describe very inconsistent behavior.Here is a problem with that for some combination of OS, git and node versions:
/refs
git api call, git operations would continuously delete and create some files such as.git/refs/remotes/origin/master
fs.watch()
remote eventgit-directory-changed
socket io event/gitlog
and/refs
/gitlog
will seriously bog down entire performance both and back end and frontend as it is more compute intense operation to recalculate and draw/refs
will trigger everything back to step 1 and entire thing repeatsThere is no way to test and prepare for all combinations. We should stick with latest doc and latest API.
So, adopted to latest API and ignoring
rename
event.todo
https://github.com/git/git page load with old code: https://recordit.co/O1lzQO62Z2
https://github.com/git/git page load with new code: https://recordit.co/bHmV8QiA0I
Below changes are abstracted out to #1277
Prevent full gitlog history from server to client and load only what is neededUpon page load, client will make and API call to get list of git nodes. However, this call gets list of ALL nodes every time. i.e. if a pages is showing 300 nodes and user scrolls down asking for 25 more nodes, backend will return 325 nodes, not just the 25 nodes needed.This is now fixed and backend will return only the nodes client needs.Prevent redundant ref and node calculations per each/gitlog
api callOne of the biggest performance hit for big repos was due to git refs calculations because ungit loads ALL refs, local and remote branches and tags of it's history.This is needed to some degree to display them in the branch drop down and etc, but there were some inefficiencies on logic that thinking these refs had valid nodes and did unnecessary calculations.