Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 22c33ae

Browse filesBrowse files
committed
Allow jobs tuning via -jobs N flag
1 parent d8f48f7 commit 22c33ae
Copy full SHA for 22c33ae

File tree

3 files changed

+11
-1
lines changed
Filter options

3 files changed

+11
-1
lines changed

‎ls/ls.go

Copy file name to clipboardExpand all lines: ls/ls.go
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ type Config struct {
7777
EnableLogging bool
7878
SkipLibrariesDiscoveryOnRebuild bool
7979
DisableRealTimeDiagnostics bool
80+
Jobs int
8081
}
8182

8283
var yellow = color.New(color.FgHiYellow)

‎ls/lsp_client_clangd.go

Copy file name to clipboardExpand all lines: ls/lsp_client_clangd.go
+8-1Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,17 @@ func newClangdLSPClient(logger jsonrpc.FunctionLogger, dataFolder *paths.Path, l
5151
args := []string{
5252
ls.config.ClangdPath.String(),
5353
"-log=verbose",
54-
"-j", "1", // Limit parallel build jobs to 1
5554
"--pch-storage=memory",
5655
fmt.Sprintf(`--compile-commands-dir=%s`, ls.buildPath),
5756
}
57+
if jobs := ls.config.Jobs; jobs == -1 {
58+
// default: limit parallel build jobs to 1
59+
args = append(args, "-j", "1")
60+
} else if jobs == 0 {
61+
// no args: clangd will max out the available cores
62+
} else {
63+
args = append(args, "-j", fmt.Sprintf("%d", jobs))
64+
}
5865
if dataFolder != nil {
5966
args = append(args, fmt.Sprintf("-query-driver=%s", dataFolder.Join("packages", "**").Canonical()))
6067
}

‎main.go

Copy file name to clipboardExpand all lines: main.go
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func main() {
5656
noRealTimeDiagnostics := flag.Bool(
5757
"no-real-time-diagnostics", false,
5858
"Disable real time diagnostics")
59+
jobs := flag.Int("jobs", -1, "Max number of parallel jobs. Default is 1. Use 0 to match the number of available CPU cores.")
5960
flag.Parse()
6061

6162
if *loggingBasePath != "" {
@@ -127,6 +128,7 @@ func main() {
127128
CliInstanceNumber: *cliDaemonInstanceNumber,
128129
SkipLibrariesDiscoveryOnRebuild: *skipLibrariesDiscoveryOnRebuild,
129130
DisableRealTimeDiagnostics: *noRealTimeDiagnostics,
131+
Jobs: *jobs,
130132
}
131133

132134
stdio := streams.NewReadWriteCloser(os.Stdin, os.Stdout)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.