From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Slawomir Nowaczyk Newsgroups: gmane.emacs.devel Subject: Re: Running two processes rapidly makes Emacs eat 100% CPU on w32 Date: Thu, 12 Oct 2006 15:52:20 +0200 Message-ID: <20061012145009.C39D.SLAWOMIR.NOWACZYK.847@student.lu.se> References: <20061012102127.C37F.SLAWOMIR.NOWACZYK.847@student.lu.se> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1160661252 19597 80.91.229.2 (12 Oct 2006 13:54:12 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 12 Oct 2006 13:54:12 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 12 15:54:07 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GY0zd-0001FK-KG for ged-emacs-devel@m.gmane.org; Thu, 12 Oct 2006 15:53:02 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GY0zd-0005vy-4g for ged-emacs-devel@m.gmane.org; Thu, 12 Oct 2006 09:53:01 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GY0zB-0005j0-1l for emacs-devel@gnu.org; Thu, 12 Oct 2006 09:52:33 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GY0z9-0005iM-VJ for emacs-devel@gnu.org; Thu, 12 Oct 2006 09:52:32 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GY0z9-0005iH-OY for emacs-devel@gnu.org; Thu, 12 Oct 2006 09:52:31 -0400 Original-Received: from [130.235.16.11] (helo=himmelsborg.cs.lth.se) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GY17N-00008I-Sj for emacs-devel@gnu.org; Thu, 12 Oct 2006 10:01:02 -0400 Original-Received: from [127.0.0.1] (slawek@dain [130.235.16.76]) by himmelsborg.cs.lth.se (8.13.6/8.13.6/perf-jw-tr) with ESMTP id k9CDqSXm028209 for ; Thu, 12 Oct 2006 15:52:29 +0200 (CEST) Original-To: emacs-devel@gnu.org In-Reply-To: X-Esmandil_Citation: done X-Mailer-Plugin: Popup Memopad for Becky!2 Ver.0.02 Rev.2 X-Mailer: Becky! ver. 2.25.02 [en] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:60663 Archived-At: On Thu, 12 Oct 2006 06:47:19 -0400 Eli Zaretskii wrote: #> > Date: Thu, 12 Oct 2006 10:44:48 +0200 #> > From: Slawomir Nowaczyk #> >=20 #> > What is the best way to debug such problem? #>=20 #> Try to figure out what happens inside w32proc.c:sys_select would be a #> beginning, I think. There are already quite a few DebPrint statements #> in that function; compiling with EMACSDEBUG defined will activate #> them. You should be able to see the strings emitted by DebPrint with #> any debugger; or you can install DbgView as a lightweight solution. Thanks for the advice, I managed to activate DebPrint. I have added one which prints the return value of w32proc:sys_select, and it is "1" consistently. None of the DebPrint statements already present in this function gets executed, neither in normal work nor when Emacs eats all the CPU. Your guess that sys_select is to be blamed was likely correct, though, as (under normal circumstances) my newly added DebPrint executes a couple of times per second, while after I execute the problematic code, it gets called thousands of times per second. There were two DebPrint statements guarded by FULL_DEBUG, but I have activated those as well. Now the one from line 1175: DebPrint (("select waiting on child %d fd %d\n", cp-child_procs, i)); keeps printing "select waiting on child 0 fd 3" (thousands of times per second, every time sys_select is called. Anyway, the log of DebPrints looks like this: return 1 ;; this part corresponds= to correctly working emacs return 1 =2E.. return 1 ;; there are a couple (1= -10) of those per second return 1 ;; now I executed (progn= (start-process "" nil "ls") (call-process "ls")) "select waiting on child 0 fd 3" "select calling SIGCHLD handler for pid 1668" ;; observe that this lin= e only happens ONCE return 1 =20 "select waiting on child 0 fd 3" ;; and this repeats, tho= usands of times per second return 1 ;; I got about 40.000= of those in 7 seconds "select waiting on child 0 fd 3" return 1 =2E.. "select waiting on child 0 fd 3" return 1 #> Once you have this in place, add DebPrint as needed to see what is #> going on there. w32proc:sys_select is much too complex for me to understand quickly. I will try to look at the code and do some more debugging tomorrow evening if I have time... In the meantime, if anyone has any ideas as to where would be a good place to put some DebPrint statements, I would be grateful. --=20 Best wishes, Slawomir Nowaczyk ( slawomir.nowaczyk.847@student.lu.se ) I plan on living forever. So far, so good.