unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Francesco Potortì" <pot@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: dmitry@gutov.dev, 73484@debbugs.gnu.org, spwhitton@spwhitton.name
Subject: bug#73484: 31.0.50; Abolishing etags-regen-file-extensions
Date: Fri, 11 Oct 2024 12:37:34 +0200	[thread overview]
Message-ID: <8734l3hqmp.fsf@tucano.isti.cnr.it> (raw)
In-Reply-To: <86frp32a90.fsf@gnu.org> (eliz@gnu.org)

>> From: Francesco Potortì <pot@gnu.org>
>> Date: Thu, 10 Oct 2024 16:25:28 +0200
>> Cc: dmitry@gutov.dev,
>> 	73484@debbugs.gnu.org,
>> 	spwhitton@spwhitton.name
>> 
>>   for (fdp = fdhead; fdp != NULL; fdp = fdp->next)
>>     {
>>       assert (fdp->infname != NULL);
>>       if (streq (uncompressed_name, fdp->infname))
>> 	goto cleanup;
>>     }
>> 
>> This is a simple O^2 comparison, which is repeated sum(1,N,N-1)=~N^2/2, which for ~375k files means ~70G comparisons.  If you can count the number of times streq is called and 70G is a substantial portion of that number, then we have the culprit.  To check, just remove the above test and see if the running time drops.
>
>Dmitry already made this check, and the run time did drop, see
>https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73484#107

Yes, sorry, I am travelling and I had missed that email.

>> In that case, using a hash rather than a comparison would probably make sense.
>
>Right.

If I recall correctly, etags depends on libc only.  If that is really the case, it would be nice to create an ad hoc has function without relying on additional libraries.

>> Alternatively, rather than managing file names in a single loop, do a first loop on all file names to canonicalise them, but without searching for tags (essentially, remove the call to process_file from process_file_name), then uniquify the list of canonicalised file names, then run process_file on them.
>
>I don't think this is possible because command-line options can be
>interspersed with file names, and each option affects the processing
>of the files whose names follow the option.

It should be possible as I have outlined above.  When the command line is parsed, process_file_name is called on each file name.  It canonicalises the current name, compares it with the previous file names, adds a new node containing the canonicalised name to a linked list and calls process_file on the file name.  It is possible to remove the last step and instead call process_file in a second loop, but I do not know if it is convenient.

The uniquify solutions would be nonparametric, if I am not wrong.  While the hash solution requires choosing the size of the hash table.

I guess that the hash solution is simpler and equally efficient in the great majority of cases, provided that the size of the hash table is appropriate.  Probably it would be reasonable to start with a 20-bit hash.  And increase that number if in some years it will look reasonable doing so.





  reply	other threads:[~2024-10-11 10:37 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87tteaznog.fsf@zephyr.silentflame.com>
     [not found] ` <edab570c-b2fa-4162-9383-df5c8aaff251@yandex.ru>
     [not found]   ` <8734lrrj4e.fsf@zephyr.silentflame.com>
     [not found]     ` <ea10f340-9b46-4199-93fc-274c5e81ace4@yandex.ru>
     [not found]       ` <87o74c1ce1.fsf@zephyr.silentflame.com>
     [not found]         ` <b8001a72-8fc9-4e4e-a2d7-5da94a92f250@yandex.ru>
2024-09-25 19:27           ` bug#73484: 31.0.50; Abolishing etags-regen-file-extensions Sean Whitton
2024-09-25 22:30             ` Dmitry Gutov
2024-09-26  7:43               ` Francesco Potortì
2024-09-26 12:18                 ` Dmitry Gutov
2024-09-29  8:25               ` Eli Zaretskii
2024-09-29 10:56                 ` Eli Zaretskii
2024-09-29 17:15                   ` Francesco Potortì
2024-09-30 23:19                 ` Dmitry Gutov
2024-10-01 15:00                   ` Eli Zaretskii
2024-10-01 22:01                     ` Dmitry Gutov
2024-10-02 11:28                   ` Eli Zaretskii
2024-10-02 18:00                     ` Dmitry Gutov
2024-10-02 18:56                       ` Eli Zaretskii
2024-10-02 22:03                         ` Dmitry Gutov
2024-10-03  6:27                           ` Eli Zaretskii
2024-10-04  1:25                             ` Dmitry Gutov
2024-10-04  6:45                               ` Eli Zaretskii
2024-10-04 23:01                                 ` Dmitry Gutov
2024-10-05  7:02                                   ` Eli Zaretskii
2024-10-05 14:29                                     ` Dmitry Gutov
2024-10-05 15:27                                       ` Eli Zaretskii
2024-10-05 20:27                                         ` Dmitry Gutov
2024-10-05 16:38                                       ` Francesco Potortì
2024-10-05 17:12                                         ` Eli Zaretskii
2024-10-06  0:56                                         ` Dmitry Gutov
2024-10-06  6:22                                           ` Eli Zaretskii
2024-10-06 19:14                                             ` Dmitry Gutov
2024-10-07  2:33                                               ` Eli Zaretskii
2024-10-07  7:11                                                 ` Dmitry Gutov
2024-10-07 16:05                                                   ` Eli Zaretskii
2024-10-07 17:36                                                     ` Dmitry Gutov
2024-10-07 19:05                                                       ` Eli Zaretskii
2024-10-07 22:08                                                         ` Dmitry Gutov
2024-10-08 13:04                                                           ` Eli Zaretskii
2024-10-09 18:23                                                             ` Dmitry Gutov
2024-10-09 19:11                                                               ` Eli Zaretskii
2024-10-09 22:22                                                                 ` Dmitry Gutov
2024-10-10  5:13                                                                   ` Eli Zaretskii
2024-10-10  1:07                                                               ` Francesco Potortì
2024-10-10  5:41                                                                 ` Eli Zaretskii
2024-10-10  8:27                                                                   ` Francesco Potortì
2024-10-10  8:35                                                                     ` Eli Zaretskii
2024-10-10 14:25                                                                       ` Francesco Potortì
2024-10-10 16:28                                                                         ` Eli Zaretskii
2024-10-11 10:37                                                                           ` Francesco Potortì [this message]
2024-10-10 10:17                                                                 ` Dmitry Gutov
2024-10-10  1:39                                                               ` Francesco Potortì
2024-10-10  5:45                                                                 ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8734l3hqmp.fsf@tucano.isti.cnr.it \
    --to=pot@gnu.org \
    --cc=73484@debbugs.gnu.org \
    --cc=dmitry@gutov.dev \
    --cc=eliz@gnu.org \
    --cc=spwhitton@spwhitton.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).