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 f2ebe46

Browse filesBrowse files
authored
Merge pull request #1122 from nevkontakte/issue470
Improve nodejs stack size limit heuristic.
2 parents d431144 + 718e189 commit f2ebe46
Copy full SHA for f2ebe46

File tree

1 file changed

+11
-4
lines changed
Filter options

1 file changed

+11
-4
lines changed

‎tool.go

Copy file name to clipboardExpand all lines: tool.go
+11-4Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -891,17 +891,24 @@ func runNode(script string, args []string, dir string, quiet bool, out io.Writer
891891
// - OS process limit
892892
// - Node.js (V8) limit
893893
//
894-
// GopherJS fetches the current OS process limit, and sets the
895-
// Node.js limit to the same value. So both limits are kept in sync
896-
// and can be controlled by setting OS process limit. E.g.:
894+
// GopherJS fetches the current OS process limit, and sets the Node.js limit
895+
// to a value slightly below it (otherwise nodejs is likely to segfault).
896+
// The backoff size has been determined experimentally on a linux machine,
897+
// so it may not be 100% reliable. So both limits are kept in sync and can
898+
// be controlled by setting OS process limit. E.g.:
897899
//
898900
// ulimit -s 10000 && gopherjs test
899901
//
900902
cur, err := sysutil.RlimitStack()
901903
if err != nil {
902904
return fmt.Errorf("failed to get stack size limit: %v", err)
903905
}
904-
allArgs = append(allArgs, fmt.Sprintf("--stack_size=%v", cur/1000)) // Convert from bytes to KB.
906+
cur = cur / 1024 // Convert bytes to KiB.
907+
defaultSize := uint64(984) // --stack-size default value.
908+
if backoff := uint64(64); cur > defaultSize+backoff {
909+
cur = cur - backoff
910+
}
911+
allArgs = append(allArgs, fmt.Sprintf("--stack_size=%v", cur))
905912
}
906913

907914
allArgs = append(allArgs, script)

0 commit comments

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