-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a way to return an empty resultset without using G_IO_ERROR_NOT_FOUND #149
Comments
Providing a GError to libxmlb results in the XbMachine internals propagating errors to the caller beyond the basic G_IO_ERROR_NOT_FOUND. This is not ideal because it means that a lot of CPU time is spent on creating and freeing GErrors in tight loops that is otherwise non-essential for control flow. Another option would be to add API to libxmlb to denote the difference between a result set, empty set (not found), and error but that will require further coordination. See hughsie/libxmlb#149.
Providing a GError to libxmlb results in the XbMachine internals propagating errors to the caller beyond the basic G_IO_ERROR_NOT_FOUND. This is not ideal because it means that a lot of CPU time is spent on creating and freeing GErrors in tight loops that is otherwise non-essential for control flow. Another option would be to add API to libxmlb to denote the difference between a result set, empty set (not found), and error but that will require further coordination. See hughsie/libxmlb#149.
FWIW, I think Christians patch is probably the right thing to do; it;s highly unlikely the |
Sure, but we do have much more complex queries than that in gnome-software, and some of them have been broken before.
Nope, I’ve tried hacks like that a few times over the years and it never works out well. |
So the idea would be to use a in-xmlb ref'd GPtrArray to return "no results, but a valid query"? If so, that makes sense to me, but I think we'd need to make it opt-in somehow. Is there anything in XPath we can [ab]use? |
Did you see this suggestion in my original post? 👇
Is that not correct? If it is correct, callers should already be expecting to handle |
Right, but if we start returning NULL without setting GError lots of things are going to start exploding... |
But the documentation for I’m reading that documentation as saying it can return Are you saying it should be read the other way — that |
Yup -- exactly that.
I've got a nagging feeling that fwupd relies on ==NULL for no-results. |
Currently, libxmlb queries will set the error
G_IO_ERROR_NOT_FOUND
if they find no matching elements. A lot of queries will often return no results (that’s just the way XML is), so this code path is hit often. If a lot of queries are run quickly (for example, when loading gnome-software), the cost of allocating aGError
to indicate an empty resultset becomes measurable.It would be nice if libxmlb would provide an alternate codepath which indicates an empty resultset some other way, without needing an allocation.
This might be possible without any new API: the documentation for the
xb_silo_query()
functions already says they returnNULL if unfound
, so callers should already be handling that. If that’s acceptable, we could just basically remove theg_set_error (G_IO_ERROR_NOT_FOUND)
calls.See https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/1749 for some more context.
The text was updated successfully, but these errors were encountered: