From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.devel Subject: Re: Automatic (e)tags generation and incremental updates Date: Tue, 12 Jan 2021 18:48:24 +0200 Message-ID: References: <779a6328-9ca5-202a-25a2-b270c66fe6dd@yandex.ru> <8fc5e96c-ebb8-c668-9b2a-c7c4ee54c0b9@yandex.ru> <83r1mwltob.fsf@gnu.org> <0bee9ab4-46bc-b6fd-97b6-e26cc80f1610@yandex.ru> <875z45dbm7.fsf@tromey.com> <1e9c9572-52ee-339b-78a2-731b9eb5f3de@yandex.ru> <871resd93f.fsf@tromey.com> <83mtxffrou.fsf@gnu.org> <106abdbb-ce7a-4911-0831-149da3dccfb3@yandex.ru> <83o8hudwgo.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24697"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Cc: philipk@posteo.net, tom@tromey.com, emacs-devel@gnu.org, john@yates-sheets.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jan 12 17:50:59 2021 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 1kzMsl-0006Ha-16 for ged-emacs-devel@m.gmane-mx.org; Tue, 12 Jan 2021 17:50:59 +0100 Original-Received: from localhost ([::1]:45774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzMsk-0003o5-0U for ged-emacs-devel@m.gmane-mx.org; Tue, 12 Jan 2021 11:50:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56504) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzMqU-0002Qf-GE for emacs-devel@gnu.org; Tue, 12 Jan 2021 11:48:38 -0500 Original-Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]:40380) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kzMqQ-0003bq-2m; Tue, 12 Jan 2021 11:48:37 -0500 Original-Received: by mail-ed1-x52d.google.com with SMTP id h16so3051604edt.7; Tue, 12 Jan 2021 08:48:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=0YEjD726Y1gmVPqWmaNlQsFB1sihnspfiIc8MU81tSo=; b=P4Raf57L0Y9mGaPepdA948UfVUlkac6JpfBSFH6skBWK776DlPq07YySjqllJeoseu eXtSEelgFZ/dNti7+nhjb755BuQE+NVVykNzeyI8faYBSpLuHV39SnMxt83J9McjSuto jNqrc6i5qFTREuJ1TwylW6tud23e+ecnhWK1tOlAQNwfMDLx3a1E7ckJEoxCqUaJBFxn ds6b9GBqZKHxOWRXD/M9qF1UCiYpEEH2UTUIZig1TgQ5daLGd957w5ycLRus0l2jOdyg 3n/PsSPfaWpuQmF5kjM8tJ8U50/vFBB1Q6805sDy3OL2OeXDylklePwDXtKoNG/1JmCc rCpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=0YEjD726Y1gmVPqWmaNlQsFB1sihnspfiIc8MU81tSo=; b=dfc7ELKpatMgxI0O+xSFhI9InQroP9qK/hNUS2jniNHZ3+cU3TFMQNeZvnShevc8Wg 5TI6IYVpkLsV1DGIvhdQHpz4TH+dsakk++cFBifyZoQ3IFTzwyF2xOJZwhIvPTCHms4M I1ZipGisozYTmeNuyH/MmirGXCmISZCkWW0+v8zZ9xjUYjgMcsKPXy7L4Xhq3PCwEUVw 6ikhVooPZn02uQ2ezPuJBZleTzI3Py4Uleo899qenjn6/ezMVpuYMwEG7ER6E8Gmkq4v jeCe64ZNl/brwhCWgshlW0DM5LmfrEee4lwOCt5faVFqWoJ07CRPy7QkKX6fmdmWWO4o jebQ== X-Gm-Message-State: AOAM5325i0Qe6lKCSFfp4w++RmGlPZTSPaMouGleIQW+6vUJRf8/X7v7 CtWNjq5mpfKljPYo6VxM3+76kTcQxY3T8A== X-Google-Smtp-Source: ABdhPJyaP48MRXRkSq9+7LilBDPQ97WS3RyHuLgivI8f1r61cmRatjbtP4TlIt2TCIC8zscO+hs3pQ== X-Received: by 2002:aa7:cd44:: with SMTP id v4mr55393edw.156.1610470109028; Tue, 12 Jan 2021 08:48:29 -0800 (PST) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id ck27sm1702926edb.13.2021.01.12.08.48.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Jan 2021 08:48:27 -0800 (PST) In-Reply-To: <83o8hudwgo.fsf@gnu.org> Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=raaahh@gmail.com; helo=mail-ed1-x52d.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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:263001 Archived-At: On 12.01.2021 17:08, Eli Zaretskii wrote: >> Cc: tom@tromey.com, john@yates-sheets.org, philipk@posteo.net, >> emacs-devel@gnu.org >> From: Dmitry Gutov >> Date: Tue, 12 Jan 2021 03:33:10 +0200 >> >>>> (write-region (point-min) (point-max) buffer-file-name nil 'silent) >>>> >>>> I wonder if *that* could be done asynchronously. >>> >>> What kind of asynchronicity did you have in mind? >> >> One where the Lisp code doesn't have to wait for the disk write to >> complete. > > Wed don't have such facilities, because they would need locking the > region (actually, probably the entire buffer) for changes while it > runs. I'd be fine with that (or if this feature required the use of a separate thread, with the buffer locked to it in the meantime). But perhaps we could go with something simpler. >>> And I'm probbaly missing something, because I don't understand how >>> Emacs is involved in updating the tags table. >> >> It's part of the secret sauce for the quick incremental updates: if >> etags writes to disk, even just to update one file's index, we'll have >> to revert-buffer, and the bigger the tags file is, the longer the revert >> will take. Basically, N(project-size). > > But still faster than write-region, no? Did you try it the other way > around: let etags write to a file, and then revert, or even just > replace some region that you wanted updated (with > insert-file-contents)? With a 45 MB tags file visited: ;; If visited normally: (benchmark 1 '(revert-buffer t t)) ; => 1.49 s (benchmark 1 '(write-region 1 (point-max) buffer-file-name)) ; => 0.45 s ;; If visited literally: (benchmark 1 '(revert-buffer t t)) ; => 1.37 s (benchmark 1 '(write-region 1 (point-max) buffer-file-name)) ; => 0.06 s (insert-file-contents "...") takes 0.15 in this example, which would make it possible to use if etags implemented the same logic that we do in Elisp currently (I tried bringing Tom's etags branch up to date, but the performance wasn't good). Also, we can choose not to synchronize to disk, or do it much less often, whereas we'd have to call insert-file-contents during every update. > Anyway, TAGS and etags.el were designed to be very tolerant to > changes, so you shouldn't need to update very often. I want it to update reliably; maybe not too often (depending on a project), but if a user switches to a different Git branch, they should be confident that they'll see the changes reflected in the index soon. Even (and especially) if those are big changes. Right now only the update-on-save feature is in there, but I have to tell you, having a newly written function in the index right away (without having to invoke any commands or switch to the terminal) is pretty nice.