Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upRun async libgit2 calls on custom threadpool #1019
Conversation
|
Innnnnnnnnteresting. |
|
@joshaber yep, the time has come to finalize this :-) With the recent libgit2 upgrade, libgit2 no longer locks the index internally. That makes it more important to turn on nodegit's thread safety, but the locking increases the burden on node's threadpool and can lead to long delays and deadlocks like we've discussed. Hopefully, this PR will avoid those issues and make thread-safe nodegit run better. |
|
wow, that's very interesting. |
|
Why this is needed: So with running async libgit2 threads with thread-safety we're enqueuing them with the internal libuv thread pool which in node is hardcoded to 4 (IIRC). This hits us hard because we also share a thread with node so that leaves us with 3 threads to pull from. That sucks because say you're running a libgit2 function that has multiple callbacks. So we have 1 thread for node, 1 thread for the original call for libgit2, a 1 thread for each callback. Let's assume that those callbacks are also going to go run libgit2 code. So as a first step this is |
d10dcee
to
ed61ea0
|
@nodegit/owners OK folks, I made most of the updates to the code that I wanted to - if anyone has a little time to spare I would love to get feedback. The main parts are:
As mentioned eariler, the reason for this PR is to get our async calls off libuv's threadpool, and avoid slowdowns and deadlocks resulting from needing more threads than available. This issue was anticipated by @saper in #827 (comment), we have seen it in GitKraken when we tried turning on NodeGit's thread-safety locking, and IIRC @joshaber reported seeing it in Atom as well. The PR currently uses 10 dedicated threads for async libgit2 calls - it is not a well thought-out number but it's >4 and dedicated :-) I've considered exposing some statistics to javascript, for example the number of async handles opened by (the CI is failing, but it looks like it's problems with AppVeyor and Travis - it was green yesterday before the final code cleanup) |
|
CI died due to network issues. I'm re-running the tests. |
|
Which sucks. Every day I wake up and say to myself, "today I'll make the unit tests work offline..." |
|
Me too @tbranyen. Me too :( |
|
Testing this in GK right now. |
|
We did run into some problems during testing in GitKraken. It worked well for the most part, but on windows we were seeing frequent app restarts. Commenting out calls to @joshaber - @johnhaley81 suggested I ping you about this - any ideas? |
|
Unfortunately I don't know much about Electron's internals. |
|
The problem ended up being on my end - I took |
|
We are running this build in production over in GitKraken land and things look Awesome job @srajko |
|
I'm not really qualified to review this PR, so I'll just |
|
It's alright @tbranyen, we love you anyways. @joshaber @saper @implausible? |
|
Looks reasonable to me |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

srajko commentedMay 2, 2016
No description provided.