From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.devel Subject: Re: SIGPROF + SIGCHLD and igc Date: Fri, 27 Dec 2024 09:08:00 +0100 Message-ID: <87a5ch5z1b.fsf@gmail.com> 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="3463"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , pipcet@protonmail.com, ofv@wanadoo.es, emacs-devel@gnu.org, acorallo@gnu.org To: Gerd =?utf-8?Q?M=C3=B6llmann?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 27 09:08:53 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 1tR5Ou-0000o5-SN for ged-emacs-devel@m.gmane-mx.org; Fri, 27 Dec 2024 09:08:52 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tR5OC-0007oc-Ni; Fri, 27 Dec 2024 03:08:08 -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 1tR5OA-0007oN-EA for emacs-devel@gnu.org; Fri, 27 Dec 2024 03:08:06 -0500 Original-Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tR5O8-0002TW-Vv; Fri, 27 Dec 2024 03:08:06 -0500 Original-Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-aa6b4cc7270so1025896766b.0; Fri, 27 Dec 2024 00:08:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735286883; x=1735891683; 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=2udHtmuWt5c+uy1juoIkYhnzeTiFa5PJ9MnHbHiGhMk=; b=eH92NWCD3ziZSX8+CaBjMjeE72A6gxp81/omUCQtFIZ1MnbhNadZp9ORmbHzEYgehT 1a9YV45KysWqJUm1XnRITNFmNxGmZl+HsoGPjDEDenAU5WwWYGlrVxMZbrOQ9c+pyB4s OwogMB42S3hZ9z7a07hWZitydwubBXN6f/wg58vZuqrf6nlFusY0aGWxPeDA+cIkyFVH 3bX9YN+KrXrcovpUI+c29UC2QGj7YBjbEOaDSD9V0oYE+Ma/O2Vm0nUWF4ovMojP8P8T chtSND4uYJ8b6nrvtvBPtWQF/ltiQcU+HKZkJ9vv8qjU26dqdl5RMYGFofvSyf741Lhg iVPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735286883; x=1735891683; 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=2udHtmuWt5c+uy1juoIkYhnzeTiFa5PJ9MnHbHiGhMk=; b=OpWn6gEM36m+7LkbnJbaxcZPgSYGWMZ/2k3XXCB/QK0uRze77ifzwyJLOvye3P6QMM +NabK6I90z9nQqbnjUTjoGYppJeXfgshKAGqfAuGeslrHipr7/yW39Lz7mzm1tmlEtCA HyfbS0HGdtbCoaJl9uizQJ/rchLQUYjwpbPeNjfHAR2e5ez7y6Wn7CpkNuFa4ZzJ0cNB sjWuDFmqWCLGXF9cIaWUfiIqvp1Wq22lMLAm8sTXq9gdr40v9GGo5s23yCFL/ANyWiIm uMRu8GNjHOAYt1SJpSbKcew/qM58C0nUusuImUF3MfjogxdaAduKdDB2Opm8kioYMpkn nI1A== X-Forwarded-Encrypted: i=1; AJvYcCXAV7GIEgRji4II3nVjS+Xe0vL0p7YCDDQhz0eCQR7FYOz9ACfV+6m2FJ/AnXyZSFxZk8KMa4La0EKSV14=@gnu.org, AJvYcCXdJETOzce6NlAF8IW/T3zhXANT1Rh68bfMPnsUMQoMnAIv2D+fyY5PQbMcIuDjSxk8NAqWCKx1Ag==@gnu.org X-Gm-Message-State: AOJu0YwIZEV2R9FueAceiTPUuZfChlgIam0Gl4yIW0FcSHJRcRDW8Cbo xuoKD+FHYWJKiOLiZ6wPxzhsqYHGQmukPRlQpKuNXEN2J24CG8WfEIChZgMC X-Gm-Gg: ASbGncsizc9SyeLarpXH2RyBIkgF7vVGVliyUfEcgnMYOjtDpcS1BJldzHt+tGbwTD+ 8ljqgAAir4lWeoBeKO/X6MBH7tQUEu/frQWLRb/ApfJN4fY0t9mF+yBh0mQPQeYIWmLx6RHdptK i5IJ4tH4t3234Bp33YG5luNwOp66HgHxFHWsUN64Quh/onN6D1xhUg7iRIFMOXYWA5Xjtu4MXil pnQwaO+s82yxfGKOPOTlDoL8sBulDZurARYPYMM9kTbbpeZGUAQPx4= X-Google-Smtp-Source: AGHT+IFPIFPATIWiYuHZW8LbulHyfCG2KXCPo5wDwUSZHRPyBiLrgleBggsdmeS1Gs5s135q4mVOhQ== X-Received: by 2002:a05:6402:358c:b0:5d0:8f1c:d9d7 with SMTP id 4fb4d7f45d1cf-5d81dd83b30mr67510252a12.4.1735286882425; Fri, 27 Dec 2024 00:08:02 -0800 (PST) Original-Received: from caladan ([31.177.115.143]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d806fedbbasm10796933a12.71.2024.12.27.00.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Dec 2024 00:08:01 -0800 (PST) In-Reply-To: ("Gerd =?utf-8?Q?M=C3=B6llmann?= =?utf-8?Q?=22's?= message of "Tue, 24 Dec 2024 07:03:53 +0100") Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=eller.helmut@gmail.com; helo=mail-ej1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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:327176 Archived-At: On Tue, Dec 24 2024, Gerd M=C3=B6llmann wrote: >> 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. I have an idea how to make a safer profiler. First, remember that MPS will stop mutator threads to protect its own consistency. What happens if we make the profiler its own thread? MPS will stop the profiler like normal mutator threads. This is useful and is as it should be. The problem now is how the profiler thread can do what get_backtrace does. We can use a protocol between the profiler thread and the main thread that goes like this: 1. The profiler periodically sends a signal, say SIGPROF, to the main thread. 2. In the signal handler for SIGPROF, the main thread synchronizes itself with the profiler by communicating over a pipe (like the Unix fathers did it). It sends some token to the profiler and waits. 3. The profiler receives the token and can now access the virtual machine state because the main thread waits. The profiler now does what get_backtrace does. After logging the stack snapshot, the profiler sends the token back to the main thread 4. The main thread receives the token, returns from the signal handler, and continues execution. Note that the signal handler only communicates over the pipe and doesn't read or write any memory that could mess up MPS. The profiler thread doesn't run any signal handlers (other than those that MPS may use behind the scenes). Another observation: MPS sends SIGXFSZ and SIGXCPU to stop and resume threads. We could intercept those signals and block SIGPROF while the thread is stopped. Obviously a hack, but could still be useful. Helmut