From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#61394: 30.0.50; [PATCH] Image-dired thumb name based on content Date: Sat, 11 Feb 2023 16:53:25 +0200 Message-ID: <838rh4jlsq.fsf@gnu.org> References: <874jruy7xx.fsf@ledu-giraud.fr> <87ttztk0yw.fsf@tcd.ie> <87v8k9s6j9.fsf@ledu-giraud.fr> <83ilg8jzti.fsf@gnu.org> <87k00oo03r.fsf@ledu-giraud.fr> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37192"; mail-complaints-to="usenet@ciao.gmane.io" Cc: contovob@tcd.ie, 61394@debbugs.gnu.org To: Manuel Giraud Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 11 15:55:15 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1pQrHX-0009Sn-7I for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 11 Feb 2023 15:55:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQrHO-0006sc-PP; Sat, 11 Feb 2023 09:55:06 -0500 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 1pQrHL-0006sM-Ud for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2023 09:55:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pQrHK-0000of-DD for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2023 09:55:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pQrHK-00006J-3L for bug-gnu-emacs@gnu.org; Sat, 11 Feb 2023 09:55:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 11 Feb 2023 14:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61394 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 61394-submit@debbugs.gnu.org id=B61394.167612724532751 (code B ref 61394); Sat, 11 Feb 2023 14:55:02 +0000 Original-Received: (at 61394) by debbugs.gnu.org; 11 Feb 2023 14:54:05 +0000 Original-Received: from localhost ([127.0.0.1]:39204 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQrGO-0008WA-O4 for submit@debbugs.gnu.org; Sat, 11 Feb 2023 09:54:05 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58234) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQrGL-0008VC-Pa for 61394@debbugs.gnu.org; Sat, 11 Feb 2023 09:54:04 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQrGF-0000e6-SS; Sat, 11 Feb 2023 09:53:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=E2SaJvJ9tR/p1gTRBHyYbI1EyvPIXF1aOC2rZC6Gcng=; b=T6H+Q9DC6anN FvsHJiMUTDq8F2+Xr+kGn3nOz37v1pP4Hk6a0H5V8BNUlYbyJLOHUJKnPZ5liAGT/dGp9/33dmI6R 0B2AsbvCZzoG5yk7W2m5ZeK/Stop0ceJifE6tMoAtL1SsrBOcB934cn5OewSjVt9YtHgfKLlYtHpk GxHAjhbZ28SXlOCNXd9AFuS4K3GFkT0rdtJzetnbfpwtS3x2ga3g8Qvj5Ms7ay4Trl7Q5WSNDtCWa hBA08Wa3MSTqLatXjhqNV3puzRUyquc8M9I/NgPgnIj6JkROlkxd4wG/nHQyoXOXOsSz6rxw7RcPA 2fvUrAzFWpeHZHO8iFAbEQ==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQrGF-000440-8e; Sat, 11 Feb 2023 09:53:55 -0500 In-Reply-To: <87k00oo03r.fsf@ledu-giraud.fr> (message from Manuel Giraud on Sat, 11 Feb 2023 13:30:48 +0100) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:255333 Archived-At: > From: Manuel Giraud > Cc: contovob@tcd.ie, 61394@debbugs.gnu.org > Date: Sat, 11 Feb 2023 13:30:48 +0100 > > > Btw, using only the first 4KiB would mean a collision is still > > possible, albeit rarely, right? So your use case of having all the > > thumbnails in the same directory could sometimes fail, right? > > The 4KiB was "quite large but not so much" guess. I've made tests with > the following code: > > --8<---------------cut here---------------start------------->8--- > (defun sha1-test (filename size) > (with-temp-buffer > (insert-file-contents-literally filename nil 0 size) > (sha1 (current-buffer)))) > > ;; From 1KiB to 64KiB > (list > (benchmark-run-compiled 1000 > (sha1-test "/tmp/a-5MiB-photo.jpg" (expt 2 10))) > (benchmark-run-compiled 1000 > (sha1-test "/tmp/a-5MiB-photo.jpg" (expt 2 11))) > (benchmark-run-compiled 1000 > (sha1-test "/tmp/a-5MiB-photo.jpg" (expt 2 12))) > (benchmark-run-compiled 1000 > (sha1-test "/tmp/a-5MiB-photo.jpg" (expt 2 13))) > (benchmark-run-compiled 1000 > (sha1-test "/tmp/a-5MiB-photo.jpg" (expt 2 14))) > (benchmark-run-compiled 1000 > (sha1-test "/tmp/a-5MiB-photo.jpg" (expt 2 15))) > (benchmark-run-compiled 1000 > (sha1-test "/tmp/a-5MiB-photo.jpg" (expt 2 16)))) > --8<---------------cut here---------------end--------------->8--- > > And here are the results on my machine: > ((0.664336771 1 0.14466495299998883) > (0.707937024 2 0.28811983400001395) > (0.940229304 3 0.44037704100000497) ;; <- 4KiB > (1.672118528 4 0.7672738199999856) > (2.6194289370000003 6 1.046699996000001) > (3.169999951 11 1.5916382949999957) > (6.547043287 21 3.195145416999992)) > > So this 4KiB seems practical: about 1 second for one thousand run. > WDYT? I only commented on that because you said it allows you to use a single directory. Otherwise, I have no problems with using just 4KiB.