Re: [PATCH 08/13 v2] libtracefs: Allow for setting filters with regex expressions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2 Apr 2021 07:29:59 +0530
sameeruddin shaik <sameeruddin.shaik8@xxxxxxxxx> wrote:

> >
> > If you left off the "^" and "$" then it would be a glob, where "*" means
> > zero or more of any character. But if you want the same in regex, you need
> > to use:
> >
> >   "^ext4.*$"  
> 
> IF we use the regex in filters, running time of the program is 
> increasing drastically.

Only if the kernel doesn't support indexing, then it would take less
than a second.

> 
> lets say,
> 
> if we give the kernel glob as a filter, its getting converted to regex 
> and running time of program is
> 
> 5 secs, in other case where we use regex, its taking 80 secs to complete.

What example did you use? And yes, regex would do the matching in user
space and globs would be processed in the kernel (unless indexing is
available, in which case it uses regex for everything). That's because
the globs in the kernel were created to speed up the selection of
multiple functions. The regex would pass in one function that matched
at a time, and that's more of a O(n^2) algorithm.

This is why the function supports both globs and regex.

For simple regex, we could optimize it to use a glob, if indexing is
not supported. I mentioned this to Tzvetomir before and we agreed that
this optimization can be done with later patches in the future, as
modern kernels (5.1 and beyond) support indexing.

-- Steve



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux