From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Gerd_M=C3=B6llmann?= Newsgroups: gmane.emacs.devel Subject: Re: Some experience with the igc branch Date: Mon, 23 Dec 2024 21:49:02 +0100 Message-ID: References: <87o713wwsi.fsf@telefonica.net> <87ldw7fwet.fsf@protonmail.com> <87a5cnfj8t.fsf@protonmail.com> <86seqe4j4f.fsf@gnu.org> <87ttaucub8.fsf@protonmail.com> <87pllicrpi.fsf@protonmail.com> <864j2u442i.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4780"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: pipcet@protonmail.com, ofv@wanadoo.es, emacs-devel@gnu.org, eller.helmut@gmail.com, acorallo@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 23 21:49:48 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tPpN3-00010w-Qd for ged-emacs-devel@m.gmane-mx.org; Mon, 23 Dec 2024 21:49:45 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tPpMT-0004wr-OB; Mon, 23 Dec 2024 15:49:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tPpMS-0004wJ-8D for emacs-devel@gnu.org; Mon, 23 Dec 2024 15:49:08 -0500 Original-Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tPpMQ-0004hw-OQ; Mon, 23 Dec 2024 15:49:08 -0500 Original-Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-aaedd529ba1so147797566b.1; Mon, 23 Dec 2024 12:49:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734986944; x=1735591744; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=feOH5gnQLso5Ft9VF/gAOxiHzmeNNY7RymFhMIdEg1w=; b=QuSMbhoycYstUU4PycV8S5pWXg1Vxq4HUreYADCorn11f5+kqe0sdPw448pExG/Wxj KvtxaMew72qhZMBKFR3zRmL09wRchJbQrSSAbgroAXnx7w9+PZ34a3wG3T9tfZCphYlN QSKHUOa0DttX2YCeP7KY6o7EmGAxwrd8rijVIWHCJYP98Xgv75zDvN+vChZgTotxPiRZ hdwVeBzDwd80/foUf8YahukX5Qgi4VT0um9YMuwf2CXznf9bWGrmLdd+0l5HpnYHgW5h PJVS+I/g4KCygNPZ0kgyM8dcoOu7tI9hsJFUYEtEYnYcjtjeqTmQRuv5JbQZvvmZB1mq nXJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734986944; x=1735591744; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=feOH5gnQLso5Ft9VF/gAOxiHzmeNNY7RymFhMIdEg1w=; b=b1MWIyV2n10d3nub39LHdv827Ybgu8fDDQE104gtdfLCqCEN02RUOYxNeMTRyCXPbv iZkDsebJ77alUNjODfAW9VTNiYwvuv4Ww1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:348d:b0:5d4:55e:f99e with SMTP id 4fb4d7f45d1cf-5d81ddc09abmr31539011a12.18.1734986943451; Mon, 23 Dec 2024 12:49:03 -0800 (PST) Original-Received: from pro2 (p200300e0b728c00045f88d4d4db0c1e7.dip0.t-ipconnect.de. [2003:e0:b728:c000:45f8:8d4d:4db0:c1e7]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aac0eae4369sm561125066b.87.2024.12.23.12.49.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 12:49:03 -0800 (PST) In-Reply-To: <864j2u442i.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 23 Dec 2024 21:00:53 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=gerd.moellmann@gmail.com; helo=mail-ej1-x62b.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:326935 Archived-At: Eli Zaretskii writes: >> From: Gerd M=C3=B6llmann >> Cc: Eli Zaretskii , ofv@wanadoo.es, emacs-devel@gnu.org, >> eller.helmut@gmail.com, acorallo@gnu.org >> Date: Mon, 23 Dec 2024 18:44:42 +0100 >>=20 >> BTW, do you know which signal handlers use Lisp, i.e. allocate Lisp >> objects or access some? All? Or, would it be realistic to rewrite signal >> handlers to not do that? > > SIGPROF does (it's the basis for our Lisp profiler). > > SIGCHLD doesn't run Lisp (I think), but it examines objects and data > structures of the Lisp machine (those related to child processes). > >> One thing I've seen done elsewhere is to publish a message to a message >> board so that it can be handled outside of the signal handler. Something >> like that, you know what I mean. > > This is tricky for the profiler, because you want to sample the > function in which you are right there and then, not some time later. > > For SIGCHLD this could work, but it might make Emacs slower in > handling subprocesses (there are some Lisp packages that fire > subprocesses at very high rate). Thanks. I've looked at SIGPROF. From an admittedly brief look at this, I'd summarize my results as: - The important part is get_backtrace. The rest could be done elsewhere by posting that to a message board, or whatever the mechanism is at the end. - Didn't see get_backtrace or functions called from it allocating Lisp objects. - It reads from a Lisp object because of #define specpdl (current_thread->m_specpdl) #define specpdl_end (current_thread->m_specpdl_end) #define specpdl_ptr (current_thread->m_specpdl_ptr) current_thread is a struct thread_state which is a PVEC_THREAD. - I remember that I wrote a scanner for the specpdl stacks, so that's not a Lisp object but a root, so no problem here, I think. - struct thread_state allocation is done in igc.c via alloc_immovable in igc_alloc_pseudovector. That allocated from from an AMS pool, which doesn't use barriers. - It doesn't seem to access other Lisp objects except current_thread. That doesn't look bad, I think. Worth mentioning is perhaps that directly after get_backtrace here static void record_backtrace (struct profiler_log *plog, EMACS_INT count) { log_t *log =3D plog->log; get_backtrace (log->trace, log->depth); EMACS_UINT hash =3D trace_hash (log->trace, log->depth); we access Lisp objects in trace_hash when computing the hash and in the other hash table code. IIUC that code counts hits with the same backtrace. Don't know how long that takes. But if posting the backtrace would take the same time, we would be on par. I'll try to also look at SIGCHLD at some later point, but Christmas, family etc. Happy holidays!