Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

global-plugins: mark placements #874

Closed
wants to merge 24 commits into from

Conversation

mpranj
Copy link
Member

@mpranj mpranj commented Aug 1, 2016

Introducing only a few of the proposed global plugin placements.

@markus2330
Copy link
Contributor

Can you mark the placements you found to be best nevertheless and write why they are not ideal? The foreach and init placements are also missing.

@@ -447,6 +447,8 @@ int kdbClose (KDB * handle, Key * errorKey)
*/
static int elektraGetCheckUpdateNeeded (Split * split, Key * parentKey)
{
// GLOBAL: getresolver [init]
Copy link
Contributor

Choose a reason for hiding this comment

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

init could be even earlier directly in kdbGet?

@markus2330
Copy link
Contributor

markus2330 commented Aug 4, 2016

There are some improvements! Maybe its better to directly work on the implementation now (instead of only having comments for placements) because you need to split some loops and some control flow needs changes because of deinit.

It would be good if you have a helper function/macro for executing the hooks so that the hooks are better visible/readable.

@mpranj
Copy link
Member Author

mpranj commented Aug 4, 2016

@markus2330 thanks for the feedback. Yes indeed, I think it's better to switch to concrete code now.

Did you find anything that was completely misplaced in general? I was unsure about what semantics was wanted, but it will be unambiguous with concrete code anyway.

I was already planning on having a function or macro to keep the verbosity/boilerplate code about the same as the current comments (one-liners). It would introduce a lot of duplicate code otherwise.

if (handle->globalPlugins[PRECOMMIT])
{
handle->globalPlugins[PRECOMMIT]->kdbSet (handle->globalPlugins[PRECOMMIT], ks, parentKey);
}

elektraSetCommit (split, parentKey);
// GLOBAL: commit [init]
Copy link
Contributor

Choose a reason for hiding this comment

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

should be before elektraSetCommit

Copy link
Contributor

Choose a reason for hiding this comment

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

or is even alias for precommit?

@markus2330
Copy link
Contributor

I already commented about some issues, but they are minor and it would also be trivial to fix the issues with code.

Maybe @tom-wa, @Namoshek, @waht or @KurtMi can find further problems, they already used (or even implemented) hooks.

Another approach would be to pinpoint problems within the test cases, maybe you can write some of them upfront? The desired sequence of called hooks in certain situations should be easy to check.


// GLOBAL: postgetstorage [init]
// GLOBAL: postgetstorage [max once]

Copy link
Contributor

@tom-wa tom-wa Aug 5, 2016

Choose a reason for hiding this comment

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

just for your information: elektraGetDoUpdatewithGlobalHooks gets called twice (thats why there's the run parameter)
you've used if statements for the set placements but not here, so i'm not sure if you've thought of that

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I did think of that since we discussed it in a meeting.

All of these are just rough markers where I thought the hooks could be placed.

@mpranj
Copy link
Member Author

mpranj commented Aug 5, 2016

Then I don't think that it would make sense for anyone to review it yet, so don't waste your time.
It would be appreciated when the code is ready.

@mpranj mpranj force-pushed the global-plugins branch 2 times, most recently from f4a9715 to b7aa731 Compare October 4, 2016 20:01
@mpranj mpranj force-pushed the global-plugins branch 2 times, most recently from 48739f2 to c007bf0 Compare November 17, 2016 01:22
@mpranj
Copy link
Member Author

mpranj commented Nov 17, 2016

This does not yet comply with the proposal for global plugins, but it adds some more positions which would be useful for #1072. (postgetstorage/deinit in particular)

@markus2330 would you consider merging the available part of the implementation already? Then I could continue working in another PR while @Namoshek could start using it already.

@Namoshek
Copy link
Contributor

Not much success so far. I used postgetstorage/init as well as postgetstorage/deinit, but it doesn't seem to work. Could also be that I'm doing something wrong or my plugin does something wrong, but I don't know how to test it (with unit tests) as global plugin.

I had to change the last function in cmake/Modules/LibAddMacros.cmake by the way, it did not accept slashes for infos/placements. You could add this to your PR (replace [a-zA-Z0-9 ]*) by [a-zA-Z0-9/ ]*).

@mpranj
Copy link
Member Author

mpranj commented Nov 17, 2016

@Namoshek, you have to either:

  • use kdb global-mount to mount it
  • or configure it manually like it's done in tests/shell/shell_recorder/globaltest.esr by setting the apropriate keys. Note that after setting the keys you need to kdbClose and then kdbOpen again. Otherwise the mount procedure is not done.

Yes, infos/placements is very misleading w.r.t. global plugins and (currently) has nothing to do with it.

@Namoshek
Copy link
Contributor

Yes, infos/placements is very misleading w.r.t. global plugins and (currently) has nothing to do with it.

Ok, that info is (obviously) very important, thanks for pointing it out. Now I also understand why you want to inform the plugin in what stage it is executed (would definitely make sense to limit the cachefilter plugin here to one state, as it could potentially increase execution time enormously, although it shouldn't matter if it is executed 20 times (from a functional perspective)).

use kdb global-mount to mount it

That is what I did and I also confirmed it by listing the elektra keys with kdb ls system/elektra and getting the global plugin values (one is spec, the other cachefilter). So it should definitely be mounted. And of course I also restarted the service. I'll try once more and add some logging output to the plugin, maybe this helps.

Thank you so far!

@mpranj
Copy link
Member Author

mpranj commented Nov 17, 2016

If it doesn't seem to work don't waste too much time. I'll look into it on saturday. Can't do any sooner. It's possible that the placement is not executed.

@markus2330
Copy link
Contributor

@mpranj Can you make this ready to merge? We now have two month to get rid of all issues.

@mpranj
Copy link
Member Author

mpranj commented Nov 23, 2016

@markus2330 I'm pretty busy but it's already on my asap list. I'd expect it to be ready within a week.

Namoshek and others added 23 commits January 2, 2017 20:57
Simplify and revamp mount.c to be able to mount the newly defined global positions.

Use a macro to generate positions and subpositions. This makes the
system more flexible to add/remove positions later.

Use a function to execute global plugins and keep boilerplate code
minimal.

Add very simple and basic shell recorder test to test if mounting and
executing the global plugins still works.
Calls the correct kdb operation on plugins (Get,Set,Error), was
previously only kdbGet.
Add the elektraGlobal{Get,Set,Error} functions.
This seemed more practical than using macros everywhere.
@@ -42,7 +42,7 @@ int elektraCachefilterGet (Plugin * handle, KeySet * returned, Key * parentKey)
void * cache = elektraPluginGetData (handle);
if (cache == NULL)
{
toBeCached = ksNew (ksGetSize (returned), KS_END);
toBeCached = ksNew (0, KS_END);
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you benchmark this? It might waste some space but should avoid many reallocations (for larger keysets).

Copy link
Member Author

Choose a reason for hiding this comment

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

No I didn't but this change is also not crucial.

The code of ksAppend, which is used later here, does suggest that it uses only one resize in advance.

I wanted to let the core decide about the allocation but if you're saying this is bad I don't mind undoing this. The objective was to get rid of the memleaks and move forward.

Copy link
Contributor

Choose a reason for hiding this comment

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

No I didn't but this change is also not crucial.

Thus I wondered why you changed it. Comments help in such situations.

But you are right, lets move forward for now. Before you start changing ksNew (to be suitable for mmap), it would be great to have benchmarks for such reallocations.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep you're right. I undid the change because it was unfounded.

@mpranj
Copy link
Member Author

mpranj commented Jan 2, 2017

@markus2330 I'll close this PR today (I just kept it for the buildbots and some remaining infos).

Do you want me to do a PR on cachefilter or do you want to merge cachefilter to master if the memleaks are fixed now?

@markus2330
Copy link
Contributor

I'll close this PR today (I just kept it for the buildbots and some remaining infos).

Perfect, it is overdue!

Do you want me to do a PR on cachefilter or do you want to merge cachefilter to master if the memleaks are fixed now?

I am okay with both: You can create a single PR with all changes (and close #1078); or update #1078 and create a separate PRs for different modules. In any case, please keep changes of separate modules in separate commits.

@mpranj mpranj closed this Jan 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants