After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 773823 - gio: Bump copy buffer size to 256k by default
gio: Bump copy buffer size to 256k by default
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2016-11-02 10:59 UTC by Bastien Nocera
Modified: 2017-08-14 09:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gio: Bump copy buffer size to 256k by default (922 bytes, patch)
2016-11-02 10:59 UTC, Bastien Nocera
none Details | Review
gio: Use heap-allocated buffer (1.24 KB, patch)
2016-12-07 13:52 UTC, Bastien Nocera
none Details | Review
gio: Bump copy buffer size to 256k by default (913 bytes, patch)
2016-12-07 13:52 UTC, Bastien Nocera
none Details | Review
gio: Use heap-allocated buffer (1.75 KB, patch)
2017-01-09 13:02 UTC, Bastien Nocera
committed Details | Review
gio: Bump copy buffer size to 256k by default (912 bytes, patch)
2017-01-09 13:02 UTC, Bastien Nocera
none Details | Review
gio: Bump copy buffer size to 256k by default (1.08 KB, patch)
2017-01-11 17:26 UTC, Bastien Nocera
committed Details | Review

Description Bastien Nocera 2016-11-02 10:59:48 UTC
.
Comment 1 Bastien Nocera 2016-11-02 10:59:52 UTC
Created attachment 338944 [details] [review]
gio: Bump copy buffer size to 256k by default

This is small enough that it shouldn't cause problems on most machines
we support, but big enough to increase throughput on a lot of devices
and network protocols.

See https://bugzilla.gnome.org/show_bug.cgi?id=773632
Comment 2 Alexander Larsson 2016-11-09 13:58:15 UTC
256kb is kinda large on the stack though. I think the default thread stack size is 2 meg, and this is 12% of that. Maybe we should use a dynamic allocation for this? I mean, the allocation will be fast compared to the i/o anyway.
Comment 3 Ondrej Holy 2016-11-09 14:06:17 UTC
Alex, see also:
https://bugzilla.gnome.org/show_bug.cgi?id=773826
Comment 4 Bastien Nocera 2016-12-07 13:52:20 UTC
Created attachment 341554 [details] [review]
gio: Use heap-allocated buffer

As if we were to increase the buffer size, it would be a bit too big to
fit on the stack.
Comment 5 Bastien Nocera 2016-12-07 13:52:25 UTC
Created attachment 341555 [details] [review]
gio: Bump copy buffer size to 256k by default

This is small enough that it shouldn't cause problems on most machines
we support, but big enough to increase throughput on a lot of devices
and network protocols.

See https://bugzilla.gnome.org/show_bug.cgi?id=773632
Comment 6 Ondrej Holy 2017-01-09 09:13:49 UTC
Review of attachment 341554 [details] [review]:

I am not GLib maint, but I suppose you need somethink like the following, because sizeof (buffer) is probably 8, or so:

@@ -2820 +2820 @@ copy_stream_with_progress (GInputStream           *in,
-      n_read = g_input_stream_read (in, buffer, sizeof (buffer), cancellable, error);
+      n_read = g_input_stream_read (in, buffer, 1024*64, cancellable, error);

So, it would be best to define some constant with the buffer size...
Comment 7 Bastien Nocera 2017-01-09 13:02:34 UTC
Created attachment 343152 [details] [review]
gio: Use heap-allocated buffer

As if we were to increase the buffer size, it would be a bit too big to
fit on the stack.
Comment 8 Bastien Nocera 2017-01-09 13:02:40 UTC
Created attachment 343153 [details] [review]
gio: Bump copy buffer size to 256k by default

This is small enough that it shouldn't cause problems on most machines
we support, but big enough to increase throughput on a lot of devices
and network protocols.

See https://bugzilla.gnome.org/show_bug.cgi?id=773632
Comment 9 Bastien Nocera 2017-01-10 15:09:49 UTC
(In reply to Ondrej Holy from comment #6)
> Review of attachment 341554 [details] [review] [review]:
> 
> I am not GLib maint, but I suppose you need somethink like the following,
> because sizeof (buffer) is probably 8, or so:

Duh, yes, fixed in the latest patches.
Comment 10 Alexander Larsson 2017-01-11 15:59:15 UTC
Review of attachment 343152 [details] [review]:

looks good
Comment 11 Alexander Larsson 2017-01-11 16:00:30 UTC
Review of attachment 343153 [details] [review]:

Can you make this (1024*256 - 2 *sizeof(gpointer)) instead? That generally means we fit in a 256k block with the standard malloc overhead.
Otherwise ok to commit.
Comment 12 Bastien Nocera 2017-01-11 17:26:03 UTC
Created attachment 343320 [details] [review]
gio: Bump copy buffer size to 256k by default

This is small enough that it shouldn't cause problems on most machines
we support, but big enough to increase throughput on a lot of devices
and network protocols.

Note that the actual value is 256k minus malloc overhead, so that it
fits nicely in a 256k block (as suggested by Alexander Larsson).

See https://bugzilla.gnome.org/show_bug.cgi?id=773632
Comment 13 Bastien Nocera 2017-01-11 17:26:36 UTC
Attachment 343152 [details] pushed as 0106a6c - gio: Use heap-allocated buffer
Attachment 343320 [details] pushed as 3b5b569 - gio: Bump copy buffer size to 256k by default
Comment 14 Ondrej Holy 2017-08-11 13:10:17 UTC
It seems that this causes deadlocks when copying, please see Bug 773823.
Comment 15 Bastien Nocera 2017-08-11 13:38:57 UTC
(In reply to Ondrej Holy from comment #14)
> It seems that this causes deadlocks when copying, please see Bug 773823.

I have a very hard time believing that, and you just pointed to the same bug you commented on.
Comment 16 Ondrej Holy 2017-08-11 13:41:47 UTC
Sorry, Bug 785391.
Comment 17 Philip Withnall 2017-08-11 13:49:18 UTC
(In reply to Ondrej Holy from comment #16)
> Sorry, Bug 785391.

Looking at comment #32 in that bug, it seems that this problem is fixed now, without needing to revert the GLib patch from this bug? If so, it looks like it’s entirely a GVFS bug, and hence can be tracked in bug #785391.
Comment 18 Ondrej Holy 2017-08-14 09:14:12 UTC
Not fixed, but yes, it is probably gvfs-only bug.