From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.devel Subject: Re: Optimizing performance of buffer markers Date: Sun, 26 Jun 2022 12:32:51 +0200 Message-ID: <87y1xjvhnw.fsf@gmail.com> References: <2c2746e5f2558a87e8eab6f0914264a020173a9d.camel@pm.me> <27630AA3-8026-4E24-8852-ACCD9325B99D@gmail.com> <0E9E702B-B07C-4794-8498-29B9320E14CC@gmail.com> <871qvorqvv.fsf@localhost> <83tu8jq2vl.fsf@gnu.org> <87sfo37etn.fsf@localhost> <834k0jplcm.fsf@gnu.org> <878rpuwm9w.fsf@localhost> <83mteao3oj.fsf@gnu.org> <87edzmv3i0.fsf@localhost> <83k09eo1p5.fsf@gnu.org> <878rpuv17q.fsf@localhost> <83fsk2nyrm.fsf@gnu.org> <878rpr4kd4.fsf@localhost> <8335fzms6q.fsf@gnu.org> <87wndar5tt.fsf@localhost> <831qvikxqo.fsf@gnu.org> <87edzdwdqt.fsf@localhost> 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="16159"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , casouri@gmail.com, emacs-devel@gnu.org To: Ihor Radchenko Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jun 26 12:33:42 2022 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 1o5PaH-000410-IZ for ged-emacs-devel@m.gmane-mx.org; Sun, 26 Jun 2022 12:33:41 +0200 Original-Received: from localhost ([::1]:53922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5PaG-0005dH-33 for ged-emacs-devel@m.gmane-mx.org; Sun, 26 Jun 2022 06:33:40 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5PZY-0004jB-6k for emacs-devel@gnu.org; Sun, 26 Jun 2022 06:32:56 -0400 Original-Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:45051) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o5PZW-000479-MI; Sun, 26 Jun 2022 06:32:55 -0400 Original-Received: by mail-wm1-x32f.google.com with SMTP id m32-20020a05600c3b2000b0039756bb41f2so3917783wms.3; Sun, 26 Jun 2022 03:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:gmane-reply-to-list:date:in-reply-to :message-id:mime-version:content-transfer-encoding; bh=gi74JuIUlPwo234Xav/uJQ1Bal5bnt6alFP02yGAvNc=; b=T6bldpLBK1HhXuvbJxOr3un2tKTmFzacONlHeNf9wCifDJbRGgtacptRVXUz+xDbjO /iyCXmuUu/wq6ocdZcGxnWqK0vkwD+sSV3xEWl8oX4vMjDyhDMj+kJFBLqeyhe5uX+9G Wbv4kziV8rpS5cwykfIK/q+PB6ltZzw7zKVTjokVXEHr3xPkUgTVA1kBjYcO+DmScepL HzBDgTxcKeL8E22LotPZhPk/EHPQ/XJax8TZZ42/o4qk1xaA+q6D/15NgbxN7dUYVwlM EZuuqoVdYT9WFcJ3/k+qqJZG7Uswe72qy3Opk2FMxyTu62ZZHVPiSyjhNmLAjYOFu+FS Zakg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references :gmane-reply-to-list:date:in-reply-to:message-id:mime-version :content-transfer-encoding; bh=gi74JuIUlPwo234Xav/uJQ1Bal5bnt6alFP02yGAvNc=; b=TvHNXPf43UkT7o7SMYM5v9cq0Fgfi8emwubeyfPx+lGellXPxPFq3wy2FYv4Bv3vhf gEFAvszFkxlnLWAsQWb/sdbVcbaD1r/fWedEFJ9Hr6vKQUStr2qxQLEeCFYsYh9NEo13 hYsXX/rzNeJfaPdhTkk1ym9XfNBO99khzHc+8GNpRMLfQ5fQOQ7QS/9I4sFPjmZsqcOs jBh+WZMTMxnL8UqRm5S2C9wvQw8Mzmhr8p2URxrJEpI0gcd+EqtFovv0P6L4q5E/Wdgu leu/DkkqIQ+Qp25LQ693dfHo5uWvvMZ+fPc3cXKgWxIDFLyHQk1D0w3YOzorNvA6EHDM M42Q== X-Gm-Message-State: AJIora9v+/HTERKkmW1dSIUH3thGcSihPf/5bDWRUxwcKSgP5m/8XFlQ D/vcNbgGDDIGa6foYUk/+tt37Nzi18c= X-Google-Smtp-Source: AGRyM1un3/pwg3CcXD1UjoD9NKzyo3GVF2Pu1SenG5CJhGhLZ9/Elex+uqrnqnT372FUHJOR4LAeNg== X-Received: by 2002:a05:600c:1e8f:b0:3a0:312f:e93 with SMTP id be15-20020a05600c1e8f00b003a0312f0e93mr13978795wmb.194.1656239572541; Sun, 26 Jun 2022 03:32:52 -0700 (PDT) Original-Received: from rltb ([2a01:e0a:3f3:fb50:c1a6:7d68:210a:3b8d]) by smtp.gmail.com with ESMTPSA id m17-20020adfe0d1000000b0021b866397a7sm7512265wri.1.2022.06.26.03.32.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jun 2022 03:32:52 -0700 (PDT) Gmane-Reply-To-List: yes In-Reply-To: <87edzdwdqt.fsf@localhost> (Ihor Radchenko's message of "Sat, 25 Jun 2022 12:47:38 +0800") Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=rpluim@gmail.com; helo=mail-wm1-x32f.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, T_SCC_BODY_TEXT_LINE=-0.01 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" Xref: news.gmane.io gmane.emacs.devel:291629 Archived-At: >>>>> On Sat, 25 Jun 2022 12:47:38 +0800, Ihor Radchenko said: Ihor> AFAIU, buf_bytepos_to_charpos tries to search for the closest mar= ker Ihor> near the requested bytepos. It currently does it using the follow= ing Ihor> heuristics (roughly): Ihor> (let ((threshold 50)) Ihor> (dolist (marker markers) Ihor> (if (or (< (abs (- marker bytepos)) threshold) Ihor> (< (abs (- nearest_previous_marker bytepos)) threshold)) Ihor> (throw 'found marker) Ihor> (cl-incf threshold 50)))) Ihor> If we store markers in a hash table, there will be no benefit - H= ash Ihor> table will only allow to find marker at exact position, not nearb= y. We could use (charpos / 50) as the key to the hash table, and then store a list of markers as the value(s). Of course you'd have to update the hash table every time a marker is added, deleted, or changes charpos, so I don=CA=BCt know if it would be a win. Robert --=20