Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use concurrent threads for faster formatting #537

Open
davsclaus opened this issue Nov 23, 2021 · 3 comments
Open

Allow to use concurrent threads for faster formatting #537

davsclaus opened this issue Nov 23, 2021 · 3 comments

Comments

@davsclaus
Copy link
Contributor

With a 8 core M1 then when we run a clean build of Apache Camel Core then it takes 5 seconds to check all the source code files

[INFO] --- formatter-maven-plugin:2.17.0:format (format) @ camel-core ---
[INFO] Processed 2625 files in 5s26ms (Formatted: 0, Unchanged: 2625, Failed: 0, Readonly: 0)

To my understanding this is done using a single thread.

Because each file is independent then we could allow to run this with a thread pool where we can use multiple threads. For example number of cores - 1 (leave 1 core for computer to be responsive).

@ctubbsii ctubbsii added this to the 2.18.0 milestone Nov 23, 2021
@ctubbsii
Copy link
Member

This would be nice. My main concern is that some of the formatters might not be thread safe. It would make sense to initialize them once, and then reuse them for each applicable file. DEBUG log messages might get messy, too, if the formatters are running concurrently, but I don't think that's a big deal. At least, we can address that if necessary later.

Running a parallel stream of files would make this trivial to implement in the built-in shared ForkJoinPool, but the ResultCollector would have to switch to using AtomicLong for its counters.

@hazendaz
Copy link
Member

hazendaz commented Feb 2, 2022

@davsclaus Any change you had time to look into what this might take on this end? A possible PR might help.

@davsclaus
Copy link
Contributor Author

@hazendaz sorry I have not tried this

@ctubbsii ctubbsii modified the milestones: 2.18.0, 2.19.0 Mar 1, 2022
@ctubbsii ctubbsii modified the milestones: 2.19.0, 2.20.0 Jun 1, 2022
@hazendaz hazendaz removed this from the 2.20.0 milestone Jul 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants