Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3333084pxa; Tue, 18 Aug 2020 12:26:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlklijDDix9Bh7BoaMjy6v/PPKsr/rdvU7a+gwS9DF41anriCnKLyWyj3kEoqFB+JBylv4 X-Received: by 2002:a17:906:7e4e:: with SMTP id z14mr21262576ejr.87.1597778812469; Tue, 18 Aug 2020 12:26:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597778812; cv=none; d=google.com; s=arc-20160816; b=ZZaTuTDxZ7lygKclQf9ejCNi52GWFUpD0e+pKur/PGyKAg4hapce7d65zoO7V3Hi8s cDXtISNzw2KrhrEJnH2JQHNuMNrsSLRUYsuUWm354951BdVrev7B9tlZ0UKSvNpTg1F4 xWfDhz9sI4DJ4cs6c/BQ0BF5eySExkZSqoEHNU6HH4QYGutVCnkoXdfEu6ua8LY23sR6 yTAriHbGqCXtiOzAYYp1I6KT4T0fKvzMPy1VMN/Oa7Q3+4zoNI11IVHLfOyc/7HVGouW GP12rDByuhbPMVUOlCBLBkLgJPGETD+D3CpqT9/TExTpKyFeQJgPiZCpzis0b+ztmfxg upLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=foGR0fGiwdN0rd86kHUK+hl2e5fXz3N4Jwx2Xbkyb0k=; b=IvMW8amt7LKz2HSZHrUAyHqqmTtSqUk8c8wLZOWEB7V3Hf4FfgDp5awTsqdDGITT4Y 8dKOX3K2Hl6j143kfhxD2qTrUmq/D9bV16YpKsDmLOfYqGg2mpDUtMF0UEga3MmLMpLQ sNCKnOqieQBOZqNoqeZabzOowxjxhuxGXspiCWBu0JIzTC0AZ8P6XjikRs+omNRZBHy0 NUfrS+dyqDnBduOxzEb1Zfu05/ti3Vc34/OSpMcbvvqhhyurDYFGOzmV8clC/yrLWhLq pP8UVbjOVR4cCnNU09Enz3NHeGZX5rpjmFXJbYlAaaicWMb/cBuYLcchzoie3eR6cbd+ Y8pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vSRd6oqd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z17si9715642edx.532.2020.08.18.12.26.28; Tue, 18 Aug 2020 12:26:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vSRd6oqd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726746AbgHRTYy (ORCPT + 99 others); Tue, 18 Aug 2020 15:24:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726682AbgHRTYy (ORCPT ); Tue, 18 Aug 2020 15:24:54 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0E04C061389 for ; Tue, 18 Aug 2020 12:24:53 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id d19so10198244pgl.10 for ; Tue, 18 Aug 2020 12:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=foGR0fGiwdN0rd86kHUK+hl2e5fXz3N4Jwx2Xbkyb0k=; b=vSRd6oqd2yNuGDNiXj92z2f1njZntPTkt8HP+/mp1t+kK6R4HgssuFX2lfgOb+qaT9 11VbEC8URgbDXYPreKg0vFh4DyyzH0ZT0sjILFM9Tbq8uCnvYXiNR2SHweMrIpaZVYUZ YSkF26FDsRj1Rae4PkAxKAM1UGefGKxbfVuk4Rw/sp5hyPs4GCb2QnOWbRtYQrGgpYjA 5J3kbQaqWKeW8GoZ/G176kPXThXKroznk6hsm8a/tRzgdlWUgS9huCCVuA+3skwdSTVX RVDnJ5HqmGmB640kh54mHHpgVCZA+SfJ09uVyOgzTJ+ap5ft1xL1GzaVZ/qiNEYNoPoW YT3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=foGR0fGiwdN0rd86kHUK+hl2e5fXz3N4Jwx2Xbkyb0k=; b=nAwkous7Q8bz5ZVK19eDGatcX1vNluMob0HChBzpxgIjHcKN9h9iT3+7XqI86Kd9Ws CldpKITdE5fC1p4d/+0Ud+FffeWYO1DXfHRheJLmHUMNYRENFNWicKcmEvndxlZ3dno+ F3XEZ0/wEruH+Hg+xBY47grON09hec6+iAnB/EAwXXJ2g2NKjSqPd5CA/A2wnmtSmJ5U c/xTrAKu1AJGp0/yM5K+XfW5UmqDuk3FIGNpWfC8rUVyY63nw8Nlt6CpB142L0x4SJbf 0WLZO+BqGmKEp8wU7aVCMfTAuPCmvK4FO9BGfWLymtMt77USKQ2PEFgYHhIUcWqauV+p 7Z2w== X-Gm-Message-State: AOAM533nqxkki2tLagz+n5MhwSQyWm8DeTsDnYelyfd8zo+c0nnhaB+Z B1kb58mfy+MkuOs/4I16N64= X-Received: by 2002:a63:955d:: with SMTP id t29mr14041544pgn.135.1597778693516; Tue, 18 Aug 2020 12:24:53 -0700 (PDT) Received: from localhost.localdomain ([49.207.204.59]) by smtp.gmail.com with ESMTPSA id h63sm647493pjb.29.2020.08.18.12.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 12:24:52 -0700 (PDT) From: Sumera Priyadarsini To: Julia.Lawall@lip6.fr Cc: Gilles.Muller@lip6.fr, nicolas.palix@imag.fr, michal.lkml@markovi.net, cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, Sumera Priyadarsini Subject: [PATCH V3] scripts: coccicheck: Change default value for parallelism Date: Wed, 19 Aug 2020 00:54:45 +0530 Message-Id: <20200818192445.24885-1-sylphrenadin@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By default, coccicheck utilizes all available threads to implement parallelisation. However, when all available threads are used, a decrease in performance is noted. The elapsed time is minimum when at most one thread per core is used. For example, on benchmarking the semantic patch kfree.cocci for usb/serial using hyperfine, the outputs obtained for J=5 and J=2 are 1.32 and 1.90 times faster than those for J=10 and J=9 respectively for two separate runs. For the larger drivers/staging directory, minimium elapsed time is obtained for J=3 which is 1.86 times faster than that for J=12. The optimal J value does not exceed 6 in any of the test runs. The benchmarks are run on a machine with 6 cores, with 2 threads per core, i.e, 12 hyperthreads in all. To improve performance, modify coccicheck to use at most only one thread per core by default. Signed-off-by: Sumera Priyadarsini --- Changes in V2: - Change commit message as suggested by Julia Lawall Changes in V3: - Use J/2 as optimal value for machines with more than 8 hyperthreads as well. --- scripts/coccicheck | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/coccicheck b/scripts/coccicheck index e04d328210ac..a72aa6c037ff 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck @@ -75,8 +75,13 @@ else OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE" fi + # Use only one thread per core by default if hyperthreading is enabled + THREADS_PER_CORE=$(lscpu | grep "Thread(s) per core: " | tr -cd [:digit:]) if [ -z "$J" ]; then NPROC=$(getconf _NPROCESSORS_ONLN) + if [ $THREADS_PER_CORE -gt 1 -a $NPROC -gt 2 ] ; then + NPROC=$((NPROC/2)) + fi else NPROC="$J" fi -- 2.17.1