[PATCH] D141230: [clang-format-diff.py] give clang-format-diff a job pool (10x speed)

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 12 07:16:12 PST 2023


MyDeveloperDay requested changes to this revision.
MyDeveloperDay added a comment.
This revision now requires changes to proceed.

On my laptop  running

  import os;
  import multiprocessing
  
  
  def main():
      num = len(os.sched_getaffinity(0))
      numcpu = multiprocessing.cpu_count()
      print ('affinity', num, '\n');
      print ('cpucount', numcpu, '\n');
  
  if __name__ == '__main__':
    main()

produces

  affinity 16
  
  cpucount 16

Does the * 8 mean I might get 128?

Do I want 16 parallel clang-format processes running at once? (especially if some of the files are memory hungry)

I'm with @owenpan here I am happy to use a -j N option when I need more power, and N default should be 1 otherwise we could be causing a regression, I'm not a fan of processes that assume thats the only thing running on my machine (cough visual studio!), and there always should be some way of saying do what we did before.



================
Comment at: clang/tools/clang-format/clang-format-diff.py:106
+  try:
+    procs = [None for i in range(len(os.sched_getaffinity(0)) * 8)]
+  except AttributeError as e:
----------------
is this 128 parallel processes?


================
Comment at: clang/tools/clang-format/clang-format-diff.py:115
+      # determined.
+      procs = [None for i in range(8)]
 
----------------
is 8 a good number here?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141230/new/

https://reviews.llvm.org/D141230



More information about the cfe-commits mailing list