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

Issue 6574 - Move pblock access from switch to func table #6575

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mreynolds389
Copy link
Contributor

Description

Currently there are over 300 switch cases for getting/setting pblock parameters.

Instead we should have separate functions for each parameter, and use a callback function pointer table.

This also combines all the parameter definitions to a single ordered list. This will make future changes much easier to implement.

Relates: #6574

@mreynolds389
Copy link
Contributor Author

As for performance, with ldclt doing exact searches I do see a 5% - 8% performance improvement when the number of threads is increased to 16 (matching the hardware). Under less load I don't really see an improvement. So there is a benefit when the server is being hit hard.

Copy link
Contributor

@Firstyear Firstyear left a comment

Choose a reason for hiding this comment

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

Not every day you get a 5 to 8% improvement! That's amazing to see :)

@mreynolds389
Copy link
Contributor Author

Not every day you get a 5 to 8% improvement! That's amazing to see :)

Well its only under certain load types - it's not across the board :-) But yes I see an improvement when all the workers are working

Copy link
Member

@droideck droideck left a comment

Choose a reason for hiding this comment

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

Besides a couple of minor issues, it looks like a simple but powerful fix! Nice find!

Comment on lines -375 to -377
#ifdef PBLOCK_ANALYTICS
pblock_analytics_record(pblock, arg);
#endif
Copy link
Member

Choose a reason for hiding this comment

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

This analytics code (and the one in _set) were removed. Should we still keep it? Or it's not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This analytics code (and the one in _set) were removed. Should we still keep it? Or it's not used?

I'm not 100% what these are for. I assumed it was for measuring how we accessed the pblock, but I have a feeling this is no longer needed. Perhaps we can remove it in a separate PR?

Comment on lines 34 to 43
/******* Deprecated (obsolete) pblock arg identifiers ************************/
#define SLAPI_CONFIG_FILENAME 40 /* use config. entries instead */
#define SLAPI_CONFIG_LINENO 41 /* use config. entries instead */
#define SLAPI_CONFIG_ARGC 42 /* use config. entries instead */
#define SLAPI_CONFIG_ARGV 43 /* use config. entries instead */
#define SLAPI_CONN_AUTHTYPE 144 /* use SLAPI_CONN_AUTHTYPE */
#define SLAPI_REQUESTOR_ISUPDATEDN SLAPI_IS_REPLICATED_OPERATION
#define SLAPI_CONN_CLIENTIP 145 /* use SLAPI_CONN_CLIENTNETADDR */
#define SLAPI_CONN_SERVERIP 146 /* use SLAPI_CONN_SERVERNETADDR */

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 we should mention the removal in the commit message.

But also, we have some leftovers in test/libslapd/pblock/pblock_accessors* and a bit in _slapi_pblock_deprecated in ldap/servers/slapd/pblock_v3.h.

IMO, it'll be cleaner to remove the code in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left this as is with the new commit

Copy link
Contributor

@tbordaz tbordaz left a comment

Choose a reason for hiding this comment

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

The change looks good and perf improvement very nice. IIUC a former customer plugin will require to be rebuilt, correct ?

@@ -6977,50 +6974,6 @@ slapi_timer_result slapi_timespec_expire_check(struct timespec *expire);
* into tombstone
*/

/*
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not like the massive change in slapi-plugin.h
(looks like a risk of breaking existing custom plugin
And after a closer look as you changed the #define values, it will definitively break the binary compatibility
with existing custom plugin.
IMHO we should not do this. we should be able to split the switches without changing slapi-plugin.h

Copy link
Contributor

Choose a reason for hiding this comment

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

an option would be to have a conversion table that convert a former define value into an index into the callback table

Copy link
Contributor

Choose a reason for hiding this comment

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

FYI, or you can do a simple table:
here is a python script that generate a skeleton of what it would looks like:
split_pblock_switches.py.txt

@mreynolds389
Copy link
Contributor Author

The change looks good and perf improvement very nice. IIUC a former customer plugin will require to be rebuilt, correct ?

@progier389 @tbordaz Yeah you guys are right, but the problem is that the callback table will have thousands of empty slots to fill in the gaps between the #define numbers. Maybe we can use a hash table instead?

@progier389
Copy link
Contributor

Having a single table with hole will be faster than an hash table (there will be a single indirection versus hash computation)
In fact if we ignore SLAPI_HINT (which is purely internal and can be changed) the maximum value is slightly below 2000
Having hole is not really an issue: holes are just a pointeur to a function that logs error

@mreynolds389
Copy link
Contributor Author

mreynolds389 commented Feb 4, 2025

Having a single table with hole will be faster than an hash table (there will be a single indirection versus hash computation) In fact if we ignore SLAPI_HINT (which is purely internal and can be changed) the maximum value is slightly below 2000 Having hole is not really an issue: holes are just a pointeur to a function that logs error

I guess I got caught up in maintainability and trying to fix how sloppy our current code is (in regards to defines). Anyway I'll undo the slapi-plugin change and adjust the tables in pblock.c

};

int
slapi_pblock_set(Slapi_PBlock *pblock, int arg, void *value)
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 we still need PR_ASSERT(NULL != pblock); here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we still need PR_ASSERT(NULL != pblock); here.

Agreed, done!

Description

Currently there are over 300 switch cases for getting/setting pblock parameters.

Instead we should have separate functions for each parameter, and use a callback
function pointer table.

Relates: 389ds#6574

Reviewed by: spichugi, firstyear, progier, tbordaz (Thanks!!!!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants