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

Limit parallel jobs to 1 / use in-memeory pch storage #177

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ls/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type Config struct {
EnableLogging bool
SkipLibrariesDiscoveryOnRebuild bool
DisableRealTimeDiagnostics bool
Jobs int
}

var yellow = color.New(color.FgHiYellow)
Expand Down
9 changes: 9 additions & 0 deletions ls/lsp_client_clangd.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,17 @@ func newClangdLSPClient(logger jsonrpc.FunctionLogger, dataFolder *paths.Path, l
args := []string{
ls.config.ClangdPath.String(),
"-log=verbose",
"--pch-storage=memory",
fmt.Sprintf(`--compile-commands-dir=%s`, ls.buildPath),
}
if jobs := ls.config.Jobs; jobs == -1 {
// default: limit parallel build jobs to 1
args = append(args, "-j", "1")
} else if jobs == 0 {
// no args: clangd will max out the available cores
} else {
args = append(args, "-j", fmt.Sprintf("%d", jobs))
}
if dataFolder != nil {
args = append(args, fmt.Sprintf("-query-driver=%s", dataFolder.Join("packages", "**").Canonical()))
}
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func main() {
noRealTimeDiagnostics := flag.Bool(
"no-real-time-diagnostics", false,
"Disable real time diagnostics")
jobs := flag.Int("jobs", -1, "Max number of parallel jobs. Default is 1. Use 0 to match the number of available CPU cores.")
flag.Parse()

if *loggingBasePath != "" {
Expand Down Expand Up @@ -127,6 +128,7 @@ func main() {
CliInstanceNumber: *cliDaemonInstanceNumber,
SkipLibrariesDiscoveryOnRebuild: *skipLibrariesDiscoveryOnRebuild,
DisableRealTimeDiagnostics: *noRealTimeDiagnostics,
Jobs: *jobs,
}

stdio := streams.NewReadWriteCloser(os.Stdin, os.Stdout)
Expand Down
Loading