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: Sat, 29 Jun 2024 20:52:48 +0200 Message-ID: References: <87v81u85hv.fsf@localhost> <87frsx81m2.fsf@localhost> <87cyo180y2.fsf@localhost> <874j9d7zqe.fsf@localhost> <87sewvg6lw.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="40640"; 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 Sat Jun 29 20:53:48 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 1sNdCm-000AN8-6r for ged-emacs-devel@m.gmane-mx.org; Sat, 29 Jun 2024 20:53:48 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sNdBv-0006fl-VE; Sat, 29 Jun 2024 14:52:55 -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 1sNdBu-0006fc-6e for emacs-devel@gnu.org; Sat, 29 Jun 2024 14:52:54 -0400 Original-Received: from mail-ed1-x52b.google.com ([2a00:1450:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sNdBs-0006M1-I9; Sat, 29 Jun 2024 14:52:53 -0400 Original-Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-57cc1c00ba6so2279017a12.1; Sat, 29 Jun 2024 11:52:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719687170; x=1720291970; 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=extViaNGdc5zAwt5KTsOpea7E7kubF3lh1TC06YthQw=; b=CNyC78wjw0WIrZa8rrFShabphvXPYI/UH5u0PokfduApb8bVRg/gd1R+Oydqkx9uhr IqoMMxl8aPdxXFobGX3Lehv/+e86GIEgyQWkeinL2GUb9Qb/25vEOYJMpsrG9oCzyRDZ sL9p68k4PiDH6MRMZjvCGv7C+xcJq4ZS9z3RJKjXH/8spgBFsi92ioL0BYWbkAgaWrn9 QhtGzJrtw5QH2a/3Jle+Ssi8WXA/zywxusn3/wrl0gO2pGsE1F2HQHR2HvUyKIBcIcP6 eXURo3nFrm0GE7Rrje6oWfyyN2GbA0rD/mVX5cIPYRIhntYue3DL3OKVw62e76o1jjBO l65A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719687170; x=1720291970; 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=extViaNGdc5zAwt5KTsOpea7E7kubF3lh1TC06YthQw=; b=OEYguuD/RlTcg07zhV6pzwCYCAyr8fNyYUvNBbKi9FDf9XqFQaMaPYm1qDVNUenVKv BMK7YP8+glz63BzNmllzsM0bFKC2tzBur6JlFuLmKZlqKZoalruYU0pmJW6RyYce3I4V b2MvhgqEUgTGk+bp3EENuTUwR9s/2KchctKc6F0EPg0yqrO9UivRaceWOBinQCF5G8FI z2yWQ+J4YXoeKY50kSOaIAqhQ6Q27FktzBB+Utybru4GX+L7EtVsGkOUaALeGqKPHYpU jChbNSPjonyaBMikesFpzUmCF3Vf8foDeLbmDtGScXnAJzpEj9qEuPsz0WGjaF+LzMvP uY2g== X-Forwarded-Encrypted: i=1; AJvYcCX02u2/pwP3JT4eE7lFHTN0b4o5q6/KhLVyyYZFk+hJjzoXNcXxshFclfhRizIkUDLTul2zmutaOvKFyM7R1bkQRl8oe/W/ZH2UAehqvhiT4Qo= X-Gm-Message-State: AOJu0YxNLWwSPXctAKdjm3968x2JZ8ZiqOYfMpVtMiI0e8a+qqjnk4Zw UDw+czC3/FypbpzoSyaZKIF4UOGggz1x0NYFkzZhafqlwwH9m0aO X-Google-Smtp-Source: AGHT+IFDsTHA2cS1bSA7xz+8sPRIUbInSyNkwG4LmphMdN9PvHpNOJDxmV5XaGQfm2T/i3ZYD0x/4A== X-Received: by 2002:a17:907:e8d:b0:a72:685b:7c98 with SMTP id a640c23a62f3a-a751444c6a2mr138417166b.37.1719687169675; Sat, 29 Jun 2024 11:52:49 -0700 (PDT) Original-Received: from pro2.fritz.box (pd9e36598.dip0.t-ipconnect.de. [217.227.101.152]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a72aaf18c83sm183149866b.4.2024.06.29.11.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Jun 2024 11:52:49 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Sat, 29 Jun 2024 14:30:36 -0400") Received-SPF: pass client-ip=2a00:1450:4864:20::52b; envelope-from=gerd.moellmann@gmail.com; helo=mail-ed1-x52b.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:320883 Archived-At: Stefan Monnier writes: >> Can it be that `remove_marker` is called much more often than add_marker? > > I don't think you can remove a marker before having added it, so it > seems rather unlikely. > >> igc_add_marker (struct buffer *b, struct Lisp_Marker *m) >> { >> Lisp_Object v = BUF_MARKERS (b); >> if (NILP (v)) >> v = BUF_MARKERS (b) = alloc_vector_weak (1, Qnil); >> >> ptrdiff_t i = find_nil_index (v); > > My guess is that `find_nil_index` almost always scans the buffer until > near the end. It should be fairly easy to speed that up by keeping > a "pointer" to the last known empty slot, or use the empty slots to > "point to each other" to form a free-list. That could be an idea, indeed. > > Still doesn't explain why `remove_marker` takes more time on your branch > than on `master`, unless we end up keeping significantly larger vectors > than the length of the linked-lists used on `master`. > > Maybe it's because `unchain_marker` often exits early (e.g. maybe it's > common that `unchain_marker` is used to delete a marker recently added, > so it's near the top of the linked list which ends up behaving a bit > like a stack)? And that makes sense. I'll try tomorrow to add something to igc that Ihor can tell us how many markers there are that are allocated in the place Eli showed.