mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marcin Niestroj <m.niestroj@grinn-global.com>
To: barebox@lists.infradead.org
Cc: Maciej Zagrabski <m.zagrabski@grinn-global.com>,
	Marcin Niestroj <m.niestroj@grinn-global.com>
Subject: [PATCH v2] fs: improve ramfs_truncate speed
Date: Wed, 26 Sep 2018 13:08:46 +0200	[thread overview]
Message-ID: <20180926110846.13527-1-m.niestroj@grinn-global.com> (raw)

During sequential writes into single file, fs layer is consequently
calling ramfs_truncate() function. When file size grows
ramfs_truncate() takes more and more time to complete, due to
interations through all already written data chunks. As an example
loading ~450M image using usb fastboot protocol took over 500s to
complete.

Use ramfs_find_chunk() function to search for last chunk of data in
ramfs_truncate() implementation, which saves a lot of loop
iterations. As a result loading ~450M image using usb fastboot
protocol takes around 25s now.

Tested-by: Maciej Zagrabski <m.zagrabski@grinn-global.com>
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
---
Changes v1 -> v2 (suggested by Sascha):
 * use positive logic, i.e. 'if (data)'
 * rebase patch on top of "fs: ramfs: make chunk counting in 
   truncate() better readable"

 fs/ramfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/ramfs.c b/fs/ramfs.c
index 8ba8d77de..e3f83bca3 100644
--- a/fs/ramfs.c
+++ b/fs/ramfs.c
@@ -379,7 +379,9 @@ static int ramfs_truncate(struct device_d *dev, FILE *f, ulong size)
 	}
 
 	if (newchunks > oldchunks) {
-		if (!data) {
+		if (data) {
+			data = ramfs_find_chunk(node, oldchunks);
+		} else {
 			node->data = ramfs_get_chunk();
 			if (!node->data)
 				return -ENOMEM;
-- 
2.19.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2018-09-26 11:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

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

  git send-email \
    --in-reply-to=20180926110846.13527-1-m.niestroj@grinn-global.com \
    --to=m.niestroj@grinn-global.com \
    --cc=barebox@lists.infradead.org \
    --cc=m.zagrabski@grinn-global.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox