Skip to content

Limit/declare thread usage to bazel#245

Open
furtib wants to merge 3 commits into
Ericsson:mainfrom
furtib:limit-codechecker-thread-use
Open

Limit/declare thread usage to bazel#245
furtib wants to merge 3 commits into
Ericsson:mainfrom
furtib:limit-codechecker-thread-use

Conversation

@furtib

@furtib furtib commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Why:
Bazel expects its actions to use 1 thread by default.
This can result in it scheduling multiple long analysis jobs on the same machine, each trying to hog resources from the others.

What:

  • Limit thread usage of per_file to 1
  • Try declaring thread usage for the monolithic rule (only affects local execution)

Addresses:
#246

@furtib furtib self-assigned this Jun 17, 2026
@furtib furtib added the enhancement New feature or request label Jun 17, 2026
@furtib furtib requested a review from Szelethus June 17, 2026 12:48

@Szelethus Szelethus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd appreciate some more explanation, preferably in an issue on what problem we are solving here. I'll do my best to do my own research on this!

@furtib furtib requested a review from Szelethus June 18, 2026 08:53
Comment thread src/per_file_script.py
+ ["--skip", SKIP_FILE]
+ ["--config", CONFIG_FILE]
+ [COMPILE_COMMANDS_ABSOLUTE]
+ ["-j 1"] # Analysis of a single file should use a single thread!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this has no much sense for per-file :)
And I would not recommend doing changes "just for the case" too.

Comment thread src/codechecker.bzl
Comment on lines +46 to +56
def _codechecker_resource_set(_os_name, input_count):
"""
Requests thread count based on number of input files.

If requested thread count is higher than available
bazel schedules the job to run alone.
This may not work with remote machines.
"""
return {
"cpu": input_count, # analysis is run for most input files
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! And this may actually help to improve performance!
But we should be sure... Need measurement results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants