From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: stephen_leake@stephe-leake.org Newsgroups: gmane.emacs.bugs Subject: bug#18626: 24.3.94; communication with subprocess is slow Date: Sat, 04 Oct 2014 01:47:16 -0500 Message-ID: <85wq8ge3gr.fsf@stephe-leake.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1412405307 21535 80.91.229.3 (4 Oct 2014 06:48:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 4 Oct 2014 06:48:27 +0000 (UTC) To: 18626@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Oct 04 08:48:21 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XaJ8c-00067N-RI for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Oct 2014 08:48:19 +0200 Original-Received: from localhost ([::1]:42765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XaJ8c-0003AO-HY for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Oct 2014 02:48:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60476) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XaJ8T-0003AH-Gn for bug-gnu-emacs@gnu.org; Sat, 04 Oct 2014 02:48:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XaJ8M-00052d-P7 for bug-gnu-emacs@gnu.org; Sat, 04 Oct 2014 02:48:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40917) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XaJ8M-00052X-Ln for bug-gnu-emacs@gnu.org; Sat, 04 Oct 2014 02:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XaJ8M-0002RO-8L for bug-gnu-emacs@gnu.org; Sat, 04 Oct 2014 02:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: stephen_leake@stephe-leake.org Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Oct 2014 06:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 18626 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14124052709363 (code B ref -1); Sat, 04 Oct 2014 06:48:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Oct 2014 06:47:50 +0000 Original-Received: from localhost ([127.0.0.1]:60714 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XaJ89-0002Qw-EE for submit@debbugs.gnu.org; Sat, 04 Oct 2014 02:47:50 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:58713) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XaJ84-0002Ql-SU for submit@debbugs.gnu.org; Sat, 04 Oct 2014 02:47:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XaJ7x-000508-I3 for submit@debbugs.gnu.org; Sat, 04 Oct 2014 02:47:44 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:50099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XaJ7x-0004zu-Fn for submit@debbugs.gnu.org; Sat, 04 Oct 2014 02:47:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XaJ7r-00038H-FT for bug-gnu-emacs@gnu.org; Sat, 04 Oct 2014 02:47:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XaJ7l-0004ym-H9 for bug-gnu-emacs@gnu.org; Sat, 04 Oct 2014 02:47:31 -0400 Original-Received: from dnvrco-outbound-snat.email.rr.com ([107.14.73.231]:29533 helo=dnvrco-oedge-vip.email.rr.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XaJ7l-0004xx-9B for bug-gnu-emacs@gnu.org; Sat, 04 Oct 2014 02:47:25 -0400 Original-Received: from [70.94.38.149] ([70.94.38.149:65431] helo=TAKVER) by dnvrco-oedge01 (envelope-from ) (ecelerity 3.5.0.35861 r(Momo-dev:tip)) with ESMTP id AD/24-23176-BF79F245; Sat, 04 Oct 2014 06:47:24 +0000 X-RR-Connecting-IP: 107.14.64.118:25 X-Authority-Analysis: v=2.1 cv=d8V7yHTE c=1 sm=1 tr=0 a=AppmJ/7ZOOFWL/q6u6u93g==:117 a=AppmJ/7ZOOFWL/q6u6u93g==:17 a=ayC55rCoAAAA:8 a=o_R75loqY_IA:10 a=9i_RQKNPAAAA:8 a=mDV3o1hIAAAA:8 a=anS06UpnrWyEo4AEdXoA:9 a=Jzz0AodKLsosewV1:21 a=xogqCaehYc11Grr6:21 X-Cloudmark-Score: 0 X-detected-operating-system: by eggs.gnu.org: BaiduSpider X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:94111 Archived-At: This may be related to http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18420 I've run into another problem with Emacs communication with external processes; there seems to be a delay on every task switch. This shows up both when sending data to the subprocess, and when reading from it. When sending the contents of an Emacs buffer (source code to be parsed) to the subprocess, if the read buffer in the subprocess is large enough to hold the entire contents, no delay is apparent. However, if the buffer is smaller, so that several reads are needed, then a delay appears. Similarly when sending data from the subprocess to Emacs. To measure the delay: (defun pipe-torture (exe &rest args) "" (let ((proc (apply 'start-process "pipe-reader" "pipe-read" exe args)) start-time) (unless (process-live-p proc) (error "process died")) (setq start-time (time-to-seconds (current-time))) (process-send-region proc (point-min) (point-max)) (message "send time %f" (- (time-to-seconds (current-time)) start-time)) )) (find-file "emacs-24.3.94/src/xdisp.c") (pipe-torture "cat.exe") => 11.255173 The time varies slightly with each run. "cat.exe" here is from Cygwin. For comparison, in a Cygwin bash shell on the same system: $ cd /tmp $ time cat < /Projects/emacs/emacs-24.3.94/src/xdisp.c > xdisp.c real 0m0.051s user 0m0.000s sys 0m0.030s Doing (setq process-adaptive-read-buffering nil) did not change the timing. To show the effect of changing the number of subprocess reads, here is a trivial Ada program that reads from stdin into a buffer whose size is set from the command line, and does no writes: with Ada.Command_Line; with GNAT.OS_Lib; procedure Debug is use GNAT.OS_Lib; Chunk : constant Integer := Integer'Value (Ada.Command_Line.Argument (1)); File : constant File_Descriptor := GNAT.OS_Lib.Standin; Read_Bytes : Integer; Text : aliased String (1 .. Chunk); begin loop Read_Bytes := Read (File, Text'Address, Chunk); exit when Read_Bytes < Chunk; end loop; end Debug; in xdisp.c: (pipe-torture "debug.exe" "4096") 4.797574 (pipe-torture "debug.exe" "40000") 0.523758 The test with "debug.exe" can also be run in Emacs 24.3.1, since it does not mix reads and writes (see bug 18420); it gives a time comparable to the command-line "cat": 0.053000 To show the delay on reading subprocess output: (defun pipe-torture-read (file) "" (let ((proc (apply 'start-process "pipe-reader" "pipe-read" (list "bash" "-c" (concat "cat < " file)))) start-time) (unless (process-live-p proc) (error "process died")) (setq start-time (time-to-seconds (current-time))) (while (process-live-p proc) (accept-process-output proc)) (message "read time %f" (- (time-to-seconds (current-time)) start-time)) )) In emacs 24.3.94: (pipe-torture-read "/Projects/emacs/emacs-24.3.94/src/xdisp.c") "read time 11.965184" In Windows native emacs 24.3.1: (pipe-torture-read "/Projects/emacs/emacs-24.3.94/src/xdisp.c") "read time 11.992000" In GNU Emacs 24.3.94.1 (x86_64-pc-mingw32) of 2014-10-04 on TAKVER Windowing system distributor `Microsoft Corp.', version 6.1.7601 Configured using: `configure --prefix=/mingw32' Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: cp1252 Major mode: Text Minor modes in effect: diff-auto-refine-mode: t display-time-mode: t delete-selection-mode: t tooltip-mode: t electric-indent-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent input: C-s a d a M-x b u g - r e p o r t r e p o r Recent messages: Loading c:/Projects/emacs_stephe.work/emacs_stephe/stephe_settings.el (source)...done For information about GNU Emacs and the GNU system, type C-h C-a. Loading c:/Projects/org.emacs.dvc.stephe/dvc-load.el (source)...done Loading c:/Projects/emacs_stephe.work/emacs_stephe/dvc-patches.el (source)... Loading c:/Projects/emacs_stephe.work/emacs_stephe/vc-mode-keys.el (source)...done Loading c:/Projects/emacs_stephe.work/emacs_stephe/dvc-patches.el (source)...done Package iswitchb is obsolete! Mark saved where search started Function xmtn-match--generate-branch is already compiled Function xmtn-match--contains-match-variable-p is already compiled Load-path shadows: /Projects/org.emacs.ada-mode.stephe-1/ada-mode hides c:/Projects/emacs/emacs-24.3.94/lisp/progmodes/ada-mode Features: (shadow sort mail-extr emacsbug sendmail xmtn-dvc dvc-status dvc-diff dvc-fileinfo diff-mode xmtn-conflicts xmtn-ids xmtn-match xmtn-automate xmtn-compat parse-time xmtn-run xmtn-basic-io xmtn-base misearch multi-isearch xgit-core bzr-core xmtn-minimal dvc-log log-edit message format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev mail-utils gmm-utils mailheader pcvs-util vc vc-dispatcher ediff-merg ediff-wind ediff-diff ediff-mult ediff-help ediff-init ediff-util ediff dvc-unified dvc-tips ffap thingatpt url-parse auth-source eieio byte-opt bytecomp byte-compile cconv eieio-core gnus-util mm-util help-fns mail-prsvr password-cache url-vars add-log dvc-autoloads dvc-core dvc-lisp dvc-buffers dvc-ui dvc-register dvc-utils dvc-emacs ewoc dvc-defs dvc-site time delsel cus-start cus-load color-theme cl-macs edmacro kmacro wid-edit cl gv cl-loaddefs cl-lib noutline outline easy-mmode iswitchb whitespace dired-x dired-aux dired compile comint ansi-color ring info easymenu bbdb-autoloads package epg-config time-date tooltip electric uniquify ediff-hook vc-hooks lisp-float-type mwheel dos-w32 ls-lisp w32-common-fns disp-table w32-win w32-vars tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process w32notify w32 multi-tty emacs) Memory information: ((conses 8 260868 6068) (symbols 32 28706 0) (miscs 32 46 139) (strings 16 49862 6082) (string-bytes 1 1215255) (vectors 8 19963) (vector-slots 4 495165 5152) (floats 8 177 242) (intervals 28 289 12) (buffers 512 13))