mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fs: improve ramfs_truncate speed
@ 2018-09-25 19:50 Marcin Niestroj
  2018-09-26  8:12 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Marcin Niestroj @ 2018-09-25 19:50 UTC (permalink / raw)
  To: barebox; +Cc: Maciej Zagrabski, Marcin Niestroj

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>
---
 fs/ramfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/ramfs.c b/fs/ramfs.c
index 7548bdac9..6f4aa0675 100644
--- a/fs/ramfs.c
+++ b/fs/ramfs.c
@@ -362,6 +362,9 @@ static int ramfs_truncate(struct device_d *dev, FILE *f, ulong size)
 			if (!node->data)
 				return -ENOMEM;
 			data = node->data;
+		} else {
+			data = ramfs_find_chunk(node, oldchunks - 1);
+			newchunks -= (oldchunks - 1);
 		}
 
 		newchunks--;
-- 
2.19.0


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] fs: improve ramfs_truncate speed
  2018-09-25 19:50 [PATCH] fs: improve ramfs_truncate speed Marcin Niestroj
@ 2018-09-26  8:12 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2018-09-26  8:12 UTC (permalink / raw)
  To: Marcin Niestroj; +Cc: Maciej Zagrabski, barebox

Hi Marcin,

On Tue, Sep 25, 2018 at 09:50:16PM +0200, Marcin Niestroj wrote:
> 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>
> ---
>  fs/ramfs.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/fs/ramfs.c b/fs/ramfs.c
> index 7548bdac9..6f4aa0675 100644
> --- a/fs/ramfs.c
> +++ b/fs/ramfs.c
> @@ -362,6 +362,9 @@ static int ramfs_truncate(struct device_d *dev, FILE *f, ulong size)
>  			if (!node->data)
>  				return -ENOMEM;
>  			data = node->data;
> +		} else {
> +			data = ramfs_find_chunk(node, oldchunks - 1);
> +			newchunks -= (oldchunks - 1);
>  		}

It took me a bit to understand why you have to call ramfs_find_chunk()
with "oldchunks - 1" instead of just "oldchunks" I just sent out a patch
which changes that, so you should now be able to use oldchunks directly.
Could you rebase your patch ontop of that and resend?

Also, could you rearrange to use if (data) rather than if (!data)? Positive
logic is easier to read.

Thanks
Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-26  8:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-25 19:50 [PATCH] fs: improve ramfs_truncate speed Marcin Niestroj
2018-09-26  8:12 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox