Skip to contentSkip to conversation

Improve Coccinelle Parallelisation

PATCH Applied Sumera Priyadarsini 2 participants 7 messages Oct 11, 2020 – Oct 12, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v4 cover Improve Coccinelle Parallelisation

Presently, Coccinelle uses at most one thread per core to improve performance in machines with more than 2 hyperthreads. Modify coccicheck to use all available threads in machines upto 4 hyperthreads. Further, modify the coccicheck script to improve portability.

Modify documentation to reflect the same.

Sumera Priyadarsini (3):
scripts: coccicheck: Add quotes to improve portability
scripts: coccicheck: Change default condition for parallelism
Documentation: Coccinelle: Modify Parallelisation information in docs

 Documentation/dev-tools/coccinelle.rst | 6 ++++--
 scripts/coccicheck                     | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v4 1/3 scripts: coccicheck: Add quotes to improve portability

While fetching the number of threads per core with lscpu, the [:digit:] set is used for translation of digits from 0-9. However, using [:digit:] instead of "[:digit:]" does not seem to work uniformly for some shell types and configurations (such as zsh).

Therefore, modify coccicheck to use double quotes around the [:digit:] set for uniformity and better portability.

---
 scripts/coccicheck | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/coccicheck +1 -1
index 6789751607f5..d67907b8a38b 100755
@@ -76,7 +76,7 @@ else
     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:])
+    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
Signature · 1 line
2.25.1
maintainer Applied
#2 lore raw

Re: [Cocci] [PATCH v4 1/3] scripts: coccicheck: Add quotes to improve portability

Quoted 10 lines · Sumera Priyadarsini

While fetching the number of threads per core with lscpu, the [:digit:] set is used for translation of digits from 0-9. However, using [:digit:] instead of "[:digit:]" does not seem to work uniformly for some shell types and configurations (such as zsh).

Therefore, modify coccicheck to use double quotes around the [:digit:] set for uniformity and better portability.

Applied, thanks.

Quoted 25 lines
---
 scripts/coccicheck | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/coccicheck +1 -2
index 6789751607f5..d67907b8a38b 100755
@@ -76,7 +76,7 @@ else
     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:])
+    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
--

2.25.1

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#3 lore raw

PATCH v4 2/3 scripts: coccicheck: Change default condition for parallelism

In reply to Sumera Priyadarsini

Currently, Coccinelle uses at most one thread per core by default in machines with more than 2 hyperthreads. However, for systems with only 4 hyperthreads, this does not improve performance.

Modify coccicheck to use all available threads in machines with upto 4 hyperthreads.

---
 scripts/coccicheck | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/coccicheck +1 -1
index d67907b8a38b..209bb0427b43 100755
@@ -79,7 +79,7 @@ else
     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
+	if [ $THREADS_PER_CORE -gt 1 -a $NPROC -gt 4 ] ; then
 		NPROC=$((NPROC/2))
 	fi
     else
Signature · 1 line
2.25.1
maintainer Applied
#4 lore raw

Re: [Cocci] [PATCH v4 2/3] scripts: coccicheck: Change default condition for parallelism

Quoted 8 lines · Sumera Priyadarsini

Currently, Coccinelle uses at most one thread per core by default in machines with more than 2 hyperthreads. However, for systems with only 4 hyperthreads, this does not improve performance.

Modify coccicheck to use all available threads in machines with upto 4 hyperthreads.

Applied, thanks.

Quoted 25 lines
---
 scripts/coccicheck | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/coccicheck +1 -2
index d67907b8a38b..209bb0427b43 100755
@@ -79,7 +79,7 @@ else
     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
+	if [ $THREADS_PER_CORE -gt 1 -a $NPROC -gt 4 ] ; then
 		NPROC=$((NPROC/2))
 	fi
     else
--

2.25.1

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#5 lore raw

PATCH v4 3/3 Documentation: Coccinelle: Modify Parallelisation information in docs

In reply to Sumera Priyadarsini

This patchset modifies coccicheck to use at most one thread per core by default in machines with more than 4 hyperthreads for optimal performance. Modify documentation in coccinelle.rst to reflect the same.

---
 Documentation/dev-tools/coccinelle.rst | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Documentation/dev-tools/coccinelle.rst +4 -2
index 74c5e6aeeff5..530d8d313601 100644
@@ -130,8 +130,10 @@ To enable verbose messages set the V= variable, for example::
 Coccinelle parallelization
 --------------------------
 
-By default, coccicheck tries to run as parallel as possible. To change
-the parallelism, set the J= variable. For example, to run across 4 CPUs::
+By default, coccicheck uses at most 1 thread per core in a machine
+with more than 4 hyperthreads. In a machine with upto 4 threads,
+all threads are used. To change the parallelism, set the J= variable.
+For example, to run across 4 CPUs::
 
    make coccicheck MODE=report J=4
 
Signature · 1 line
2.25.1
maintainer Acked-by on v4 3/3
#6 lore raw

Re: [Cocci] [PATCH v4 3/3] Documentation: Coccinelle: Modify Parallelisation information in docs

Quoted 5 lines · Sumera Priyadarsini

This patchset modifies coccicheck to use at most one thread per core by default in machines with more than 4 hyperthreads for optimal performance. Modify documentation in coccinelle.rst to reflect the same.

Jonathan, will you take this patch?

thanks,
julia

Quoted 29 lines
---
 Documentation/dev-tools/coccinelle.rst | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Documentation/dev-tools/coccinelle.rst +4 -3
index 74c5e6aeeff5..530d8d313601 100644
@@ -130,8 +130,10 @@ To enable verbose messages set the V= variable, for example::
 Coccinelle parallelization
 --------------------------
 
-By default, coccicheck tries to run as parallel as possible. To change
-the parallelism, set the J= variable. For example, to run across 4 CPUs::
+By default, coccicheck uses at most 1 thread per core in a machine
+with more than 4 hyperthreads. In a machine with upto 4 threads,
+all threads are used. To change the parallelism, set the J= variable.
+For example, to run across 4 CPUs::
 
    make coccicheck MODE=report J=4
 
--

2.25.1

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci