From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: MPS: weak hash tables Date: Sat, 06 Jul 2024 09:46:23 +0300 Message-ID: <86le2f5874.fsf@gnu.org> References: <_mNcR6ailVKpYHLxgfo_tJlYGeR0AQIzQWluspYYp5_g5pIIKkHLNfFkklQQgOKNiVW8jn8NS3i2dJ7_B2Qyx9v-Dq3MQ9mP8HNL30UWsqY=@protonmail.com> <878qyf4sgm.fsf@gmail.com> <4JQ7mGAwBrGOLmq0SzqnMOSkzoEFxTOfGHxGzJ8fa48FMVlfasV4QTPgE3E8yidy4XXamrIt3gg9Lv_TSJkOO5IIz4VDmygEtBAEsvhIusM=@protonmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37149"; mail-complaints-to="usenet@ciao.gmane.io" Cc: gerd.moellmann@gmail.com, eller.helmut@gmail.com, emacs-devel@gnu.org To: Pip Cet Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jul 06 08:47:27 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 1sPzCf-0009R6-QB for ged-emacs-devel@m.gmane-mx.org; Sat, 06 Jul 2024 08:47:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sPzBp-0001ps-EG; Sat, 06 Jul 2024 02:46:33 -0400 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 1sPzBj-0001pX-9O for emacs-devel@gnu.org; Sat, 06 Jul 2024 02:46:29 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sPzBi-0003EX-Sr; Sat, 06 Jul 2024 02:46:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=hi81hOqYawQ2k99LWVtxDbG7O82I75j7wb18QCnntn4=; b=mMT7Ax/cVn9u n7f/K4Fuj4ggxrbaahQS7LZ+olo2TEgv8vL71Do7Xi9GbOvDRE0hGNGouK3ZJmCQX8dWMJpLwobkC zyftB0/NQdG7nUlJxgWSfXTTrVtgTMrMWamcuNcHQHTrnyH2fnFQXWvJfZxnZp1yJolOvlN50vwag DicOh7ck8uWxYyi8mknnKHw/p7CQHRxXiysAegs6N5tTnxt8KPHFsP5U7tSn1xb7MnbLKpDS5ghOm WroilqFPHrSSJ2M++yESTCCIbJeShp4tR8Uy39rugb9qOxK5wh/OewjLAlId1Kz7LOFQ0AJRms/oG UKzVcagRZcOWhtbffjE9Ew==; In-Reply-To: <4JQ7mGAwBrGOLmq0SzqnMOSkzoEFxTOfGHxGzJ8fa48FMVlfasV4QTPgE3E8yidy4XXamrIt3gg9Lv_TSJkOO5IIz4VDmygEtBAEsvhIusM=@protonmail.com> (message from Pip Cet on Sat, 06 Jul 2024 05:58:19 +0000) 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:321409 Archived-At: > Date: Sat, 06 Jul 2024 05:58:19 +0000 > From: Pip Cet > Cc: Helmut Eller , Eli Zaretskii , Emacs Devel > > > > What I'm doing right now is alternating usleep(10000) and > > > igc_collect() in a secondary thread. That crashes somewhat > > > reproducibly in interactive sessions. > > > > Could you please make that available in some form? > > Sure. I was thinking about cleaning it up (usleep is non-standard) and committing it behind a stress-test option, actually. > > Right now it's dying because specpdl is a union type and GC might hit while the main thread leaves it in a partially-initialized state. I vaguely recall turning it into a struct for that reason on another branch years ago... > > Pip > > diff --git a/src/igc.c b/src/igc.c > index f154a040a0e..be2b9fb719e 100644 > --- a/src/igc.c > +++ b/src/igc.c > @@ -4820,6 +4820,16 @@ igc_busy_p (void) > return mps_arena_busy (global_igc->arena); > } > > +static void * > +igc_thread_fun (void *addr) > +{ > + while (true) > + { > + usleep (5000); > + igc_collect (); > + } > +} > + > /*********************************************************************** > Init > ***********************************************************************/ > @@ -4830,6 +4840,8 @@ init_igc (void) > mps_lib_assert_fail_install (igc_assert_fail); > global_igc = make_igc (); > add_main_thread (); > + pthread_t thr; > + pthread_create (&thr, NULL, igc_thread_fun, global_igc); > set_state (IGC_STATE_USABLE_PARKED); > } Thanks, but why is this important or interesting? We are not going to add native threads to Emacs. Also, AFAIU, MPS docs says to register each thread with it, and your code doesn't, AFAICT.