1

I'm batch processing lots of Mercurial repositories and I want to save CPU time by avoiding fork.

I can use internal Mercurial API: https://www.mercurial-scm.org/wiki/MercurialApi to create objects operating on several repositories simultaneously in a single Python process address space. But this method is discouraged by Hg maintainers: they consider Python Hg API unstable...

https://www.mercurial-scm.org/wiki/CommandServer is a recommended approach but it requires starting a server per repository: hg --config ui.interactive=True serve --cmdserver pipe. Meaning lots of forks that I wanted to avoid...

Is there a way to utilize a single hg serve --cmdserver pipe and switch repositories? What is the control command name for switching, what is the signature/args?

gavenkoa
  • 45,285
  • 19
  • 251
  • 303
  • If you were able to get the cmd server to switch repositories, why is that better than stopping/starting a new server? – StayOnTarget Dec 06 '22 at 12:55
  • My goal is to avoid `fork` syscall. It is bottleneck on Windows. I'm experimenting with private `mercurial` package instead. – gavenkoa Dec 06 '22 at 13:49
  • Unless the repos are tiny I would have thought the new process creation would be only a very small portion of the overall runtime / cpu work – StayOnTarget Dec 06 '22 at 15:09
  • Not on windows... I'm working on syncing a set of hg repos. Cygwin or Msys2 have extremely slow `fork`. – gavenkoa Dec 06 '22 at 21:39

0 Answers0