]> Cypherpunks repositories - gostls13.git/commitdiff
Revert "os: raise open file rlimit at startup"
authorBryan Mills <bcmills@google.com>
Tue, 15 Mar 2022 17:49:01 +0000 (17:49 +0000)
committerRuss Cox <rsc@golang.org>
Tue, 15 Mar 2022 18:09:24 +0000 (18:09 +0000)
This reverts CL 392415.

Reason for revert: new test is failing on at least darwin-amd64-10_14, darwin-amd64-10_15, and openbsd-arm64-jsing.

Updates #46279.

Change-Id: I2890b72f8ee74f31000d65f7d47b5bb0ed5d6007
Reviewed-on: https://go-review.googlesource.com/c/go/+/393016
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
src/os/rlimit.go [deleted file]
src/os/rlimit_test.go [deleted file]

diff --git a/src/os/rlimit.go b/src/os/rlimit.go
deleted file mode 100644 (file)
index 3e29db9..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2022 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
-
-package os
-
-import "syscall"
-
-// Some systems set an artificially low soft limit on open file count, for compatibility
-// with code that uses select and its hard-coded maximum file descriptor
-// (limited by the size of fd_set).
-//
-// Go does not use select, so it should not be subject to these limits.
-// On some systems the limit is 256, which is very easy to run into,
-// even in simple programs like gofmt when they parallelize walking
-// a file tree.
-//
-// After a long discussion on go.dev/issue/46279, we decided the
-// best approach was for Go to raise the limit unconditionally for itself,
-// and then leave old software to set the limit back as needed.
-// Code that really wants Go to leave the limit alone can set the hard limit,
-// which Go of course has no choice but to respect.
-func init() {
-       var lim syscall.Rlimit
-       if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &lim); err == nil && lim.Cur != lim.Max {
-               lim.Cur = lim.Max
-               syscall.Setrlimit(syscall.RLIMIT_NOFILE, &lim)
-       }
-}
diff --git a/src/os/rlimit_test.go b/src/os/rlimit_test.go
deleted file mode 100644 (file)
index 9bb6858..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2022 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package os_test
-
-import (
-       . "os"
-       "testing"
-)
-
-func TestOpenFileLimit(t *testing.T) {
-       // For open file count,
-       // macOS sets the default soft limit to 256 and no hard limit.
-       // CentOS and Fedora set the default soft limit to 1024,
-       // with hard limits of 4096 and 524288, respectively.
-       // Check that we can open 1200 files, which proves
-       // that the rlimit is being raised appropriately on those systems.
-       var files []*File
-       for i := 0; i < 1200; i++ {
-               f, err := Open("rlimit.go")
-               if err != nil {
-                       t.Error(err)
-                       break
-               }
-               files = append(files, f)
-       }
-
-       for _, f := range files {
-               f.Close()
-       }
-}