Skip to contentSkip to conversation

Two optimizations for libsepol

PATCH New Adam Tkac 1 participant 1 message May 25, 2012 SELinux security module

lore
Share & tools
lore

Adam Tkac

author
#0 lore raw

PATCH 1/1 Two optimizations for libsepol

Hello all,

I've just finished two optimizations which speeds-up libsepol's expand_filename_trans() function. Various se* commands (like setsebool, semodule) now consumes only 15% of CPU time compared to current expand_filename_trans() implementation.

The first patch is fairly simple and straightforward.

The second patch improves main expand_filename_trans() headache, comparsion of two linked lists. It chunks the second list by filename_trans->stype value and now algorithm walks only through piece of list where all elements have matching filename_trans->stype value.

As an example, semodule run time is greatly decreased on my machine:

Original libsepol:

# time /usr/sbin/semodule -b /etc/selinux/targeted/modules/active/base.pp
real    1m54.548s
user    1m51.535s
sys     0m0.875s

After the first patch:

# time /usr/sbin/semodule -b /etc/selinux/targeted/modules/active/base.pp
real    1m43.243s
user    1m40.247s
sys     0m0.902s

Both patches applied:

# time /usr/sbin/semodule -b /etc/selinux/targeted/modules/active/base.pp
real    0m20.752s
user    0m18.508s
sys     0m0.984s

Any comments are welcomed.

Regards, Adam

Signature · 1 line
Adam Tkac, Red Hat, Inc.