Closed hurricane618 closed 1 year ago
Hello, please send your idea and patch to the SELinux mailing list at selinux@vger.kernel.org. It is the main communication channel for this project, and it will reach a wider audience.
Also please read https://github.com/SELinuxProject/selinux/blob/master/CONTRIBUTING.md to get some hints how to contribute code
Thanks a lot, I submit my patch to SELinux mailing list.
https://lore.kernel.org/selinux/20230209114253.120485-1-wanghuizhao1@huawei.com/T/#t
In my process of using selinux, I found that when
semodule -i some.pp
loads a large number of modules with rules, the loading time increases rapidly.Then, I analyzed and found a function
nodups_specs
inlibselinux/src/label_file.c
. The algorithm complexity of implementing this function isO(N^2)
. In my use scenario, the N number would be over 20,000, so it would be performed hundreds of millions of times. It takes12s
to install the policy.Therefore, I propose an optimization solution to this problem. The purpose of this function is to check for duplicates. The original function implementation is a double-layer loop to find duplicates. I'd like to propose a new implementation that uses hash tables to check for duplicates. The algorithm complexity of new implementing is
O(N)
. The new solution is tested in my environment. The result is that the loading time is reduced to less than1s
.What do you think of this solution? I want to submit my optimization implementation to the community.