Closed Bug 1671351 Opened 4 years ago Closed 4 years ago

remove all calls to hg via subprocess

Categories

(Conduit :: moz-phab, enhancement)

enhancement

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: tarek, Assigned: tarek)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

moz-phab is calling hg cat and hg files on EACH file it processes. This is extremely expensive, you need to start a python process everytime.

Let's use directly the mercurial lib.

ALL calls to hg should be migrated to use the lib.

I'll start to do it in https://github.com/tarekziade/review - feel free to use that clone to try out (speedup branch)

Assignee: nobody → tarek
Type: defect → enhancement
Blocks: 1649086

using mercurial's internals directly sounds misguided, there's no API compat guarantees

I am not saying that it is good but we have significant precedents in our tooling. For example:
https://hg.mozilla.org/hgcustom/version-control-tools/file/tip/hgext/clang-format/__init__.py
(and many other files in this repo)

Sure, but these are hg extensions so you kind of don't have a choice there. There's ways to avoid forking hg many times from moz-phab without going the "use mercurial internals" way (off the top of my head, using hglib, or chg, but even without that, avoiding repeating the same things over and over, as documented in other bugs hanging off of 1649086), since that is likely to just increase your maintenance cost. And you'll end up just reinventing hg's own phabricator extension, which also seems like wasted effort. Obviously it's ultimately not my call.

(In reply to Julien Cristau [:jcristau] from comment #1)

using mercurial's internals directly sounds misguided, there's no API compat guarantees

+1
See https://www.mercurial-scm.org/wiki/MercurialApi#Why_you_shouldn.27t_use_Mercurial.27s_internal_API
There's also licensing concerns as linking with mercurial internals forces us to use GPL.

Using https://www.mercurial-scm.org/wiki/PythonHglib will avoid creating a process for every hg query, but using a stable API.

Thanks all, I moved to python-hlib and we're seeing the same gains. (3-4x)

I've updated my PR and will work on the tests to make sure everything's fine. If you want to give it a shot, please do!

Attachment #9182028 - Attachment is obsolete: true
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED

This failed the Windows tests. I'll investigate and fix.

Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Status: REOPENED → RESOLVED
Closed: 4 years ago4 years ago
Resolution: --- → FIXED
Regressions: 1676220
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: