Closed
Bug 1383252
Opened 9 years ago
Closed 9 years ago
[sync] Reduce the number of hg clone operations
Categories
(Webtools Graveyard :: Pontoon, enhancement, P3)
Webtools Graveyard
Pontoon
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: mathjazz, Unassigned)
Details
On each sync cycle, Pontoon needs to update all project repositories, to check if there are any changes to be imported into Pontoon.
Since our HG projects (Firefox, Firefox for Android, Thunderbird, Lightning, Seamonkey) work with per-locale repositories, that means hg clone operation for each locale enabled for each of these projects. That's currently over 200 such operations per sync cycle, which translates into several minutes of sync time. The number only goes up as we enable more locales for these projects.
The best part of it is that most of the time only a few (if any) of these repositories actually change.
--
We should be able to reduce the number of hg clone operations by using this file:
https://hg.mozilla.org/l10n-central/?style=json
It gives us the timestamp of the last change for each repository, so we only need to clone repositories for locales that have either changed since the last project sync or have changes in Pontoon (so that we can commit them).
Comment 1•9 years ago
|
||
Also, we don't need to clone each time, despite what https://github.com/mathjazz/pontoon/blob/61751748552fc44d3b89da7e8d07e54fbe922206/pontoon/sync/vcs/repositories.py#L79 says.
We can enable the `strip` extension, and before we pull, do an `hg strip -r 'roots(draft())'`, followed by an `hg up -C -r default`.
| Reporter | ||
Comment 2•9 years ago
|
||
We should be better off by using "https://hg.mozilla.org/l10n-central/{locale_code}/rev/default?style=json" instead of "https://hg.mozilla.org/l10n-central/?style=json".
It gives us the latest commit id, which is more suitable for our use case than timestamp, because we store last synced revision for each repository.
The downside is that we need to make a separate request for each locale, which takes around 35 seconds for 90+ Firefox locales (~400 ms per request). But that's still ~20 *times* faster than hg clone.
Comment 3•9 years ago
|
||
If it takes so long because of network, you may run the sync in parallel. It won't be possible to sync multiple languages for a single locale repo at the same time, but is should be safe to sync e.g. all Firefox locales at the same time, because they have standalone repositories.
| Reporter | ||
Comment 4•9 years ago
|
||
We already run sync in parallel. So all HG clone operations for all 6 HG projects do not take significantly more time than if we only sync the single project with the most repos.
Comment 5•9 years ago
|
||
Commit pushed to master at https://github.com/mozilla/pontoon
https://github.com/mozilla/pontoon/commit/c54707052d7f162cbaa3d1c7c4e7b0f1c114e924
Fix bug 1383252: Reduce hg clone operations (#688)
If project repositories have API access, we can retrieve their latest
commit hashes, using which we can detect changed locales in VCS, join
them with changed locales in DB and only clone repositories for those.
For projects with many repositories, this is much faster than running
VCS pull/clone for each repository.
Related changes fixed along the way:
* If sources have changed, update stats for all locales at the end, even
if they don't have locale specific changes or we don't even have their
checkouts.
* Simplify single locale sync code: rename sync_resources to
sync_sources to better reflect what the code actually does. It syncs
Resource and Entity objects, which represent source strings.
* Do not clone all repositories on single locale sync
* More robust Repository.pull() and pull_changes signature
Updated•9 years ago
|
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Updated•5 years ago
|
Product: Webtools → Webtools Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•