Skip to content

Commit

Permalink
reflow: Make raising of FD limit work on OS X/Go 1.12
Browse files Browse the repository at this point in the history
Summary:
This commit implements a workaround to an issue [[ golang/go#30401 |  introduced in Go 1.12 ]].

The behavior of `Setrlimit` changed to no longer succeed when the requested limit exceeded the maximum.  (It used to succeed, clamping the value to the allowed maximum).

Test Plan: Manual testing

Reviewers: smahadevan, pgopal, marius

Reviewed By: marius

Maniphest Tasks: T17776

Differential Revision: https://phabricator.grailbio.com/D27211

fbshipit-source-id: 8be13f0
  • Loading branch information
jcharum authored and mariusae committed May 13, 2019
1 parent 0829d68 commit 81c62ca
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
_ "net/http/pprof"
"os"
"os/signal"
"runtime"
"runtime/pprof"
"sort"
"syscall"
Expand Down Expand Up @@ -416,6 +417,15 @@ func increaseFDRlimit() error {
return nil
}
l.Cur = l.Max

// The following is a workaround for this issue:
// https://github.com/golang/go/issues/30401
if runtime.GOOS == "darwin" && l.Cur > 24576 {
// The max file limit is 24576, even though the max returned by
// Getrlimit is 1<<63-1.
l.Cur = 24576
}

return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &l)
}

Expand Down

0 comments on commit 81c62ca

Please sign in to comment.