From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jonas Hahnfeld via "Developers list for Guile, the GNU extensibility library" Newsgroups: gmane.lisp.guile.devel Subject: Re: GC + Java finalization Date: Sat, 03 Jul 2021 19:26:00 +0200 Message-ID: <665d5bf795575a076321e7de74bef00023ae9355.camel@hahnjo.de> References: Reply-To: Jonas Hahnfeld Mime-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-aUe2iA3Tb839vbmnp5fe" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16192"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.40.2 To: Maxime Devos , guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sat Jul 03 19:26:23 2021 Return-path: Envelope-to: guile-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 1lzjPK-0003wJ-OS for guile-devel@m.gmane-mx.org; Sat, 03 Jul 2021 19:26:22 +0200 Original-Received: from localhost ([::1]:41214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lzjPJ-0001Pr-CM for guile-devel@m.gmane-mx.org; Sat, 03 Jul 2021 13:26:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzjP8-0001Pj-Bc for guile-devel@gnu.org; Sat, 03 Jul 2021 13:26:10 -0400 Original-Received: from backus.hahnjo.de ([2a03:4000:2a:2c1::1]:45936 helo=mail.hahnjo.de) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lzjP6-0002yl-1O for guile-devel@gnu.org; Sat, 03 Jul 2021 13:26:10 -0400 Original-Received: from [IPv6:2a01:cb15:40c:c100:cf0a:528a:fee7:c993] (unknown [IPv6:2a01:cb15:40c:c100:cf0a:528a:fee7:c993]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.hahnjo.de (Postfix) with ESMTPSA id 29C124BC2BFC; Sat, 3 Jul 2021 19:26:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=hahnjo.de; s=default; t=1625333164; bh=0FVAKjHEBrvmr0oaOIQOTGONnAQHjjLoJK48HErH7ck=; h=Subject:From:To:Date:In-Reply-To:References; b=F3Ci/cTcxOlFYqxeZ924Ul9cXaf5mcgwwONGL2SI+9iWU1CA1dUAvbDyU8Yzt7YIo Q4LfdyWwmSD9TGPyTt64rkacO1EyOUrPRdnXNisw8M+ZGfDwwA12Uf9Df5I0BZp4TD v4cqaELSUbpXU8bPNG6ydNGeUjek5gWVfprkj2HzOQGgk0Y8PYyhKjBRIw6F8gH8Pn heUTefqEN0d4fuZoN3bEna01R5+Ci/7xiGAmSmuNJC7Kginf+IfqHof2uLEfA6kDzJ HsQ0BATBvVx552Rb340y5PghOhJUmapQZDcIxETEHpqnxR9Az1t4TZOmnXZnniASn0 ckh/bkLcGDyhg== In-Reply-To: Received-SPF: pass client-ip=2a03:4000:2a:2c1::1; envelope-from=hahnjo@hahnjo.de; helo=mail.hahnjo.de 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.io gmane.lisp.guile.devel:20797 Archived-At: --=-aUe2iA3Tb839vbmnp5fe Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Am Samstag, dem 03.07.2021 um 19:14 +0200 schrieb Maxime Devos: > Jonas Hahnfeld via Developers list for Guile, the GNU extensibility libra= ry schreef op za 03-07-2021 om 14:05 [+0200]: > > Hi Guile devs, > >=20 >=20 > Hi, I'm not really a Guile dev but I'll respond anyway. >=20 > > I'm hacking on GNU LilyPond and recently wondered if Guile could run > > without Java finalization that prevents collection of chains of > > unreachable objects. >=20 > Do you have an example where this is a problem? > I.e., did you encounter =E2=80=98chains of unreachable objects=E2=80=99 t= hat were > uncollectable, and so, where? Sorry, I should have been clearer: Chains don't become uncollectable, but a chain of N objects takes N collections to be completely reclaimed (because Java finalization prepares for the possibility that a free function makes an object live again, as Guile does for guardians). This leads to unnecessary waste on the heap, and more work for the collector (even though I haven't been able to measure so far). >=20 > > I found that the functionality is only needed once > > the first guardian is created, so it's possible to delay enabling the > > mode until then. This required some fixes to free functions that > > assumed dependent objects to be freed only later (see first two > > patches). > > The third patch delays ensuring Java finalization to scm_make_guardian, > > but doesn't disable it explicitly (it's on by default in bdwgc). This > > could now be done right after GC_INIT(), but it's not clear (at least > > to me) whether client applications actually rely it, so I think it's > > better if that's not done in Guile itself. > >=20 > > Please consider applying, the fixes potentially also to stable-2.2. > >=20 > > Thanks > > Jonas >=20 > I would need to look more closely at how =E2=80=98Java-style=E2=80=99 fin= alisation > works. Some comments anyway: >=20 > (first patch) >=20 > > * test-suite/standalone/test-smob-mark.c > > (init_smob_type): Correct size of smob type. > > (free_x): Clear smob data instead of local variable. > > (test_scm_smob_mark): Put smobs in array to ensure marking. > >=20 > > - fprintf (stderr, "FAIL: SMOB mark function called for each SMOB\= n"); > > + // Print pointer so it cannot be collected before. > > + fprintf (stderr, "FAIL: SMOB mark function called for each SMOB = (smobs =3D %p)\n", smobs); > > exit (EXIT_FAILURE); >=20 > Normally scm_remember_upto_here is used for that. I think I tried, but it wasn't available. Or I mistyped, not sure. > Also, I believe "/* */"-style comments are used customarily used in Guile > instead of "//"-style comments. >=20 > > static void > > init_smob_type () > > { > > - x_tag =3D scm_make_smob_type ("x", sizeof (x_t)); > > + x_tag =3D scm_make_smob_type ("x", sizeof (x_t *)); >=20 > This change seems to be a fix independent of the =E2=80=98do we want Java= -style finalization=E2=80=99 > question. Yes, that's why it's a separate patch. >=20 > (third patch) >=20 > Note that guardians are used in (ice-9 popen). > They are also used by some guile libraries (e.g. guile-fibers), > so you can't use (ice-9 popen) or any library using guardians > if Java-style finalization is undesirable. Yes, I'm aware and that's why any constructed guardian force-enables Java finalization. But applications might not use it, and at least for LilyPond I'm sure it's not used. Jonas --=-aUe2iA3Tb839vbmnp5fe Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEXw/5YGpL6H9VOgO2kcnDPSxhrNsFAmDgnagACgkQkcnDPSxh rNssRQf/araTVXUJFFZcqROUjDZK0irJK9lMd7G3bWefQ9RyQgE6rdkqym/r9ZWV ihBWZStWZ9GamX34NsC5eahlLIec69L43Pj+KaHviYdZhJXdpuY+glJUyTtgcFRm xGfaDCqVFgeFPYmJtl2s3CSidiR4jaRt0a4CflwU5omaRU9Yk0Y24pJ8iL4YVt7X CxGChVMUN9YEXbEqb08ahax6bacNISbuowQD/bB7ybG2bD0ahsfUrO5KO/tk7Oaf XOcRhlH/FuwCPqGN8/BKqIskbGWCLwZ3OXHS9wMRHCCRwu2ZgU9lMBDixVvKMjma UkndbYB0sENiWGyikb8HxK7i57ZfwQ== =dVfg -----END PGP SIGNATURE----- --=-aUe2iA3Tb839vbmnp5fe--