Skip to content
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

Various sqlite backend optimizations and cleanups #972

Merged
merged 6 commits into from Dec 11, 2019

Conversation

pmatilai
Copy link
Member

@pmatilai pmatilai commented Dec 9, 2019

No description provided.

No functional changes, just makes the thing a little clearer.
Rpm can reuse an iterator cursor for a write when rewriting an existing
header (such as when updating file states of already installed package),
which in sqlite terms turns a SELECT into INSERT, destroying the
iteration in progress.

Detect the condition and use a local cursor as necessary, this also means
we don't need to track the query fmt string in cursors.
Caching statements is not stupid but when it makes us go slower...
Also without the cache we have a better handle on locks and all,
revisit the caching issue later.
Spinning new cursors for each key value is just mind-bogglingly stupid
(if simple), use a sub-cursor with key binding instead. Which isn't any
more complicated, really.
The upper layers sort the dbi set as necessary, this is nothing but
waste of perfectly good computing cycles.
We don't need to pull the key values from the db here, we already have it.
dbiCursorFree(dbi, kc);
}
if (set)
rc = sqlite_idxdbByKey(dbi, dbc->subc, dbc->key, dbc->keylen, set);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's an error here. It looks like there should be braces here...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What makes you think that? There's no need for braces for a single line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, aside from a couple lines up there is braces used even with a single line branch on if, the rc = RPMRC_OK made me think there's some kind of error here.

Copy link
Member Author

@pmatilai pmatilai Dec 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The brace use for single line items varies a lot throughout rpm, the only hard rule there is that anything spanning multiple lines in the source must use braces, even if the compiler thinks it's just one line.

I generally dislike unnecessary braces but sometimes they are introduced in anticipation for surrounding code, at other times they get left behind from other code changes, at other times they add to readability and at others, they're just ugly.

dbiCursorFree(dbi, kc);
}
if (set)
rc = sqlite_idxdbByKey(dbi, dbc->subc, dbc->key, dbc->keylen, set);
rc = RPMRC_OK;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this statement supposed to be here? It essentially clobbers the result from the line above...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit fishy alright, but it's not being introduced in this patch.

IIRC it's there for a reason though, and with this patch all the more so.

@pmatilai
Copy link
Member Author

With sqlite changes, it's worth remembering it's all very much still a work-in-progress thing and should be reviewed with different mindset than changes to released features and such. The whole db schema is likely to be revamped etc, this is all just trying out things.

@pmatilai pmatilai merged commit 0094eaa into rpm-software-management:master Dec 11, 2019
@pmatilai pmatilai deleted the sqlite-opt-pr branch January 8, 2020 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants