From 1f1d1894413f6aca3ea8792f5e5f87ce3a070191 Mon Sep 17 00:00:00 2001 From: Catherine Date: Thu, 17 Mar 2022 05:38:58 +0000 Subject: [PATCH] build.run: pipeline SFTP operations to improve performance. --- amaranth/build/run.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/amaranth/build/run.py b/amaranth/build/run.py index f87653d..cb40af6 100644 --- a/amaranth/build/run.py +++ b/amaranth/build/run.py @@ -154,10 +154,11 @@ class BuildPlan: mkdirs(filename) - mode = "wt" if isinstance(content, str) else "wb" - with sftp.file(str(filename), mode) as f: + mode = "t" if isinstance(content, str) else "b" + with sftp.file(str(filename), "w" + mode) as f: + f.set_pipelined() # "b/t" modifier ignored in SFTP. - if mode == "wt": + if mode == "t": f.write(content.encode("utf-8")) else: f.write(content) @@ -261,6 +262,7 @@ class RemoteSSHBuildProducts(BuildProducts): sftp.chdir(self.__root) with sftp.file(filename, "r" + mode) as f: + f.prefetch() # "b/t" modifier ignored in SFTP. if mode == "t": return f.read().decode("utf-8")