From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Aaron Jensen Newsgroups: gmane.emacs.bugs Subject: bug#26397: 25.1; call-process slow on macOS and slower on larger frames Date: Sun, 9 Apr 2017 08:07:26 -0700 Message-ID: References: <20170408191959.GA7541@breton.holly.idiocy.org> <20170409130155.GA59432@breton.holly.idiocy.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1491750503 13666 195.159.176.226 (9 Apr 2017 15:08:23 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 9 Apr 2017 15:08:23 +0000 (UTC) Cc: 26397@debbugs.gnu.org To: Alan Third Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 09 17:08:18 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxERk-0002AF-QX for geb-bug-gnu-emacs@m.gmane.org; Sun, 09 Apr 2017 17:08:09 +0200 Original-Received: from localhost ([::1]:58837 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxERq-0003U3-PV for geb-bug-gnu-emacs@m.gmane.org; Sun, 09 Apr 2017 11:08:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42050) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxERj-0003Ty-12 for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2017 11:08:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxERf-0001o3-0F for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2017 11:08:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41664) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cxERe-0001np-Rn for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2017 11:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cxERe-0007LV-HE for bug-gnu-emacs@gnu.org; Sun, 09 Apr 2017 11:08:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Aaron Jensen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 09 Apr 2017 15:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 26397 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 26397-submit@debbugs.gnu.org id=B26397.149175045528203 (code B ref 26397); Sun, 09 Apr 2017 15:08:02 +0000 Original-Received: (at 26397) by debbugs.gnu.org; 9 Apr 2017 15:07:35 +0000 Original-Received: from localhost ([127.0.0.1]:39863 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxERD-0007Kp-6z for submit@debbugs.gnu.org; Sun, 09 Apr 2017 11:07:35 -0400 Original-Received: from mail-yw0-f175.google.com ([209.85.161.175]:35564) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxERA-0007Kb-HO for 26397@debbugs.gnu.org; Sun, 09 Apr 2017 11:07:33 -0400 Original-Received: by mail-yw0-f175.google.com with SMTP id d191so50493888ywe.2 for <26397@debbugs.gnu.org>; Sun, 09 Apr 2017 08:07:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=AxgiLKtMjFVt03Kyv8nMxppcVhgudwUs4pPGW6UIED8=; b=qSb103Oo//h38fax2A3nb6+vGLeIz1Xpy4jb94mj1mhAvrONzNDnEVit48lpxb15Ge FySdNnciSDO1U4n29y0jEPGSNn8DTitubmIWSlBhsBaQj6XYYKEHKssCgGT6MXVX+iGI ey5uxJ9IYScQfhR7qv9sWYgNh1PjXuj11MMBtuOiUGJQIiCLwRpvkKPfPzlVQd2N7AvA CJva95HneEma7M0O7s9HWOW1DfYVj2ibAO778PyRgpQcSiTYS2RdKrJ20LWgrr8ccD+k qWFhKNBvJZCXJSfNeP0M8L3rktn/Pjvl6efq8icfNxf0CfMyqNRjPB7owsuw1K1hpeMJ Qrlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=AxgiLKtMjFVt03Kyv8nMxppcVhgudwUs4pPGW6UIED8=; b=aHoprdNEAoOpOe+YKeGM6Xdg/pjY3ASk8rCE1H4ixRfS4+AaJY10fn6nr0eAJ0acjG j11mtGBpnhJDa+AnzqElk2gu8Jp69zFZOdIbRNkS3geUtn+Z0v1tffqlwrI2HtHeKSMt 2HCBQ6XhPy4yFrqhN1W6if7MXwrgUe3E9O4f2hSglzlXX06K7dUJ75HAjisIKQK/xGX9 VkMrCvaa2/5PTOawcokKVHy0TcgiGimziFDP3zSAIMS6ekn7RWWm3iDjMT+sVWYQQREJ SEd0iby/1c6Omv10EBGnqxPnmoQxvnbiS2S53KlesDx+lio+QzrLjRJGTWvc6njfNEaF /CUQ== X-Gm-Message-State: AFeK/H2HA0kIRkdTM5Zrwax5+mzzsdFngxpI2bIYfKARaNqpAIc+35tMxnjQSndaiH3FIuqr9HYXmi7SJuREUQ== X-Received: by 10.129.121.151 with SMTP id u145mr36663807ywc.247.1491750446921; Sun, 09 Apr 2017 08:07:26 -0700 (PDT) Original-Received: by 10.37.56.132 with HTTP; Sun, 9 Apr 2017 08:07:26 -0700 (PDT) In-Reply-To: <20170409130155.GA59432@breton.holly.idiocy.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:131411 Archived-At: That appears to work for me. Here's the patch I'm trying out: https://gist.githubusercontent.com/aaronjensen/28e26a6c6c0dc767176bc35d5545= d10e/raw/7fbbfa48fcf26d083e38cec9f174cef911a806ca/GNU-Emacs-25.1-OS-X-enabl= e-vfork.patch =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D >From 4a9221e2332d85d64978719a43f884b92bf6cb7b Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Sat, 8 Apr 2017 08:32:57 -0700 Subject: [PATCH 1/2] Enable vfork on macOS --- src/conf_post.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf_post.h b/src/conf_post.h index 209f60792c..04c5cd6cf6 100644 --- a/src/conf_post.h +++ b/src/conf_post.h @@ -87,8 +87,8 @@ typedef bool bool_bf; (make-comint "test0" "/nodir/nofile" nil "") when /nodir/nofile does not exist. Also, setsid is not allowed in the vfork child's context as of Darwin 9/Mac OS X 10.5. */ -#undef HAVE_WORKING_VFORK -#define vfork fork +/* #undef HAVE_WORKING_VFORK */ +/* #define vfork fork */ #endif /* DARWIN_OS */ /* If HYBRID_MALLOC is defined (e.g., on Cygwin), emacs will use --=20 2.12.2 >From 9a15fda33bf2b369207701b66cd8f93e2d3a8801 Mon Sep 17 00:00:00 2001 From: Aaron Jensen Date: Sun, 9 Apr 2017 07:43:25 -0700 Subject: [PATCH 2/2] Only vfork if not pty --- src/process.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/process.c b/src/process.c index 7ab92b0102..b49d5970c8 100644 --- a/src/process.c +++ b/src/process.c @@ -1811,7 +1811,14 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) int volatile forkerr_volatile =3D forkerr; struct Lisp_Process *p_volatile =3D p; - pid =3D vfork (); + #ifdef DARWIN_OS + if (pty_flag) + pid =3D fork (); + else + pid =3D vfork (); + #else + pid =3D vfork (); + #endif current_dir =3D current_dir_volatile; lisp_pty_name =3D lisp_pty_name_volatile; --=20 2.12.2 On Sun, Apr 9, 2017 at 6:01 AM, Alan Third wrote: > On Sat, Apr 08, 2017 at 08:19:59PM +0100, Alan Third wrote: >> On Sat, Apr 08, 2017 at 08:47:25AM -0700, Aaron Jensen wrote: >> > On Sat, Apr 8, 2017 at 12:37 AM, YAMAMOTO Mitsuharu >> > wrote: >> > > >> > > Probably "fork" copies some GUI resources. That would also explain >> > > why the performance is worse on the Mac port, where each frame >> > > allocates an extra NSWindow for overlaying. >> > > >> > > It becomes much faster and seemingly unaffected by the frame size if >> > > you comment out "#undef HAVE_WORKING_VFORK" and "#define vfork fork" >> > > in src/conf_post.h. But I'm not sure if it is safe. >> > >> > Wow, that does make a big difference. The comment says that Emacs >> > hangs when evaluating: >> > >> > (make-comint "test0" "/nodir/nofile" nil "") >> > >> > But I can not reproduce that currently with vfork. > > I can=E2=80=99t reproduce a hang with that command either. > >> > I do not understand the second comment: "Also, setsid is not >> > allowed in the vfork child's context as of Darwin 9/Mac OS X >> > 10.5." >> >> It looks to me like we could replace the call to setsid with >> >> setpgid (0, 0); >> >> for Darwin builds. > > No, forget that. It doesn=E2=80=99t do the same thing at all. > > If you run Emacs, then > > M=E2=80=90x ansi-term RET RET > > You should get a shell prompt. Using fork/setsid, your shell will be > able to do job control, but using vfork it can=E2=80=99t. You can test th= is by > typing the `bg` command. Zsh (and I assume bash, etc.) responds by > telling you either there are no jobs, or that the shell has no job > control. > > We could work around this in a rather ugly manner by doing something like= : > > #ifdef DARWIN_OS > if (pty_flag) > pid =3D fork (); > else > pid =3D vfork (); > #else > pid =3D vfork (); > #endif > > which would use fork where we=E2=80=99re expecting to run setsid, and vfo= rk > otherwise. > > -- > Alan Third