From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.bugs Subject: bug#10580: 24.0.92; gdb initialization takes more than one minute at 100% CPU Date: Fri, 11 May 2012 14:33:52 +0800 Message-ID: <8762c3z0of.fsf@gnu.org> References: <874nrsem67.fsf@gnu.org> <874nrswme9.fsf@gnu.org> <87zk9kv75l.fsf@gnu.org> <87mx5j6pqs.fsf@gnu.org> <877gwm3ajn.fsf@gnu.org> <83txzq1s4y.fsf@gnu.org> <837gwl1ckx.fsf@gnu.org> <87pqacrunj.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1336718117 8602 80.91.229.3 (11 May 2012 06:35:17 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 11 May 2012 06:35:17 +0000 (UTC) Cc: 10580@debbugs.gnu.org, schwab@linux-m68k.org To: Dov Grobgeld Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri May 11 08:35:15 2012 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 1SSjRW-00011W-0Q for geb-bug-gnu-emacs@m.gmane.org; Fri, 11 May 2012 08:35:10 +0200 Original-Received: from localhost ([::1]:52827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSjRV-0007FE-CF for geb-bug-gnu-emacs@m.gmane.org; Fri, 11 May 2012 02:35:09 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:50617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSjRN-0007Ax-Dd for bug-gnu-emacs@gnu.org; Fri, 11 May 2012 02:35:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SSjRL-0000sr-1V for bug-gnu-emacs@gnu.org; Fri, 11 May 2012 02:35:00 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53390) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSjRK-0000sm-UI for bug-gnu-emacs@gnu.org; Fri, 11 May 2012 02:34:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SSjRN-0004pj-Mj for bug-gnu-emacs@gnu.org; Fri, 11 May 2012 02:35:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Chong Yidong Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 11 May 2012 06:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10580 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10580-submit@debbugs.gnu.org id=B10580.133671805118523 (code B ref 10580); Fri, 11 May 2012 06:35:01 +0000 Original-Received: (at 10580) by debbugs.gnu.org; 11 May 2012 06:34:11 +0000 Original-Received: from localhost ([127.0.0.1]:47461 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SSjQX-0004oh-5l for submit@debbugs.gnu.org; Fri, 11 May 2012 02:34:10 -0400 Original-Received: from fencepost.gnu.org ([208.118.235.10]:47541 ident=Debian-exim) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SSjQT-0004oV-3p for 10580@debbugs.gnu.org; Fri, 11 May 2012 02:34:06 -0400 Original-Received: from [155.69.16.143] (port=38908 helo=ulysses) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1SSjQM-0006Mj-Kn; Fri, 11 May 2012 02:33:59 -0400 In-Reply-To: (Dov Grobgeld's message of "Thu, 10 May 2012 22:07:38 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.96 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:59930 Archived-At: --=-=-= Content-Type: text/plain Dov Grobgeld writes: > Here are the tests when using the the latest cvs gdb that yields a gdb > output file of about 800k. > > Without gdb-get-source-file-list override: ~139s > With gdb-get-source-file-list override: ~125s > > Thus it is clear that most of the time is taken just reading the > string into emacs. But doing find-file on the same file is almost > instantaneous. Here's another little experiment. Could you apply the two attached patches, individually, and see what difference each patch makes? (Again, with gdb-create-source-file-list at its default of t, and without any other patches to gdb-mi.el.) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=gdb-test-1.patch === modified file 'lisp/progmodes/gdb-mi.el' *** lisp/progmodes/gdb-mi.el 2012-04-20 10:09:40 +0000 --- lisp/progmodes/gdb-mi.el 2012-05-11 06:21:29 +0000 *************** *** 1918,1923 **** --- 1918,1925 ---- (gdb-ignored-notification . "=[-[:alpha:]]+,?\\(.*?\\)\n") (gdb-shell . "\\(\\(?:^.+\n\\)+\\)"))) + (defvar gdb-accumulator nil) + (defun gud-gdbmi-marker-filter (string) "Filter GDB/MI output." *************** *** 1928,1954 **** (> (length gdb-debug-log) gdb-debug-log-max)) (setcdr (nthcdr (1- gdb-debug-log-max) gdb-debug-log) nil))) ! ;; Recall the left over gud-marker-acc from last time ! (setq gud-marker-acc (concat gud-marker-acc string)) ;; Start accumulating output for the GUD buffer (setq gdb-filter-output "") - (let (output-record-list) ! ;; Process all the complete markers in this chunk. ! (dolist (gdbmi-record gdbmi-record-list) ! (while (string-match (cdr gdbmi-record) gud-marker-acc) ! (push (list (match-beginning 0) ! (car gdbmi-record) ! (match-string 1 gud-marker-acc) ! (match-string 2 gud-marker-acc) ! (match-end 0)) ! output-record-list) ! (setq gud-marker-acc ! (concat (substring gud-marker-acc 0 (match-beginning 0)) ! ;; Pad with spaces to preserve position. ! (make-string (length (match-string 0 gud-marker-acc)) 32) ! (substring gud-marker-acc (match-end 0)))))) (setq output-record-list (sort output-record-list 'gdb-car<)) --- 1930,1960 ---- (> (length gdb-debug-log) gdb-debug-log-max)) (setcdr (nthcdr (1- gdb-debug-log-max) gdb-debug-log) nil))) ! ;; Recall the left over output from last time ! (unless gdb-accumulator ! (setq gdb-accumulator (get-buffer-create " *gdb output accumulator"))) ! ! (with-current-buffer gdb-accumulator ! (goto-char (point-max)) ! (insert string)) ;; Start accumulating output for the GUD buffer (setq gdb-filter-output "") ! ;; Process all the complete markers in this chunk. ! (let (output-record-list marker) ! (with-current-buffer gdb-accumulator ! (dolist (gdbmi-record gdbmi-record-list) ! (goto-char (point-min)) ! (while (re-search-forward (cdr gdbmi-record) nil t) ! (setq marker (make-marker)) ! (set-marker marker (match-beginning 0)) ! (push (list marker ! (car gdbmi-record) ! (match-string 1) ! (match-string 2)) ! output-record-list) ! (replace-match "\n")))) (setq output-record-list (sort output-record-list 'gdb-car<)) *************** *** 1969,1976 **** (setq gdb-output-sink 'user) ;; Remove padding. ! (string-match "^ *" gud-marker-acc) ! (setq gud-marker-acc (substring gud-marker-acc (match-end 0))) gdb-filter-output)) --- 1975,1984 ---- (setq gdb-output-sink 'user) ;; Remove padding. ! (with-current-buffer gdb-accumulator ! (goto-char (point-min)) ! (while (re-search-forward "^\n" nil t) ! (replace-match ""))) gdb-filter-output)) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=gdb-test-2.patch === modified file 'lisp/progmodes/gdb-mi.el' *** lisp/progmodes/gdb-mi.el 2012-04-20 10:09:40 +0000 --- lisp/progmodes/gdb-mi.el 2012-05-11 06:32:52 +0000 *************** *** 1904,1923 **** (< (car a) (car b))) (defvar gdbmi-record-list ! '((gdb-gdb . "(gdb) \n") ! (gdb-done . "\\([0-9]*\\)\\^done,?\\(.*?\\)\n") ! (gdb-starting . "\\([0-9]*\\)\\^running\n") ! (gdb-error . "\\([0-9]*\\)\\^error,\\(.*?\\)\n") ! (gdb-console . "~\\(\".*?\"\\)\n") ! (gdb-internals . "&\\(\".*?\"\\)\n") ! (gdb-stopped . "\\*stopped,?\\(.*?\\)\n") ! (gdb-running . "\\*running,\\(.*?\n\\)") ! (gdb-thread-created . "=thread-created,\\(.*?\n\\)") ! (gdb-thread-selected . "=thread-selected,\\(.*?\\)\n") ! (gdb-thread-exited . "=thread-exited,\\(.*?\n\\)") ! (gdb-ignored-notification . "=[-[:alpha:]]+,?\\(.*?\\)\n") (gdb-shell . "\\(\\(?:^.+\n\\)+\\)"))) (defun gud-gdbmi-marker-filter (string) "Filter GDB/MI output." --- 1904,1925 ---- (< (car a) (car b))) (defvar gdbmi-record-list ! '((gdb-gdb . "^(gdb) \n") ! (gdb-done . "^\\([0-9]*\\)\\^done,?\\(.*?\\)\n") ! (gdb-starting . "^\\([0-9]*\\)\\^running\n") ! (gdb-error . "^\\([0-9]*\\)\\^error,\\(.*?\\)\n") ! (gdb-console . "^~\\(\".*?\"\\)\n") ! (gdb-internals . "^&\\(\".*?\"\\)\n") ! (gdb-stopped . "^\\*stopped,?\\(.*?\\)\n") ! (gdb-running . "^\\*running,\\(.*?\n\\)") ! (gdb-thread-created . "^=thread-created,\\(.*?\n\\)") ! (gdb-thread-selected . "^=thread-selected,\\(.*?\\)\n") ! (gdb-thread-exited . "^=thread-exited,\\(.*?\n\\)") ! (gdb-ignored-notification . "^=[-[:alpha:]]+,?\\(.*?\\)\n") (gdb-shell . "\\(\\(?:^.+\n\\)+\\)"))) + (defvar gdb-accumulator nil) + (defun gud-gdbmi-marker-filter (string) "Filter GDB/MI output." *************** *** 1928,1954 **** (> (length gdb-debug-log) gdb-debug-log-max)) (setcdr (nthcdr (1- gdb-debug-log-max) gdb-debug-log) nil))) ! ;; Recall the left over gud-marker-acc from last time ! (setq gud-marker-acc (concat gud-marker-acc string)) ;; Start accumulating output for the GUD buffer (setq gdb-filter-output "") - (let (output-record-list) ! ;; Process all the complete markers in this chunk. ! (dolist (gdbmi-record gdbmi-record-list) ! (while (string-match (cdr gdbmi-record) gud-marker-acc) ! (push (list (match-beginning 0) ! (car gdbmi-record) ! (match-string 1 gud-marker-acc) ! (match-string 2 gud-marker-acc) ! (match-end 0)) ! output-record-list) ! (setq gud-marker-acc ! (concat (substring gud-marker-acc 0 (match-beginning 0)) ! ;; Pad with spaces to preserve position. ! (make-string (length (match-string 0 gud-marker-acc)) 32) ! (substring gud-marker-acc (match-end 0)))))) (setq output-record-list (sort output-record-list 'gdb-car<)) --- 1930,1960 ---- (> (length gdb-debug-log) gdb-debug-log-max)) (setcdr (nthcdr (1- gdb-debug-log-max) gdb-debug-log) nil))) ! ;; Recall the left over output from last time ! (unless gdb-accumulator ! (setq gdb-accumulator (get-buffer-create " *gdb output accumulator"))) ! ! (with-current-buffer gdb-accumulator ! (goto-char (point-max)) ! (insert string)) ;; Start accumulating output for the GUD buffer (setq gdb-filter-output "") ! ;; Process all the complete markers in this chunk. ! (let (output-record-list marker) ! (with-current-buffer gdb-accumulator ! (dolist (gdbmi-record gdbmi-record-list) ! (goto-char (point-min)) ! (while (re-search-forward (cdr gdbmi-record) nil t) ! (setq marker (make-marker)) ! (set-marker marker (match-beginning 0)) ! (push (list marker ! (car gdbmi-record) ! (match-string 1) ! (match-string 2)) ! output-record-list) ! (replace-match "\n")))) (setq output-record-list (sort output-record-list 'gdb-car<)) *************** *** 1969,1976 **** (setq gdb-output-sink 'user) ;; Remove padding. ! (string-match "^ *" gud-marker-acc) ! (setq gud-marker-acc (substring gud-marker-acc (match-end 0))) gdb-filter-output)) --- 1975,1984 ---- (setq gdb-output-sink 'user) ;; Remove padding. ! (with-current-buffer gdb-accumulator ! (goto-char (point-min)) ! (while (re-search-forward "^\n" nil t) ! (replace-match ""))) gdb-filter-output)) --=-=-=--