From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Sebastien Chapuis Newsgroups: gmane.emacs.devel Subject: Re: State of the overlay tree branch? Date: Wed, 21 Mar 2018 15:14:18 +0100 Message-ID: <87y3iltt1h.fsf@chapu.is> References: <834lldp18f.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1521641582 31972 195.159.176.226 (21 Mar 2018 14:13:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 21 Mar 2018 14:13:02 +0000 (UTC) User-Agent: mu4e 0.9.19; emacs 27.0.50 Cc: Sebastian Sturm , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Mar 21 15:12:57 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eyeU3-0008AL-I4 for ged-emacs-devel@m.gmane.org; Wed, 21 Mar 2018 15:12:56 +0100 Original-Received: from localhost ([::1]:55388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyeW4-0000uk-W4 for ged-emacs-devel@m.gmane.org; Wed, 21 Mar 2018 10:15:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eyeVW-0000uQ-4T for emacs-devel@gnu.org; Wed, 21 Mar 2018 10:14:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eyeVT-0004ld-3g for emacs-devel@gnu.org; Wed, 21 Mar 2018 10:14:26 -0400 Original-Received: from mail-wr0-x232.google.com ([2a00:1450:400c:c0c::232]:33338) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eyeVS-0004l5-Tl for emacs-devel@gnu.org; Wed, 21 Mar 2018 10:14:23 -0400 Original-Received: by mail-wr0-x232.google.com with SMTP id z73so5357096wrb.0 for ; Wed, 21 Mar 2018 07:14:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chapu-is.20150623.gappssmtp.com; s=20150623; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=SxO/1ObYa74gS1sFRolI3J4RgyoSgzIESIAJpHifzIM=; b=15Jje+3HaZQ9hLavIAMeUreOQFRzc/keb1n3fpLhwVXMfg4wVfOUFdKtMZMk1cYtMU GXIwUWV5Dk+q8uWEDCKk+hehIdUHAtSZIlVlC5gID594qWGfLSzluRoG9pwa7+vueiFZ YfX4Q80kzAOgDzoHw/FmdyYAPco3CpTCzzXfqk2vt63nEb/hjbQlHGjZ+Q+eZ38V4saW UEFWQ9XuEtFJgKSTTbCTepXNzPN13E64L+NFnpy0icWXVaWiCXUaAVZ54RHSujp8UM5o zEj02kpomVog2yagCTfXJWrx8xyd2D5vR4uYqCpJmj9bz4/s6zJrU8FpNx9a2CS8jOxT /ntw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=SxO/1ObYa74gS1sFRolI3J4RgyoSgzIESIAJpHifzIM=; b=ZAWGxyaWkmRpVk//tnbk17FX1XsiVnfyH9gEIecg7JOeZFBsK/p3nhNMNB2Bw12rr2 dK97I2qmd2muTVzW+Yp5FfBcacEk71h3OC6A7fRV/FeyYIOVcWc0N3q1i8qLvUJJ3XOV Zcj5ghmcDBvrNXctyQz1uV2TZfjOXcJXgQS0HeU9fHQQPrv5skr6UAzRJN8pplL15LzT eHk9Jpco+lBdP0MTdL/T7GtYCgHwJIt9JcmIuzV8GY2O1RpXJe2ygF/rLTPUaAhYRc0w a9q9xxTIdjO97r2GPVqr921L01d4xAWTKP4mGuP66ARupT3mdFNGFWCWVRcF27pFXtex 7Ppg== X-Gm-Message-State: AElRT7Gt2VqqmAKDhvoF46c1EAOAnkPvOiJYpxaw9SJOd6R9ZbxMXtm/ 6v6edDXboCvxDgKAzARues1eaW/dVCg= X-Google-Smtp-Source: AG47ELtIWWEz69WdtwSqzxaKTDVMVf/EDBPI5lxT+p9NvaWh6o9jPtDFPiJd6N6S3qfjeRPZ7eO/rw== X-Received: by 10.223.196.132 with SMTP id m4mr18010966wrf.9.1521641661410; Wed, 21 Mar 2018 07:14:21 -0700 (PDT) Original-Received: from XPS13 (188.226.99.84.rev.sfr.net. [84.99.226.188]) by smtp.gmail.com with ESMTPSA id o88sm4493441wrb.44.2018.03.21.07.14.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Mar 2018 07:14:20 -0700 (PDT) In-reply-to: <834lldp18f.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::232 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:223891 Archived-At: Eli Zaretskii writes: >> From: Sebastian Sturm >> Date: Sun, 18 Mar 2018 21:14:53 +0100 >> >> [1] I'm using cquery for my C++ editing needs, which comes with an >> overlay-based semantic highlighting mechanism. With my emacs >> configuration, lsp-mode/lsp-ui emit 6 calls to line-number-at-pos per >> character insertion, which consume ~20 to 25 ms each when performing >> edits close to the bottom of a 66KB C++ file (measured using >> (benchmark-run 1000 (line-number-at-pos (point))) on a release build of >> emacs-27/git commit #9942734...). Using the noverlay branch, this figure >> drops to ~160us per call. > > If lsp-mode/lsp-ui needs a fast line counter, one can easily be > provided by exposing find_newline to Lisp. IME, it's lightning-fast, > and should run circles around count-lines (used by line-number-at-pos). > > (I'm not sure I even understand how overlays come into play here, > btw.) The language server protocol defines a position in file with zero-indexed line and column offsets [1]: ``` interface Position { line: number; character: number; } ``` lsp-mode uses heavily line-number-at-pos to convert an Emacs buffer point to a LSP position, and vice-versa [2]. This can happen thousands times on each keystroke. If Emacs could provide a function to do the conversion very fast (or at least faster than with line-number-at-pos), it would be great. [1] https://github.com/Microsoft/language-server-protocol/blob/gh-pages/specification.md#position [2] The conversion from a LSP position to point doesn't use line-number-at-pos, but forward-line and forward-char. It's still very slow. -- Sebastien Chapuis