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: MPS: dangling markers Date: Fri, 28 Jun 2024 06:14:57 +0200 Message-ID: References: <87v81u85hv.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1282"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Ihor Radchenko , emacs-devel@gnu.org, Eli Zaretskii , eller.helmut@gmail.com To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jun 28 06:15:46 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 1sN31V-000Adb-SA for ged-emacs-devel@m.gmane-mx.org; Fri, 28 Jun 2024 06:15:45 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sN30q-000293-Hu; Fri, 28 Jun 2024 00:15:04 -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 1sN30o-00028u-Vh for emacs-devel@gnu.org; Fri, 28 Jun 2024 00:15:03 -0400 Original-Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sN30n-0001it-4d; Fri, 28 Jun 2024 00:15:02 -0400 Original-Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-52ce9ba0cedso228703e87.2; Thu, 27 Jun 2024 21:15:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719548099; x=1720152899; darn=gnu.org; h=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=43rsWHBbbdeeyc7pmNoLKuLBUm7AyRkMpNNBhpGv94A=; b=fQzMqdx/2pNBXNB/xCHCEQw5q3svON+WzptBAETy8drp0PzDgv5HYsyWkfwJ2pJebG JAXaxIdqqXxtLRwESS/FKssoyuoOheyR5TX1g7dTVm6Wdt662mhdKVvBmMA/EfPYxCVP H0htiCZks98wptHouFZIiGyvUKy//Oa1IAMW51/mQ53pCqn35sLVDdYlnpOitRu9YuWj vqeMhfcqGZozQGuxuR84ekRqokBMVgTVI3dGQPzGsp6/quyS9Sr01l0nLoIcd1FalQFw UCM0ezGHX9CiN38i/dqAzErHk70akl4J1NZTBudqXmbA//2IWFN2vLAzZq55Qjd/7p5C EEXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719548099; x=1720152899; h=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=43rsWHBbbdeeyc7pmNoLKuLBUm7AyRkMpNNBhpGv94A=; b=bjUmZfoni0TA/7kddxLo+f/IqcbgPV0ZFU/ADxkh9K1eLRbJrXci8LpxrOOydwK9Hf uheKgRcRzxCX4AzTzxZ4UxU6aJXNX3bQL+qc/4R1uum2TI0rOVLtX5Id86noYSSuV0ch hL8gQoO3zHgUUVmFu/5k9tqx7mTGR1GTsVbpYDGTbOfkJy/rEFDb2J2r+iw3evs0FPxT 1x7rslYiGJ0sn+5UgN0s9RRckeERmojzbLHLaXSgmmNnPzUITggDS4zh2HauWbfYNn08 L/F4uIM8KvWV10jcudkIyNYYo6UyguUbm0bAbvgUdN/L9NoB+tGuvfbVJcA7d1xO/r7i lz8Q== X-Forwarded-Encrypted: i=1; AJvYcCVEDVi2x0NAjeQtlFnTipy/YJ67HXBwn+5cOq0CYMgEXlbkN0SakvV0x4pInQb+5UL/57PrSWWPzlw3qvKN/2DKFqMs18r4BRvZGU1qE/SRKTc= X-Gm-Message-State: AOJu0Yx8fBBofXuurW/elElfLl9ZnhwHs1doSRfjCffFsDaP3pK35Al5 L20yyZymL3LsuQJAJMeJ6WRuf0A4sA+zIVYv31d0fglcsl5Y8FlYD6U1hQ== X-Google-Smtp-Source: AGHT+IFfOSWF6mqZBtaueKOjN9tia4L0935awseVJog0PYdI99a6NFdkhwlEhF4p7zHg8ILhHGcsBQ== X-Received: by 2002:ac2:5609:0:b0:52c:dea7:f0db with SMTP id 2adb3069b0e04-52ce1832b34mr11066207e87.23.1719548098808; Thu, 27 Jun 2024 21:14:58 -0700 (PDT) Original-Received: from pro2.fritz.box (pd9e360da.dip0.t-ipconnect.de. [217.227.96.218]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aaf6339bsm37141666b.80.2024.06.27.21.14.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 21:14:58 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Thu, 27 Jun 2024 17:24:26 -0400") Received-SPF: pass client-ip=2a00:1450:4864:20::12f; envelope-from=gerd.moellmann@gmail.com; helo=mail-lf1-x12f.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:320794 Archived-At: Stefan Monnier writes: >> - perf points to (1) itree lookup; (2) bytepos<->charpos, which implies >> that things may be related to the number of allocated markers and >> overlays. >> - I observe things slowing down as the number of "PVEC_MARKER" in the >> output of `igc-info' grows. >> - Forcing (igc--collect) returns speed to normal > [...] >> AFAIK, at least overlays, buffers, and markers are used in C code within >> object lists/trees are often traversed in full. If objects in these >> lists are not regularly garbage-collected, we may end up in situation >> when dead objects significantly impact performance. > > AFAIK, markers are the only one that can be reachable (i.e. we may > spend time looking at them) yet GC-able, because the buffers' `markers` > slot contains a linked-list of all markers that's treated specially by > the GC (basically, the list is "weak" so markers get removed from this > list during GC if the marker is reachable only from the list). Exactly. > [ Of course, similar things can occur with other objects via our weak > hash table. And there are a few other "background cleanups" we do in > GC (such as resizing gaps or truncating undo logs) which could be > impacted as well. ] (FWIW, in igc, I'm trying to do these things incrementally when idle, Weaj hash tables are currently not implemented. I can't bring me to do that.) > So I'm not surprised by your point (2) above, but I don't have an > explanation for your point (1), OTOH. Would be interesting to so some profiler output showing in which context these itree operations happen. > BTW, a lof of C and ELisp code is careful to delete markers after their > use, so I suspect that a large proportion of the "dead" markers that can > accumulate in the list of markers are those created by the chars<->bytes > conversion code (as a memoization cache), and we should be able to > decouple their collection from the GC by simply adding a bit that says > this is just a cached result of a previous chars<->bytes conversion, > rather than a true marker object, and then we could have a "background > task" that flushes them as needed. That might be a way, yes. In igc I could try to do that in on_idle, incrementally, or even in another thread (not the Emacs ones).