From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Elisp native profiler Date: Mon, 01 Oct 2012 23:12:45 +0200 Message-ID: <834nmdc2wi.fsf@gnu.org> References: <83zk4egs0w.fsf@gnu.org> <83y5jygrni.fsf@gnu.org> <50620443.8050301@cs.ucla.edu> <20120926151625.229ef3cc9caf90e5098b18ef@cx4a.org> <20121001014217.03ac31a69b9b43516cb0dd61@cx4a.org> <50689C1D.8080005@cs.ucla.edu> <5068AEE2.4080004@cs.ucla.edu> <5068F696.7040600@cs.ucla.edu> <83txueb63s.fsf@gnu.org> <5069C7C1.7040206@cs.ucla.edu> <83a9w6axlk.fsf@gnu.org> <838vbqax9p.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1349125975 802 80.91.229.3 (1 Oct 2012 21:12:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 1 Oct 2012 21:12:55 +0000 (UTC) Cc: tomo@cx4a.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org To: eggert@cs.ucla.edu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 01 23:12:58 2012 Return-path: Envelope-to: ged-emacs-devel@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 1TInIH-00064D-Ce for ged-emacs-devel@m.gmane.org; Mon, 01 Oct 2012 23:12:49 +0200 Original-Received: from localhost ([::1]:59795 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TInIB-0004O2-R3 for ged-emacs-devel@m.gmane.org; Mon, 01 Oct 2012 17:12:43 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:41095) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TInI8-0004Nx-Tc for emacs-devel@gnu.org; Mon, 01 Oct 2012 17:12:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TInI7-0006Kl-O8 for emacs-devel@gnu.org; Mon, 01 Oct 2012 17:12:40 -0400 Original-Received: from mtaout23.012.net.il ([80.179.55.175]:55942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TInI7-0006Kb-FW for emacs-devel@gnu.org; Mon, 01 Oct 2012 17:12:39 -0400 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0MB800A00FZU5R00@a-mtaout23.012.net.il> for emacs-devel@gnu.org; Mon, 01 Oct 2012 23:12:37 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MB8009L4G91XC80@a-mtaout23.012.net.il>; Mon, 01 Oct 2012 23:12:37 +0200 (IST) In-reply-to: <838vbqax9p.fsf@gnu.org> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 80.179.55.175 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:153878 Archived-At: > Date: Mon, 01 Oct 2012 19:59:46 +0200 > From: Eli Zaretskii > Cc: eggert@cs.ucla.edu, tomo@cx4a.org, monnier@iro.umontreal.ca, emacs-devel@gnu.org > > Actually, I take this back: I'm quite sure the problem is that the > handler is quite expensive. The proof: when the user types > "M-x profiler-stop RET", the timer thread does not exit, it continues > to run, sleeping 30 ms at a time, then awakens, sees that the timer is > disabled, and goes back to sleep. So almost the whole thread loop is > executed, except suspending/resuming the main thread and calling the > handler. The difference in terms of CPU usage is tremendous, though: > zero CPU usage. > > So either suspending/resuming a thread takes a lot of time, or the > handler, or both. The truth is neither. I timed the code with a high-resolution timer and found a bug. After fixing it, the CPU usage while profiling is zero (not visible on the CPU graph). Also, it turns out that calling the SIGPROF handler takes about 10 usec, half of it to suspend and resume the main thread.