From unknown Thu Jun 19 14:06:35 2025 X-Loop: help-debbugs@gnu.org Subject: bug#76623: [PATCH] filesys.c: Use scm_sendfile to copy files. Resent-From: Tomas Volf <~@wolfsden.cz> Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 28 Feb 2025 01:11:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 76623 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: 76623@debbugs.gnu.org Cc: ludo@gnu.org, Tomas Volf <~@wolfsden.cz> X-Debbugs-Original-To: bug-guile@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.174070504714080 (code B ref -1); Fri, 28 Feb 2025 01:11:03 +0000 Received: (at submit) by debbugs.gnu.org; 28 Feb 2025 01:10:47 +0000 Received: from localhost ([127.0.0.1]:40794 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tnoto-0003ei-KI for submit@debbugs.gnu.org; Thu, 27 Feb 2025 20:10:46 -0500 Received: from lists.gnu.org ([2001:470:142::17]:59870) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1tnotl-0003di-CM for submit@debbugs.gnu.org; Thu, 27 Feb 2025 20:10:42 -0500 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 <~@wolfsden.cz>) id 1tnotf-0003RU-RX for bug-guile@gnu.org; Thu, 27 Feb 2025 20:10:35 -0500 Received: from wolfsden.cz ([37.205.8.62]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <~@wolfsden.cz>) id 1tnotd-0001Xf-Ow; Thu, 27 Feb 2025 20:10:35 -0500 Received: by wolfsden.cz (Postfix, from userid 104) id 17A0631AF01; Fri, 28 Feb 2025 01:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1740705028; bh=cPpyKkWq0xanapkmsTwpmr16f9qYtTN6PMsmgBzlcrI=; h=From:To:Cc:Subject:Date; b=Kqix0SJGRzNMz361QDqGF4yPlswQrGFqgClGCL4Rn0ZJoKjXvr8dXSQ/l5N+nToLR Lat2uNZuIpw5c+8zNmtfboNKVqg07bdHBs7ggNTIUVSFLlP/q457bmfa0ni2re1+Uq heor1o5AoZQkR+apUoh+s0n4HoqNEN4MWsEhcCqnxx3LDur9dtQa0NzFFxNQGGuRDK tXeTiijRkbZUAK9PoC5u0yfkOJK+ZvQtJv6kHsbGyqM8attFBXaxfxm9EwoWe1gcg9 sNhJGae4/dlnbQ/gDzzx33ZBB/vQ2xFVAcGt4omoYC5x7fk5+UBnsWveM/xFWOtpQn i6OYoPcc2OJ1Fu6Gy68t1QcB6rVUXKpXpN4X6KMvTDBwl+8CsmBXUOMDtGs/FMwv4J 99Im/hSe7B7EyvsXDIURiMgxbjFuF9tmh6gi3kef27vTBl3Z9oM+gspNSRfni2mmMb e6BGl5yVGUOa2DwWN/C29+adIGGhLNdKhlEgnOgecb8/PetElbHop0zZSOVsbKiLzZ cfT6qWYoo94UfdIcmvkdMGiLqIAsAt/3vxszKwnNYwGmc3ZtyMZofs9AVztjr38Ng1 HqKNEerUoJ/USRb775hDXdX2VTs5dAlDBzbgnEV3Hebh2W+C4lfb/3MvlYUHEvJweQ ZmAob3C1Y/dcGwqiBvWZdDMw= X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on wolfsden X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id D5D7531B08D; Fri, 28 Feb 2025 01:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1740705026; bh=cPpyKkWq0xanapkmsTwpmr16f9qYtTN6PMsmgBzlcrI=; h=From:To:Cc:Subject:Date; b=A6OjeYcjqpgA8Qs0L4yjKi8ivZi5dETL1f3NejZJEvJsplWbRBNSB3n+CN2SWI0Ek ActEeBrX+pybGis2wKLr7EuibLKWDUQOgU+V2mvZdK+nxwl4kDuT+cr1HLAOdv537J PaF8F24oz6aC8ZATkXRlX7PyDUFDPI2Cv3cdHxyNA1o2Hf4Uc5kPuy2uxEfXwTkCOd aVnXU0drOfOMOHIrgBGQTXCH/q7jzWH7WE6HstwLWUKzBLgldSdEU9o24r+M1/UVqO xJ+X8P5M4XOAm5cZXXXGoyf86CU0mgBC8Xh6CBLEuEjGUklENXv+BVTowXpCLEUTre hZLXxZ5+i6GlZ4S4nchT0U1zBjcHLjbkc/ojCup+jKIeDc2KplN1abEE+nJjnfqWzC XXKSEqC0ZobqQSUrw615bCMjPl1J+KtFmsfv+hyDn7UnEqz0xJ2IxrmKvkE5PH61P7 IDQATvE1JwfMFwHMF98Wvmk82H77b5Wnlrb1rnBmOj+4fCD2HRAEodcwBWGh5PCLus dpJkECz9PhKowYYEFXT3CzewlzOGNe/bhg9QLV9qoGN/trzKTfZSUuqRVq0WIBU5Ep oRTE+7+C09YuP+B5BdRa0vNU7e1UpI7lBpPCqbVfPYtyoiLINiRSTuHonBb8JZ8BJy JOWhw0EDdrO/IXiRo39F2xtY= From: Tomas Volf <~@wolfsden.cz> Date: Fri, 28 Feb 2025 02:10:18 +0100 Message-ID: <20250228011018.14428-1-~@wolfsden.cz> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=37.205.8.62; envelope-from=~@wolfsden.cz; helo=wolfsden.cz 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Use scm_sendfile instead of read-write loop. This moves the work into the kernel, improving performance. This implements Ludovic's suggestion from bug 68504. * libguile/filesys.c (scm_copy_file2): Use scm_sendfile. --- libguile/filesys.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libguile/filesys.c b/libguile/filesys.c index 3bfa5eb91..8a05f066f 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -1,7 +1,7 @@ /* Copyright 1996-2002,2004,2006,2009-2019,2021 Free Software Foundation, Inc. Copyright 2021 Maxime Devos - Copyright 2024 Tomas Volf <~@wolfsden.cz> + Copyright 2024, 2025 Tomas Volf <~@wolfsden.cz> This file is part of Guile. @@ -1354,13 +1354,18 @@ SCM_DEFINE (scm_copy_file2, "copy-file", 2, 0, 1, scm_syserror ("copy-file: copy-on-write failed"); if (clone_res) - while ((n = read (oldfd, buf, sizeof buf)) > 0) - if (write (newfd, buf, n) != n) - { - close (oldfd); - close (newfd); - SCM_SYSERROR; - } + { + off_t end; + if ((end = lseek_or_lseek64 (oldfd, 0, SEEK_END)) < 0) + SCM_SYSERROR; + if (lseek_or_lseek64 (oldfd, 0, SEEK_SET) < 0) + SCM_SYSERROR; + + scm_sendfile (scm_from_int (newfd), + scm_from_int (oldfd), + scm_from_off_t (end), + SCM_UNDEFINED); + } close (oldfd); if (close (newfd) == -1) SCM_SYSERROR; -- 2.48.1 From unknown Thu Jun 19 14:06:35 2025 X-Loop: help-debbugs@gnu.org Subject: bug#76623: [PATCH] filesys.c: Use scm_sendfile to copy files. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 28 Feb 2025 20:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 76623 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: Tomas Volf <~@wolfsden.cz> Cc: 76623@debbugs.gnu.org Received: via spool by 76623-submit@debbugs.gnu.org id=B76623.174077348922523 (code B ref 76623); Fri, 28 Feb 2025 20:12:01 +0000 Received: (at 76623) by debbugs.gnu.org; 28 Feb 2025 20:11:29 +0000 Received: from localhost ([127.0.0.1]:53357 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1to6hk-0005rD-Vo for submit@debbugs.gnu.org; Fri, 28 Feb 2025 15:11:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44036) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1to6hg-0005qS-Pj for 76623@debbugs.gnu.org; Fri, 28 Feb 2025 15:11:26 -0500 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 1to6hZ-0001in-LS; Fri, 28 Feb 2025 15:11:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=DpNZkal+nBBW6D1RDVmjw4/YqJp2hkfCzxeZ7SDZAlo=; b=n7t+nCums/UgzG++LzV1 SK8H7TXP/st6LPj9bWYyI1fLsiaTZCpwTwFz5z5grM3lO+4YVTtznhCHPGpCagccrBWpDh7Am/0I/ Gh1u4jS4f2TBrfKbZ5FA53oCFUXuHnsxdErCBNRbRdwifpkmi5nxuRkIlvSV1XQRvJ6xIVDfTwrSW zRq0mpqN+hISa8wm5oW0uVcw8T3/xWmb0isX/1oZXYqjX6xuF3AMwmRt62zYLJpJ6Q+7kXNNr2Fnz 30QwO1sna9SK6AaaT93GdVHyLtvOMUA6M1baF5R3n2Y239Iipav67aJjSxhYPF8qvHaBD6c39xcb7 hMws2Kh9zoSOHA==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= In-Reply-To: <20250228011018.14428-1-~@wolfsden.cz> (Tomas Volf's message of "Fri, 28 Feb 2025 02:10:18 +0100") References: <20250228011018.14428-1-~@wolfsden.cz> Date: Fri, 28 Feb 2025 21:11:10 +0100 Message-ID: <87h64drfs1.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, Tomas Volf <~@wolfsden.cz> skribis: > Use scm_sendfile instead of read-write loop. This moves the work into > the kernel, improving performance. This implements Ludovic's suggestion > from bug 68504. > > * libguile/filesys.c (scm_copy_file2): Use scm_sendfile. Nice! I had to apply the changes below to appease GCC. The patch LGTM but I realize there=E2=80=99s no real =E2=80=98copy-file=E2= =80=99 test. Not your fault but would you mind adding one or two tests? Thanks, Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline diff --git a/libguile/filesys.c b/libguile/filesys.c index 00171dade..4f861ab35 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -1306,10 +1306,9 @@ SCM_DEFINE (scm_copy_file2, "copy-file", 2, 0, 1, { char *c_oldfile, *c_newfile; int oldfd, newfd; - int n, rv; + int rv; SCM cow = sym_auto; int clone_res; - char buf[BUFSIZ]; struct stat_or_stat64 oldstat; scm_dynwind_begin (0); --=-=-=-- From unknown Thu Jun 19 14:06:35 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Tomas Volf <~@wolfsden.cz> Subject: bug#76623: closed (Re: bug#76623: [PATCH] filesys.c: Use scm_sendfile to copy files.) Message-ID: References: <87frj8wi01.fsf@trouble.defaultvalue.org> <20250228011018.14428-1-~@wolfsden.cz> X-Gnu-PR-Message: they-closed 76623 X-Gnu-PR-Package: guile X-Gnu-PR-Keywords: patch Reply-To: 76623@debbugs.gnu.org Date: Thu, 20 Mar 2025 02:32:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1742437922-23858-1" This is a multi-part message in MIME format... ------------=_1742437922-23858-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #76623: [PATCH] filesys.c: Use scm_sendfile to copy files. which was filed against the guile package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 76623@debbugs.gnu.org. --=20 76623: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D76623 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1742437922-23858-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 76623-done) by debbugs.gnu.org; 20 Mar 2025 02:31:02 +0000 Received: from localhost ([127.0.0.1]:54546 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tv5gT-0006BZ-TY for submit@debbugs.gnu.org; Wed, 19 Mar 2025 22:31:02 -0400 Received: from defaultvalue.org ([45.33.119.55]:43140) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tv5gQ-0006B7-41 for 76623-done@debbugs.gnu.org; Wed, 19 Mar 2025 22:30:58 -0400 Received: from trouble.defaultvalue.org (localhost [127.0.0.1]) (Authenticated sender: rlb@defaultvalue.org) by defaultvalue.org (Postfix) with ESMTPSA id 658772020F; Wed, 19 Mar 2025 21:30:55 -0500 (CDT) Received: by trouble.defaultvalue.org (Postfix, from userid 1000) id BAA1614E156; Wed, 19 Mar 2025 21:30:54 -0500 (CDT) From: Rob Browning To: Ludovic =?utf-8?Q?Court=C3=A8s?= , Tomas Volf <~@wolfsden.cz> Subject: Re: bug#76623: [PATCH] filesys.c: Use scm_sendfile to copy files. In-Reply-To: <87h64drfs1.fsf@gnu.org> References: <20250228011018.14428-1-~@wolfsden.cz> <87h64drfs1.fsf@gnu.org> Date: Wed, 19 Mar 2025 21:30:54 -0500 Message-ID: <87frj8wi01.fsf@trouble.defaultvalue.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76623-done Cc: 76623-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Ludovic Court=C3=A8s writes: > The patch LGTM but I realize there=E2=80=99s no real =E2=80=98copy-file= =E2=80=99 test. Not your > fault but would you mind adding one or two tests? I went ahead and added a commit to include some simple tests and pushed that and this to main. --=20 Rob Browning rlb @defaultvalue.org and @debian.org GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4 ------------=_1742437922-23858-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 28 Feb 2025 01:10:47 +0000 Received: from localhost ([127.0.0.1]:40794 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tnoto-0003ei-KI for submit@debbugs.gnu.org; Thu, 27 Feb 2025 20:10:46 -0500 Received: from lists.gnu.org ([2001:470:142::17]:59870) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1tnotl-0003di-CM for submit@debbugs.gnu.org; Thu, 27 Feb 2025 20:10:42 -0500 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 <~@wolfsden.cz>) id 1tnotf-0003RU-RX for bug-guile@gnu.org; Thu, 27 Feb 2025 20:10:35 -0500 Received: from wolfsden.cz ([37.205.8.62]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <~@wolfsden.cz>) id 1tnotd-0001Xf-Ow; Thu, 27 Feb 2025 20:10:35 -0500 Received: by wolfsden.cz (Postfix, from userid 104) id 17A0631AF01; Fri, 28 Feb 2025 01:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1740705028; bh=cPpyKkWq0xanapkmsTwpmr16f9qYtTN6PMsmgBzlcrI=; h=From:To:Cc:Subject:Date; b=Kqix0SJGRzNMz361QDqGF4yPlswQrGFqgClGCL4Rn0ZJoKjXvr8dXSQ/l5N+nToLR Lat2uNZuIpw5c+8zNmtfboNKVqg07bdHBs7ggNTIUVSFLlP/q457bmfa0ni2re1+Uq heor1o5AoZQkR+apUoh+s0n4HoqNEN4MWsEhcCqnxx3LDur9dtQa0NzFFxNQGGuRDK tXeTiijRkbZUAK9PoC5u0yfkOJK+ZvQtJv6kHsbGyqM8attFBXaxfxm9EwoWe1gcg9 sNhJGae4/dlnbQ/gDzzx33ZBB/vQ2xFVAcGt4omoYC5x7fk5+UBnsWveM/xFWOtpQn i6OYoPcc2OJ1Fu6Gy68t1QcB6rVUXKpXpN4X6KMvTDBwl+8CsmBXUOMDtGs/FMwv4J 99Im/hSe7B7EyvsXDIURiMgxbjFuF9tmh6gi3kef27vTBl3Z9oM+gspNSRfni2mmMb e6BGl5yVGUOa2DwWN/C29+adIGGhLNdKhlEgnOgecb8/PetElbHop0zZSOVsbKiLzZ cfT6qWYoo94UfdIcmvkdMGiLqIAsAt/3vxszKwnNYwGmc3ZtyMZofs9AVztjr38Ng1 HqKNEerUoJ/USRb775hDXdX2VTs5dAlDBzbgnEV3Hebh2W+C4lfb/3MvlYUHEvJweQ ZmAob3C1Y/dcGwqiBvWZdDMw= X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on wolfsden X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id D5D7531B08D; Fri, 28 Feb 2025 01:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1740705026; bh=cPpyKkWq0xanapkmsTwpmr16f9qYtTN6PMsmgBzlcrI=; h=From:To:Cc:Subject:Date; b=A6OjeYcjqpgA8Qs0L4yjKi8ivZi5dETL1f3NejZJEvJsplWbRBNSB3n+CN2SWI0Ek ActEeBrX+pybGis2wKLr7EuibLKWDUQOgU+V2mvZdK+nxwl4kDuT+cr1HLAOdv537J PaF8F24oz6aC8ZATkXRlX7PyDUFDPI2Cv3cdHxyNA1o2Hf4Uc5kPuy2uxEfXwTkCOd aVnXU0drOfOMOHIrgBGQTXCH/q7jzWH7WE6HstwLWUKzBLgldSdEU9o24r+M1/UVqO xJ+X8P5M4XOAm5cZXXXGoyf86CU0mgBC8Xh6CBLEuEjGUklENXv+BVTowXpCLEUTre hZLXxZ5+i6GlZ4S4nchT0U1zBjcHLjbkc/ojCup+jKIeDc2KplN1abEE+nJjnfqWzC XXKSEqC0ZobqQSUrw615bCMjPl1J+KtFmsfv+hyDn7UnEqz0xJ2IxrmKvkE5PH61P7 IDQATvE1JwfMFwHMF98Wvmk82H77b5Wnlrb1rnBmOj+4fCD2HRAEodcwBWGh5PCLus dpJkECz9PhKowYYEFXT3CzewlzOGNe/bhg9QLV9qoGN/trzKTfZSUuqRVq0WIBU5Ep oRTE+7+C09YuP+B5BdRa0vNU7e1UpI7lBpPCqbVfPYtyoiLINiRSTuHonBb8JZ8BJy JOWhw0EDdrO/IXiRo39F2xtY= From: Tomas Volf <~@wolfsden.cz> To: bug-guile@gnu.org Subject: [PATCH] filesys.c: Use scm_sendfile to copy files. Date: Fri, 28 Feb 2025 02:10:18 +0100 Message-ID: <20250228011018.14428-1-~@wolfsden.cz> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=37.205.8.62; envelope-from=~@wolfsden.cz; helo=wolfsden.cz 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit Cc: ludo@gnu.org, Tomas Volf <~@wolfsden.cz> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Use scm_sendfile instead of read-write loop. This moves the work into the kernel, improving performance. This implements Ludovic's suggestion from bug 68504. * libguile/filesys.c (scm_copy_file2): Use scm_sendfile. --- libguile/filesys.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/libguile/filesys.c b/libguile/filesys.c index 3bfa5eb91..8a05f066f 100644 --- a/libguile/filesys.c +++ b/libguile/filesys.c @@ -1,7 +1,7 @@ /* Copyright 1996-2002,2004,2006,2009-2019,2021 Free Software Foundation, Inc. Copyright 2021 Maxime Devos - Copyright 2024 Tomas Volf <~@wolfsden.cz> + Copyright 2024, 2025 Tomas Volf <~@wolfsden.cz> This file is part of Guile. @@ -1354,13 +1354,18 @@ SCM_DEFINE (scm_copy_file2, "copy-file", 2, 0, 1, scm_syserror ("copy-file: copy-on-write failed"); if (clone_res) - while ((n = read (oldfd, buf, sizeof buf)) > 0) - if (write (newfd, buf, n) != n) - { - close (oldfd); - close (newfd); - SCM_SYSERROR; - } + { + off_t end; + if ((end = lseek_or_lseek64 (oldfd, 0, SEEK_END)) < 0) + SCM_SYSERROR; + if (lseek_or_lseek64 (oldfd, 0, SEEK_SET) < 0) + SCM_SYSERROR; + + scm_sendfile (scm_from_int (newfd), + scm_from_int (oldfd), + scm_from_off_t (end), + SCM_UNDEFINED); + } close (oldfd); if (close (newfd) == -1) SCM_SYSERROR; -- 2.48.1 ------------=_1742437922-23858-1-- From unknown Thu Jun 19 14:06:35 2025 X-Loop: help-debbugs@gnu.org Subject: bug#76623: [PATCH] filesys.c: Use scm_sendfile to copy files. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 25 Mar 2025 09:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 76623 X-GNU-PR-Package: guile X-GNU-PR-Keywords: patch To: Rob Browning Cc: Tomas Volf <~@wolfsden.cz>, 76623-done@debbugs.gnu.org Received: via spool by 76623-done@debbugs.gnu.org id=D76623.17428948197612 (code D ref 76623); Tue, 25 Mar 2025 09:27:01 +0000 Received: (at 76623-done) by debbugs.gnu.org; 25 Mar 2025 09:26:59 +0000 Received: from localhost ([127.0.0.1]:36272 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tx0Yk-0001yi-OU for submit@debbugs.gnu.org; Tue, 25 Mar 2025 05:26:58 -0400 Received: from hera.aquilenet.fr ([185.233.100.1]:41584) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tx0Yi-0001yR-L2 for 76623-done@debbugs.gnu.org; Tue, 25 Mar 2025 05:26:57 -0400 Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id AEF1B57C; Tue, 25 Mar 2025 10:26:50 +0100 (CET) Authentication-Results: hera.aquilenet.fr; none X-Virus-Scanned: Debian amavis at hera.aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavis, port 10024) with ESMTP id i7RczhJQBb11; Tue, 25 Mar 2025 10:26:50 +0100 (CET) Received: from ribbon (unknown [193.50.110.142]) by hera.aquilenet.fr (Postfix) with ESMTPSA id D1EA645E; Tue, 25 Mar 2025 10:26:49 +0100 (CET) From: Ludovic =?UTF-8?Q?Court=C3=A8s?= In-Reply-To: <87frj8wi01.fsf@trouble.defaultvalue.org> (Rob Browning's message of "Wed, 19 Mar 2025 21:30:54 -0500") References: <20250228011018.14428-1-~@wolfsden.cz> <87h64drfs1.fsf@gnu.org> <87frj8wi01.fsf@trouble.defaultvalue.org> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Quintidi 5 Germinal an 233 de la =?UTF-8?Q?R=C3=A9volution,?= jour de la Poule X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Tue, 25 Mar 2025 10:26:49 +0100 Message-ID: <87msd9o3za.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: AEF1B57C X-Spamd-Result: default: False [4.84 / 15.00]; SPAM_FLAG(5.00)[]; BAYES_HAM(-3.00)[99.99%]; NEURAL_SPAM(2.94)[0.981]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Level: **** X-Rspamd-Action: no action X-Spamd-Bar: ++++ X-Rspamd-Server: hera X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Rob Browning skribis: > Ludovic Court=C3=A8s writes: > >> The patch LGTM but I realize there=E2=80=99s no real =E2=80=98copy-file= =E2=80=99 test. Not your >> fault but would you mind adding one or two tests? > > I went ahead and added a commit to include some simple tests and pushed > that and this to main. Thank you! Ludo=E2=80=99.