lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 12 Aug 2020 14:52:39 -0700
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Masahiro Yamada <masahiroy@...nel.org>
Cc:     Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
        Nathan Huckleberry <nhuck@...gle.com>,
        Tom Roeder <tmroeder@...gle.com>,
        clang-built-linux <clang-built-linux@...glegroups.com>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/3] gen_compile_commands: parse only the first line of
 .*.cmd files

On Wed, Aug 12, 2020 at 10:40 AM Masahiro Yamada <masahiroy@...nel.org> wrote:
>
> After the allmodconfig build, this script takes about 5 sec on my
> machine. Most of the run-time is consumed for needless regex matching.
>
> We know the format of .*.cmd file; the first line is the build command.
> There is no need to parse the remaining.
>
> With this optimization, now it runs in about 1 sec with the allmodconfig
> build.
>
> Signed-off-by: Masahiro Yamada <masahiroy@...nel.org>

Before your patch, my x86_64 allmodconfig:
$ /usr/bin/time -v ./scripts/gen_compile_commands.py
...
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:08.35
...
After:
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:02.10

So it's a nice speedup.
Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>
Tested-by: Nick Desaulniers <ndesaulniers@...gle.com>
small nit below:

> ---
>
>  scripts/gen_compile_commands.py | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/gen_compile_commands.py b/scripts/gen_compile_commands.py
> index c458696ef3a7..19c7338740e7 100755
> --- a/scripts/gen_compile_commands.py
> +++ b/scripts/gen_compile_commands.py
> @@ -125,11 +125,9 @@ def main():
>              filepath = os.path.join(dirpath, filename)
>
>              with open(filepath, 'rt') as f:
> -                for line in f:
> -                    result = line_matcher.match(line)
> -                    if not result:
> -                        continue
> -
> +                line = f.readline()
> +                result = line_matcher.match(line)

If `line` is not referenced beyond the following statement, consider
combining the two statement into one:
result = line_matcher.match(f.readline())

> +                if result:
>                      try:
>                          entry = process_line(directory, dirpath,
>                                               result.group(1), result.group(2))
> --
> 2.25.1
>


-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists