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: MPS: weak hash tables Date: Sat, 06 Jul 2024 11:47:58 +0200 Message-ID: <878qye3l81.fsf@gmail.com> References: <-plQctKgNkvp-LJ9ov2QAiXQKxd9V-hI0yz_opRGxQtbknubCjH4rH2-ymgbw_Qr1ZhB1rtlmiEW8XtuIVNr7nR_Yj20AH6WkH6kUGp68g0=@protonmail.com> <_mNcR6ailVKpYHLxgfo_tJlYGeR0AQIzQWluspYYp5_g5pIIKkHLNfFkklQQgOKNiVW8jn8NS3i2dJ7_B2Qyx9v-Dq3MQ9mP8HNL30UWsqY=@protonmail.com> <878qyf4sgm.fsf@gmail.com> 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="14135"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Pip Cet , Eli Zaretskii , Emacs Devel To: Gerd =?utf-8?Q?M=C3=B6llmann?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jul 06 11:48: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 1sQ22H-0003Z6-MP for ged-emacs-devel@m.gmane-mx.org; Sat, 06 Jul 2024 11:48:53 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQ21V-0001ZZ-4Z; Sat, 06 Jul 2024 05:48:05 -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 1sQ21T-0001Yn-Ue for emacs-devel@gnu.org; Sat, 06 Jul 2024 05:48:04 -0400 Original-Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sQ21S-0007Qv-4s; Sat, 06 Jul 2024 05:48:03 -0400 Original-Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-42660b8dd27so1122925e9.3; Sat, 06 Jul 2024 02:48:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720259280; x=1720864080; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ja1PQjSub69KdnHsfji5DySKj39zqHfjWrppzj9AqIk=; b=gKldCkiEchN6FnULLO8KTPfrBag+HpnoILf7f0OYRS4vBjBiu+skr0xPlEgYdGGQva H1Fuq/gO95+gbZ/JflPnEO/UpkCDYs5k8l25VLQ7qSAM7WNBrwCHk7+7dmZSkgEj1hg+ t5RoXSNOxUn9fTKCYA9XwAks5yCldBYWzaTijicqykHJxgNoLTukfCkmmW3I14VChKUl d3s9uo5a4MN5RVjV6zAOGY+0TP5WFNQZcpbwJJzsH3vD1ejJNVG3FCaHygzqFMP8ViJX bwmYtk4JRDErYPYiQ6X1ByyXulJI5JbhxwvrHBFImDXDNlqeT8GZXyrLuwjHZQNWW4gv 5Vgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720259280; x=1720864080; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ja1PQjSub69KdnHsfji5DySKj39zqHfjWrppzj9AqIk=; b=QnQqHlixEXtJ1GLS1QGklrk5NXJvmmpyFwHPSPBypYKcutZ7LoZqRXdMSvfyWJ6RW7 fOYe7qCtyHg2z9F+2CaMupFuLPn774cRZ4HmMwOVWHJDVSiXFu3wN62lyJbXd0WYXNug DcqRSUzHOOFMeIgI3mDfXUWkRtQtS0iDxsQ1Wkiu1dlSpbDnT2SgHysS5X6dwdoXoXP5 a0Me6qtqI5ef8av+DQz75Jd1Fm5yhOpoJMS1l4ZQwbZleC1QYQDX5JtHicr7vjveYvFX UAEBoEMkPoQaU9FSx5Yc3ncyLboisqxb09LZ1Ss7m6+SIhfL8iYVvsvS2qF1CK+joIhu hnGw== X-Forwarded-Encrypted: i=1; AJvYcCVuvVaqana8MY4AR814aOkLF9aGfpvIVyLBIJaaJNDRdf8egdHhbl1YdscJ/XSnotCqX29x6rxAKRErg2bWhWmknZJ6YLLRqq8s1FkHjcxPeCY= X-Gm-Message-State: AOJu0YxsZuzLVmOzkbKHvpOFC01vFRZsi6u5EZZrqcLpPBJXvavJzpd3 SJBV7mIlsygIxcg0u5nldOmhmwubI/ZlKKTrcMwkQhGgm81+QvDNVeiw9g== X-Google-Smtp-Source: AGHT+IFNa2fH3s1oo7dwFHcMpwG6Rsrj9G5oM5RNQXEdkcFgyaG7THnE8u8dmR+UJZTZX4bfB8uL6g== X-Received: by 2002:a05:600c:63c4:b0:425:6207:12b4 with SMTP id 5b1f17b1804b1-4264a3e79cbmr52103325e9.24.1720259279960; Sat, 06 Jul 2024 02:47:59 -0700 (PDT) Original-Received: from caladan (dial-190152.pool.broadband44.net. [212.46.190.152]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4264a2519a4sm89245885e9.35.2024.07.06.02.47.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jul 2024 02:47:59 -0700 (PDT) In-Reply-To: ("Gerd =?utf-8?Q?M=C3=B6llman?= =?utf-8?Q?n=22's?= message of "Sat, 06 Jul 2024 05:38:01 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=eller.helmut@gmail.com; helo=mail-wm1-x32c.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:321416 Archived-At: On Sat, Jul 06 2024, Gerd M=C3=B6llmann wrote: >> ert-tests.el worries me the most. There, MPS looks pretty bad compared >> to the old GC. (Who would have thought that printing backtraces >> involves copying and rebalancing interval trees with thousands of nodes? >> And why does it perform so poorly with a generational GC?) > > Hm, sounds almost like a bug to me. The bug being the copying. Why does > it do that, do you know? One reason may be that something tries to remove invisible text with buffer-substring. That needs to copy part of the interval tree. But the copying happens for both, the MPS and the non-MPS version. When I run perf record ../src/emacs -Q --batch -l lisp/emacs-lisp/ert-tests.el --eval '(ert-run-tests-batch-and-exit "ert-test-\\(parse\\|plist\\|record\\|run-tests-batch-exp\\)")' =20 then the top entries in the perf output for the MPS version looks like: 9.55% emacs emacs [.] balance_an_interval 5.46% emacs emacs [.] amcSegFix 5.20% emacs emacs [.] exec_byte_code 3.71% emacs emacs [.] _mps_fix2 3.10% emacs emacs [.] fix_lisp_obj 2.81% emacs emacs [.] SegSetGrey 2.37% emacs emacs [.] shieldQueue 2.29% emacs emacs [.] SegFix 2.24% emacs emacs [.] is_dflt_fwd 2.07% emacs emacs [.] alloc_impl 2.02% emacs emacs [.] dflt_scan_obj.constprop.0 and the non-MPS version: 19.63% emacs emacs [.] balance_an_interval 10.22% emacs emacs [.] exec_byte_code 9.73% emacs emacs [.] process_mark_stack 3.04% emacs emacs [.] next_interval 2.42% emacs emacs [.] sweep_intervals 2.26% emacs emacs [.] Fmemq 2.16% emacs emacs [.] find_interval 2.05% emacs emacs [.] Fcons So balance_an_interval is pretty high in both, but it seems that the GC related part is quite a bit bigger for the MPS version. Maybe it has something to do with memory barriers. >> It would be nice to have a way to set a "memory limit". Preferably with >> some "out of memory error". Even aborting would be better than starting >> to swap. > > There is > > MPS_KEY_COMMIT_LIMIT (type size_t) is the maximum amount of main memory, > in bytes (1), that the MPS will obtain from the operating system. See > mps_arena_commit_limit() for details. The default commit limit is the > maximum value of the size_t type. > > Never tried that. There are also functions to read/set the limit, so > maybe we could introduce a DEFVAR with variable watcher for playing with > it, or a function. When I add MPS_ARGS_ADD (args, MPS_KEY_COMMIT_LIMIT, 1 << 30); to make_arena then make lisp/emacs-lisp/ert-tests aborts with trace.c:1088: Emacs fatal error: assertion failed: band !=3D RankWEAK || = rank =3D=3D band This looks like a bug. >> I also think that something needs to be done about the pidigits >> benchmark. It's not about the bignums (which I couldn't care less >> about) but the problem that finalization messages are only processed >> when Emacs is idle. > > Hm, so this one didn't help. > > void > garbage_collect (void) > { > #ifdef HAVE_MPS > igc_process_messages (); > #endif > > Looks like it needs to be put somewhere else. I think finalize_bignum is ever called for something like this: ./src/emacs -Q -batch -eval ' (dotimes (_ 10000000) (set (quote foo) (ash most-positive-fixnum 10000)))'