Skip to content

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: https://github.com/hughsie/libxmlb/pull/52

Signed-off-by: Philip Withnall withnall@endlessm.com

Merge request reports