-
Notifications
You must be signed in to change notification settings - Fork 583
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
permissions: Rewrite the in-memory storage backend #3560
base: master
Are you sure you want to change the base?
Conversation
b5a3492
to
fa0e9ee
Compare
fa0e9ee
to
e3258db
Compare
Hello @benceszigeti , I haven't had a look at your patch, but I have a question : |
It returns the first match. For For |
If an address/subnet is defined in multiple groups, |
If an address/subnet is defined in multiple groups, `get_source_group` may return a different group than it did previously. Previously, it returned the group with the lowest group ID where the match occurred (due to how the data was stored). Therefore, I am using a linked list for groups instead of a hash table, so we do not have to look up every group to find the smallest group ID. This change is necessary for backward compatibility.
Updated the PR: changes are now backward-compatible:
|
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.
Great work on the internal refactoring, @benceszigeti! I have tested the code a bit and couldn't see any backwards-compatibility issues neither on opensips.cfg side nor MI side, so we are good to merge. Still, do make sure to add GPLv3 headers on each of the 4 new source code files! Either with copyrights to your company or just "OpenSIPS Project" as default.
And a couple optional suggestions, perhaps worthy of future work:
-
the
1.5f
bucket growth factor seems a bit off, because it generates the bucket sequence:16
,24
,36
,54
,81
,121
, etc. Most of these numbers are not powers of two, which means thecore_hash()
function will have gaps in its output hashing, meaning that some buckets will be permanently empty, while others will be extra full. Simply using a factor of2f
would fix this. -
in
new_address_node()
you could use a private, dynamic-sized struct with 4 fields (two fixed-sized and two dynamic-sized, determined at runtime) to perform x1 shm_malloc instead of x4, for all kinds of benefits (speed, better memory usage, etc.).
Summary
Removed the hardcoded entry limit in the permission module’s in-memory subnet storage and optimized lookup performance.
Details
Previously, exceeding 128 subnet entries prevented adding new subnets, requiring code modifications and custom builds to handle more. This update eliminates that limitation and enhances the scalability of in-memory storage for larger numbers of subnets and addresses.
Solution
Group Partitioning: Subnets and addresses are now partitioned by group ID in a hash table, removing the need for ordered storage and simplifying group lookups.UPDATE: Removed for backward compatibility.Compatibility
The permission module interfaces (scripting, MI) remained unchanged: except, on the MI interface, when dumping subnets or addresses, the result is not in an ordered list.UPDATE:get_source_group
can return different group if address/subnet added into multiple groups and found an another first.UPDATE: PR updated so the change is backward compatible.
Closing Issues
#2551, #2636