On Tue, 2015-02-10 at 10:30 -0800, Jasper St. Pierre wrote:
> One quick example: calling g_file_read_async on a GResourceFile spawns
> a new thread and does a synchronous stream read from a block already
> in memory.
>
>
> It should just be a single g_bytes_ref, but we have three different
> classes created, a thread spawned, and a large amount of locks to do
> the equivalent of memcpy.
That’s not good at all, and seems like it should be easy to fix by
overriding the read_async vfunc for GResourceFile. Is there a bug filed
about it?
Philip
> On Tue, Feb 10, 2015 at 8:49 AM, Jasper St. Pierre
> <jstpierre mecheye net> wrote:
>Â Â Â Â Â Right now the way g_file_read_async works is by scheduling a
>Â Â Â Â Â task on a worker thread, having the worker thread do the async
>Â Â Â Â Â read, and then returning a result.
>
>Â Â Â Â Â As such, it's impossible to have two async reads done at the
>Â Â Â Â Â same time, which is really unfortunate from my understanding.
>Â Â Â Â Â If I'm reading a large file, and then a small file, the large
>Â Â Â Â Â file needs to fully complete before the small file is
>Â Â Â Â Â dispatched from the async queue.
>
>Â Â Â Â Â Additionally, when profiling GNOME on ARM, I've been seeing a
>Â Â Â Â Â lot of cases of users using g_file_read_async() "just in case"
>Â Â Â Â Â for no particular reason, which causes several locks to be
>Â Â Â Â Â taken, severely slowing performance.
>
>
>Â Â Â Â Â We need to seriously improve our async performance before
>Â Â Â Â Â asking people to use it.
>
>
>Â Â Â Â Â On Tue, Feb 10, 2015 at 6:48 AM, Lennart Poettering
>Â Â Â Â Â <mztabzr 0pointer de> wrote:
>Â Â Â Â Â Â Â Â Â On Tue, 10.02.15 13:59, Philip Withnall
>Â Â Â Â Â Â Â Â Â (philip tecnocode co uk) wrote:
>
>Â Â Â Â Â Â Â Â Â > > I am pretty sure if you do async IO like gio does
>Â Â Â Â Â Â Â Â Â for every single
>Â Â Â Â Â Â Â Â Â > > file access you'll just complicate your program
>Â Â Â Â Â Â Â Â Â and make it
>Â Â Â Â Â Â Â Â Â > > substantially slower. For small files normal,
>Â Â Â Â Â Â Â Â Â synchronous disk access
>Â Â Â Â Â Â Â Â Â > > is a ton faster than dispatching things to
>Â Â Â Â Â Â Â Â Â background threads, and
>Â Â Â Â Â Â Â Â Â > > back...
>Â Â Â Â Â Â Â Â Â >
>         > The problem is that GIO can’t know which accesses
>Â Â Â Â Â Â Â Â Â are to small, local
>         > files, and which aren’t. It already optimises reads
>Â Â Â Â Â Â Â Â Â from pollable
>Â Â Â Â Â Â Â Â Â > streams (sockets) by keeping them in the main thread
>Â Â Â Â Â Â Â Â Â and adding them
>Â Â Â Â Â Â Â Â Â > into the main poll() call.
>
>Â Â Â Â Â Â Â Â Â Well, but the developer frequently knows that. He
>Â Â Â Â Â Â Â Â Â knows that the
>Â Â Â Â Â Â Â Â Â config file in ~/.config is not going to be more than
>Â Â Â Â Â Â Â Â Â a few K. And
>Â Â Â Â Â Â Â Â Â that it hence is fine to access it synchronously...
>
>Â Â Â Â Â Â Â Â Â > > Also, glib has wrappers for making mmaping
>Â Â Â Â Â Â Â Â Â available to programs, to
>Â Â Â Â Â Â Â Â Â > > improve seldom-accessed sparse databases
>Â Â Â Â Â Â Â Â Â efficient, do you want to
>Â Â Â Â Â Â Â Â Â > > prohibit that too?
>Â Â Â Â Â Â Â Â Â >
>Â Â Â Â Â Â Â Â Â > No, mmap() is clearly a tool for a different kind of
>         problem. If you’re
>         > accessing an mmap()ed file, you need to be sure it’s
>Â Â Â Â Â Â Â Â Â local anyway, I
>         > think? GMappedFile doesn’t have async versions of
>Â Â Â Â Â Â Â Â Â its methods,
>Â Â Â Â Â Â Â Â Â > presumably for this reason.
>
>Â Â Â Â Â Â Â Â Â mmap() works pretty Ok these days over NFS. Concurrent
>Â Â Â Â Â Â Â Â Â access
>Â Â Â Â Â Â Â Â Â doesn't. But as long as you just want to access
>Â Â Â Â Â Â Â Â Â something, it's
>Â Â Â Â Â Â Â Â Â fine...
>
>Â Â Â Â Â Â Â Â Â That said it's probably not a good idea to use mmap()
>Â Â Â Â Â Â Â Â Â for stuff below
>Â Â Â Â Â Â Â Â Â $HOME...
>
>Â Â Â Â Â Â Â Â Â > As above, how about making that line the distinction
>Â Â Â Â Â Â Â Â Â between calling
>Â Â Â Â Â Â Â Â Â > functions from gstdio.h and using GIO? In the former
>Â Â Â Â Â Â Â Â Â case, you know
>         > you’re operating on local files. In the latter, you
>Â Â Â Â Â Â Â Â Â could be operating
>Â Â Â Â Â Â Â Â Â > on files from the moon.
>
>Â Â Â Â Â Â Â Â Â I'd always leave some freedom for the developers. It
>Â Â Â Â Â Â Â Â Â is certainly good
>Â Â Â Â Â Â Â Â Â to document things and push people into the right
>Â Â Â Â Â Â Â Â Â directions, but I
>Â Â Â Â Â Â Â Â Â think there are many cases where the developer should
>Â Â Â Â Â Â Â Â Â have every right
>Â Â Â Â Â Â Â Â Â to prefer sync access for valid reasons, even from the
>Â Â Â Â Â Â Â Â Â main loop...
>
>Â Â Â Â Â Â Â Â Â Lennart
>
>Â Â Â Â Â Â Â Â Â --
>Â Â Â Â Â Â Â Â Â Lennart Poettering, Red Hat
>Â Â Â Â Â Â Â Â Â _______________________________________________
>Â Â Â Â Â Â Â Â Â desktop-devel-list mailing list
>Â Â Â Â Â Â Â Â Â desktop-devel-list gnome org
>Â Â Â Â Â Â Â Â Â https://mail.gnome.org/mailman/listinfo/desktop-devel-list
>
>
>
>
>Â Â Â Â Â --
>Â Â Â Â Â Â Jasper
>
>
>
>
> --
>Â Â Jasper
>