appstream: Don’t call xb_builder_source_ctx_get_bytes()

It unconditionally allocates a 128MB buffer for the `GBytes`, and can’t
easily be improved. When starting gnome-software up on my Fedora 32
machine, this was happening 107 times (once for each `.desktop` file on
the system), and each 128MB allocation was taking 35ms. So this commit
should reduce appstream refresh time by up to 3.7s.

Instead, use the new API in libxmlb to get the source filename, and tell
as-glib to load from that file directly instead. On these code paths,
that filename will typically be non-NULL, as they’re used to load
`.desktop` files from disk and convert them to XML.

Another approach would have been to add stream-based constructors to
as-glib, such as `as_app_parse_stream()`, then the stream from
`xb_builder_source_ctx_get_stream()` could have been passed to them.
That would have been more work but would have given a slightly more
streamlined result.

By exposing the on-disk filename, however, this commit opens the
possibility for memory mapping the files if needed. That may speed
things up further, but I’ve not explored it yet.

Depends on:

Signed-off-by: Philip Withnall <>
3 jobs for appstream-bytes-allocations in 4 minutes and 12 seconds (queued for 1 second)
Status Job ID Name Coverage
failed #789660


passed #741124


failed #741125


Name Stage Failure
debian-stable-x86_64 Build
Uploading artifacts...
_build/config.h: found 1 matching files

_build/meson-logs: found 2 matching files

WARNING: _build/debian-stable-x86_64-report.xml: no matching files
Uploading artifacts to coordinator... ok
id=789660 responseStatus=201 Created token=S3c573Hk
Uploading artifacts...
WARNING: _build/debian-stable-x86_64-report.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit code 1