-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auto set GOMEMLIMIT when memory is limited (#14882)
* feat: auto set GOMEMLIMIT when memory is limited use automemlimit lib to set memory limit run check every 30s * lint: run make update * feat: fallback to system if cgroup is not available (cherry picked from commit 4940a7e) # Conflicts: # NOTICE.txt # go.mod # go.sum
- Loading branch information
1 parent
41eb467
commit 8eb527a
Showing
5 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,37 @@ Third party libraries used by the Elastic APM Server project: | |
================================================================================ | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
Dependency : github.com/KimMachineGun/automemlimit | ||
Version: v0.7.0-pre.3 | ||
Licence type (autodetected): MIT | ||
-------------------------------------------------------------------------------- | ||
|
||
Contents of probable licence file $GOMODCACHE/github.com/!kim!machine!gun/[email protected]/LICENSE: | ||
|
||
MIT License | ||
|
||
Copyright (c) 2022 Geon Kim | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
Dependency : github.com/cespare/xxhash/v2 | ||
Version: v2.3.0 | ||
|
@@ -6278,6 +6309,35 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
THE SOFTWARE. | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
Dependency : go.uber.org/zap/exp | ||
Version: v0.3.0 | ||
Licence type (autodetected): MIT | ||
-------------------------------------------------------------------------------- | ||
|
||
Contents of probable licence file $GOMODCACHE/go.uber.org/zap/[email protected]/LICENSE: | ||
|
||
Copyright (c) 2016-2024 Uber Technologies, Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
Dependency : golang.org/x/net | ||
Version: v0.34.0 | ||
|
@@ -13800,6 +13860,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
|
||
|
||
-------------------------------------------------------------------------------- | ||
<<<<<<< HEAD | ||
Dependency : github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal | ||
Version: v0.116.0 | ||
Licence type (autodetected): Apache-2.0 | ||
|
@@ -14019,6 +14080,18 @@ Licence type (autodetected): BSD-3-Clause | |
Contents of probable licence file $GOMODCACHE/github.com/pierrec/[email protected]+incompatible/LICENSE: | ||
|
||
Copyright (c) 2015, Pierre Curto | ||
======= | ||
Dependency : github.com/pbnjay/memory | ||
Version: v0.0.0-20210728143218-7b4eea64cf58 | ||
Licence type (autodetected): BSD-3-Clause | ||
-------------------------------------------------------------------------------- | ||
|
||
Contents of probable licence file $GOMODCACHE/github.com/pbnjay/[email protected]/LICENSE: | ||
|
||
BSD 3-Clause License | ||
|
||
Copyright (c) 2017, Jeremy Jay | ||
>>>>>>> 4940a7ea (feat: auto set GOMEMLIMIT when memory is limited (#14882)) | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
|
@@ -14031,7 +14104,11 @@ modification, are permitted provided that the following conditions are met: | |
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
<<<<<<< HEAD | ||
* Neither the name of xxHash nor the names of its | ||
======= | ||
* Neither the name of the copyright holder nor the names of its | ||
>>>>>>> 4940a7ea (feat: auto set GOMEMLIMIT when memory is limited (#14882)) | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
|
@@ -14047,7 +14124,10 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
|
||
<<<<<<< HEAD | ||
|
||
======= | ||
>>>>>>> 4940a7ea (feat: auto set GOMEMLIMIT when memory is limited (#14882)) | ||
-------------------------------------------------------------------------------- | ||
Dependency : github.com/pierrec/lz4/v4 | ||
Version: v4.1.21 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package beatcmd | ||
|
||
import ( | ||
"fmt" | ||
"log/slog" | ||
"time" | ||
|
||
"github.com/KimMachineGun/automemlimit/memlimit" | ||
) | ||
|
||
func adjustMemlimit(d time.Duration, logger *slog.Logger) error { | ||
if _, err := memlimit.SetGoMemLimitWithOpts( | ||
memlimit.WithProvider( | ||
memlimit.ApplyFallback( | ||
memlimit.FromCgroup, | ||
memlimit.FromSystem, | ||
), | ||
), | ||
memlimit.WithLogger(logger), | ||
memlimit.WithRefreshInterval(d), | ||
memlimit.WithRatio(0.9), | ||
); err != nil { | ||
return fmt.Errorf("failed to set go memlimit: %w", err) | ||
} | ||
return nil | ||
} |