SELinuxProject/selint

Pre-compute and store strlen() of string_list items

Opened this issue · 1 comments

As the content of the items of stringlists are pretty much read-only, would it make sense to pre-compute strlen() and store it in the item on stringlist-item creation?

I'm not sure how this would affect performance. A lot of the string lists may never have strlen calculated on them. I can't think of a case where we're calculating strlen on a given string_list element more than a handful of times in one execution. The main case I think would be checks, and those will typically run once per node. If a check is running strlen multiple times on the same value, it's easy to cache that locally, otherwise, we've got one per check that calls strlen for each node. Vs nodes that we never call strlen on.

My very uninformed guess is performance-wise it's a wash. And IO is our main performance issue anyways. I'm not sure I see an ease of use argument either.

If you wanted to do it, I'd defintely consider a patch, although I'd like to see performance numbers before and after.