-
Notifications
You must be signed in to change notification settings - Fork 122
Conversation
This pull request introduces 1 alert when merging 2f20bd4 into 8d138a2 - view on LGTM.com new alerts:
|
Before we get to the questions, one important thing: I added a separate I also removed Now the many questions: This is still very much broken (as you can see), but there are a lot of open questions: First the more concrete questions:
libelektra/tests/data/data_escape.c Lines 26 to 27 in 2f20bd4
libelektra/tests/ctest/test_key.c Lines 1403 to 1406 in 2f20bd4
And now some more conceptual things:
And last a few things that are still completely open:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it makes sense that you leave the mmap
stuff out and I will fix it when the rest is done?
@@ -403,6 +419,7 @@ int keyCopy (Key * dest, const Key * source) | |||
|
|||
// free old resources of destination | |||
if (!test_bit (dest->flags, KEY_FLAG_MMAP_KEY)) elektraFree (destKey); | |||
if (!test_bit (dest->flags, KEY_FLAG_MMAP_KEY)) elektraFree (destUKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The KEY_FLAG_MMAP_KEY
is a flag for the Key->key member. If I understand this correctly ukey
is a member which is separately allocated. Then we need to add a separate flag for this field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we do. key->key
and key->ukey
are always changed at the same time. Either both are NULL
or both are correctly allocated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case you're right, I was not aware of that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such invariants should also be documented in the struct.
if (key->ukey) | ||
{ | ||
key->ukey = key->ukey + destInt; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like the right direction, but there are other places we need to change. We will also need to copy this data into the mmap
region.
It is a performance thing: ideally
If your formalization brings different results in this cases, it is okay to change this. Actually the best test would be to escape und unescape random byte sequences and see if you receive the same bits.
Yes, please remove this owner stuff. It is not working anyway and it is unlikely we can have it for 1.0.
@PhilippGackstatter didn't you already make this suggestion? Do you already work on this?
Please do not provide any. Elektra 1.0 should only understand key names with the colon. We make this change either fully or not.
What about making this fail? (letting keyNew return NULL) Is there some code that really needs these empty key names? From the user view it would be nice to have an invariant that keys have a valid name. (Especially, if you already changed that wrong names let keyNew fail. The empty name would simply be yet another wrong name.)
Maybe somewhere in the future during 1.0. At the moment we make as little as possible public. |
I don't think blindly aiming for less mallocs is a good idea. Having two smaller buffers instead of one big one might for example affect cache behaviour. (e.g. Apart from that using only 2 mallocs is pretty hard (and definitely was not the case for the old
There is a test that checks all 2 byte sequences (with an extra flag it checks all 4 byte sequences). But I can add some more edge cases. Actually random tests are not good for reproducibility and just generating some fixed strings and using them doesn't really make for good tests, as most strings are won't involve any escaping.
He did yes, my question was more about the "how much granularity do we want".
There are definitely some tests that create a key with an empty name and then use
I agree. The easy solution to this would be to allow |
It's broadly covered in #3029, but I am not working on it. |
In benchmarks I saw that malloc and elektraUnescapeKeyName have about the same costs.. And it is not pure speculation that calling malloc several times is more expensive than calling it once. I do not see how this could negatively affect cache behavior, as having everything in a block should not be worse than having it scattered around in the memory. But of course I cannot exclude this possibility.
I agree. As already said, we can optimize this later when it really becomes a bottleneck. Currently malloc usually is only about 5% of the total costs (in a
I think the proposal in #3029 is good. You can say there which other cases you think of.
When grepping for
I would prefer if an invalid key is completely impossible. |
Okay so to sum up:
Questions still open:
|
A few more things came up:
|
Yes you can remove all of them (including test cases), I wrote about that just before in #3124
keyIsInactive can also be removed. If we reintroduce inactive keys, we will use meta data for it. It is not needed for 1.0.0. |
2f20bd4
to
b077488
Compare
This pull request introduces 1 alert when merging b077488 into 6aea503 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging a61af5a into 6aea503 - view on LGTM.com new alerts:
|
@markus2330 I stumbled upon a problem with the |
Although on second though, I think |
Yes, the trie internally does not know about keys anyway. I would not optimize there anything unless you find a problem. The 8 KiB should be no problem as they are only needed per mountpoint. Afaik this part was bug free since it was written. |
This pull request introduces 1 alert when merging 4da8dd4 into 69b1e93 - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging a9e6df6 into 69b1e93 - view on LGTM.com new alerts:
|
src/libs/elektra/keyhelpers.c
Outdated
|
||
if (!key->meta) key->meta = ksNew (0, KS_END); | ||
memset (key, 0, sizeof (struct _Key)); | ||
key->meta = ksNew (0, KS_END); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to not allocate key->meta eagerly? It was discussed in #3142 to not do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markus2330 The current situation is this:
Most of this works already, but I have some problems with |
Thank you for the update! Sounds very good!
Shouldn't it be called keySetName? Or is elektraKeySetName still needed? |
No its not needed anymore, I just didn't update that part yet. |
I ended up validating the whole key name (except for the namespace) in reverse, but there are now working versions of |
380ddbd
to
27babaa
Compare
@markus2330 Do you know which storage plugins support metadata? Is there some way to easily find out, other than looking at the code? |
@mpranj What do you want to tell us? Yes, the PR is insanely huge, but it can't be any smaller... Changing a basic fact about key names (colon after namespace) will naturally break everything. You could use the VS Code Github Extension, if you are interesting the contents of this PR. It seems it is able to handle the enormous size of the PR. |
@kodebach I just thought it's funny that github cannot handle this PR. It's clear that the change implies huge changes in the complete codebase. |
@markus2330 Whats the plan for the Python 2 binding? Are we going to remove it soon? Or do I have to fix it? |
It will be removed soon via #3291. |
I hit a problem with The specific circumstances in which this caused a problem is the
Also the file I don't know why this didn't happen before the key name update. Does anyone have an idea, where these keys should be removed or what else should happen to avoid this problem? PS. Everything else should be working now. Apart from documentation, I am now just waiting for #2969, so that I can rebase. |
Do you mean being able to store arbitrary metadata? Then it should be:
Hopefully I did not forget one. |
Yes, thanks. I think
We'll find out if someone notices incompatible files, because of the |
Hey @kodebach, sorry this PR has been sitting around for so long. Since we had a fresh release this week I think it could make sense to rebase & finish this up. The backend plugin will take a bit longer so we could actually merge this PR first. What do you think about including it in the next release and do you even have time to pick up and finish this work? |
I created #3447. It contains the same commits as this PR, but squashed and rebased onto
I don't know when the next release is going to be, but I am quite certain that I won't have time to finish this PR before July. However, if somebody else has the time, feel free to help. IIRC the main part of this PR is finished, it is just a matter of updating code that was added since last year and some bug fixing. |
Implements #3102
Closes #3050
Closes #3084
Closes #2698
Closes #3082
Basics
These points need to be fulfilled for every PR:
(added as entry in
doc/news/_preparation_next_release.md
whichcontains
_(my name)_
)Please always add something to the release notes.
(first line should have
module: short statement
syntax)close #X
, are in the commit messages.Checklist
(not in the PR description)
Review