mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-22 18:22:11 +00:00
[chore]: Bump github.com/KimMachineGun/automemlimit from 0.3.0 to 0.4.0 (#2440)
Bumps [github.com/KimMachineGun/automemlimit](https://github.com/KimMachineGun/automemlimit) from 0.3.0 to 0.4.0. - [Commits](https://github.com/KimMachineGun/automemlimit/compare/v0.3.0...v0.4.0) --- updated-dependencies: - dependency-name: github.com/KimMachineGun/automemlimit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
parent
9b03840b42
commit
cd1611362f
2
go.mod
2
go.mod
|
@ -19,7 +19,7 @@ require (
|
|||
codeberg.org/gruf/go-sched v1.2.3
|
||||
codeberg.org/gruf/go-store/v2 v2.2.4
|
||||
github.com/DmitriyVTitov/size v1.5.0
|
||||
github.com/KimMachineGun/automemlimit v0.3.0
|
||||
github.com/KimMachineGun/automemlimit v0.4.0
|
||||
github.com/abema/go-mp4 v1.1.1
|
||||
github.com/buckket/go-blurhash v1.1.0
|
||||
github.com/coreos/go-oidc/v3 v3.9.0
|
||||
|
|
4
go.sum
4
go.sum
|
@ -80,8 +80,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
|
|||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/DmitriyVTitov/size v1.5.0 h1:/PzqxYrOyOUX1BXj6J9OuVRVGe+66VL4D9FlUaW515g=
|
||||
github.com/DmitriyVTitov/size v1.5.0/go.mod h1:le6rNI4CoLQV1b9gzp1+3d7hMAD/uu2QcJ+aYbNgiU0=
|
||||
github.com/KimMachineGun/automemlimit v0.3.0 h1:khgwM5ESVN85cE6Bq2ozMAAWDfrOEwQ51D/YlmThE04=
|
||||
github.com/KimMachineGun/automemlimit v0.3.0/go.mod h1:pJhTW/nWJMj6SnWSU2TEKSlCaM+1N5Mej+IfS/5/Ol0=
|
||||
github.com/KimMachineGun/automemlimit v0.4.0 h1:qOjSDbAUENEL6fiKmRKuAVhPaLijpoEHFDTE+I+prp0=
|
||||
github.com/KimMachineGun/automemlimit v0.4.0/go.mod h1:pJhTW/nWJMj6SnWSU2TEKSlCaM+1N5Mej+IfS/5/Ol0=
|
||||
github.com/abema/go-mp4 v1.1.1 h1:OfzkdMO6SWTBR1ltNSVwlTHatrAK9I3iYLQfkdEMMuc=
|
||||
github.com/abema/go-mp4 v1.1.1/go.mod h1:vPl9t5ZK7K0x68jh12/+ECWBCXoWuIDtNgPtU2f04ws=
|
||||
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
||||
|
|
1
vendor/github.com/KimMachineGun/automemlimit/README.md
generated
vendored
1
vendor/github.com/KimMachineGun/automemlimit/README.md
generated
vendored
|
@ -42,6 +42,7 @@ func init() {
|
|||
memlimit.SetGoMemLimitWithProvider(memlimit.Limit(1024*1024), 0.9)
|
||||
memlimit.SetGoMemLimitWithProvider(memlimit.FromCgroup, 0.9)
|
||||
memlimit.SetGoMemLimitWithProvider(memlimit.FromCgroupV1, 0.9)
|
||||
memlimit.SetGoMemLimitWithProvider(memlimit.FromCgroupHybrid, 0.9)
|
||||
memlimit.SetGoMemLimitWithProvider(memlimit.FromCgroupV2, 0.9)
|
||||
}
|
||||
```
|
||||
|
|
7
vendor/github.com/KimMachineGun/automemlimit/memlimit/cgroups.go
generated
vendored
7
vendor/github.com/KimMachineGun/automemlimit/memlimit/cgroups.go
generated
vendored
|
@ -21,7 +21,7 @@ func FromCgroup() (uint64, error) {
|
|||
case cgroups.Legacy:
|
||||
return FromCgroupV1()
|
||||
case cgroups.Hybrid:
|
||||
return fromCgroupHybrid()
|
||||
return FromCgroupHybrid()
|
||||
case cgroups.Unified:
|
||||
return FromCgroupV2()
|
||||
}
|
||||
|
@ -49,10 +49,9 @@ func FromCgroupV1() (uint64, error) {
|
|||
return 0, ErrNoLimit
|
||||
}
|
||||
|
||||
// fromCgroupHybrid returns the memory limit from the cgroup v1 or v2.
|
||||
// FromCgroupHybrid returns the memory limit from the cgroup v1 or v2.
|
||||
// It checks the cgroup v2 first, and if it fails, it falls back to cgroup v1.
|
||||
// TODO: make this function public in the next minor version.
|
||||
func fromCgroupHybrid() (uint64, error) {
|
||||
func FromCgroupHybrid() (uint64, error) {
|
||||
limit, err := fromCgroupV2(filepath.Join(cgroupMountPoint, "unified"))
|
||||
if err == nil {
|
||||
return limit, nil
|
||||
|
|
2
vendor/github.com/KimMachineGun/automemlimit/memlimit/cgroups_unsupported.go
generated
vendored
2
vendor/github.com/KimMachineGun/automemlimit/memlimit/cgroups_unsupported.go
generated
vendored
|
@ -11,7 +11,7 @@ func FromCgroupV1() (uint64, error) {
|
|||
return 0, ErrCgroupsNotSupported
|
||||
}
|
||||
|
||||
func fromCgroupHybrid() (uint64, error) {
|
||||
func FromCgroupHybrid() (uint64, error) {
|
||||
return 0, ErrCgroupsNotSupported
|
||||
}
|
||||
|
||||
|
|
37
vendor/github.com/KimMachineGun/automemlimit/memlimit/memlimit.go
generated
vendored
37
vendor/github.com/KimMachineGun/automemlimit/memlimit/memlimit.go
generated
vendored
|
@ -104,14 +104,14 @@ func SetGoMemLimitWithOpts(opts ...Option) (_ int64, _err error) {
|
|||
|
||||
if val, ok := os.LookupEnv(envGOMEMLIMIT); ok {
|
||||
cfg.logger.Printf("GOMEMLIMIT is set already, skipping: %s\n", val)
|
||||
return
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
ratio := cfg.ratio
|
||||
if val, ok := os.LookupEnv(envAUTOMEMLIMIT); ok {
|
||||
if val == "off" {
|
||||
cfg.logger.Printf("AUTOMEMLIMIT is set to off, skipping\n")
|
||||
return
|
||||
return 0, nil
|
||||
}
|
||||
_ratio, err := strconv.ParseFloat(val, 64)
|
||||
if err != nil {
|
||||
|
@ -119,11 +119,8 @@ func SetGoMemLimitWithOpts(opts ...Option) (_ int64, _err error) {
|
|||
}
|
||||
ratio = _ratio
|
||||
}
|
||||
if ratio <= 0 || ratio > 1 {
|
||||
return 0, fmt.Errorf("invalid AUTOMEMLIMIT: %f", ratio)
|
||||
}
|
||||
|
||||
limit, err := SetGoMemLimitWithProvider(cfg.provider, ratio)
|
||||
limit, err := setGoMemLimit(ApplyRatio(cfg.provider, ratio))
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to set GOMEMLIMIT: %w", err)
|
||||
}
|
||||
|
@ -145,33 +142,27 @@ func SetGoMemLimitWithEnv() {
|
|||
|
||||
// SetGoMemLimit sets GOMEMLIMIT with the value from the cgroup's memory limit and given ratio.
|
||||
func SetGoMemLimit(ratio float64) (int64, error) {
|
||||
return SetGoMemLimitWithProvider(FromCgroup, ratio)
|
||||
return SetGoMemLimitWithOpts(WithRatio(ratio))
|
||||
}
|
||||
|
||||
// Provider is a function that returns the memory limit.
|
||||
type Provider func() (uint64, error)
|
||||
|
||||
// SetGoMemLimitWithProvider sets GOMEMLIMIT with the value from the given provider and ratio.
|
||||
func SetGoMemLimitWithProvider(provider Provider, ratio float64) (int64, error) {
|
||||
return SetGoMemLimitWithOpts(WithProvider(provider), WithRatio(ratio))
|
||||
}
|
||||
|
||||
func setGoMemLimit(provider Provider) (int64, error) {
|
||||
limit, err := provider()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
goMemLimit := cappedFloat2Int(float64(limit) * ratio)
|
||||
debug.SetMemoryLimit(goMemLimit)
|
||||
return goMemLimit, nil
|
||||
capped := cappedU64ToI64(limit)
|
||||
debug.SetMemoryLimit(capped)
|
||||
return capped, nil
|
||||
}
|
||||
|
||||
func cappedFloat2Int(f float64) int64 {
|
||||
if f > math.MaxInt64 {
|
||||
func cappedU64ToI64(limit uint64) int64 {
|
||||
if limit > math.MaxInt64 {
|
||||
return math.MaxInt64
|
||||
}
|
||||
return int64(f)
|
||||
}
|
||||
|
||||
// Limit is a helper Provider function that returns the given limit.
|
||||
func Limit(limit uint64) func() (uint64, error) {
|
||||
return func() (uint64, error) {
|
||||
return limit, nil
|
||||
}
|
||||
return int64(limit)
|
||||
}
|
||||
|
|
40
vendor/github.com/KimMachineGun/automemlimit/memlimit/provider.go
generated
vendored
Normal file
40
vendor/github.com/KimMachineGun/automemlimit/memlimit/provider.go
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
package memlimit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// Provider is a function that returns the memory limit.
|
||||
type Provider func() (uint64, error)
|
||||
|
||||
// Limit is a helper Provider function that returns the given limit.
|
||||
func Limit(limit uint64) func() (uint64, error) {
|
||||
return func() (uint64, error) {
|
||||
return limit, nil
|
||||
}
|
||||
}
|
||||
|
||||
// ApplyRationA is a helper Provider function that applies the given ratio to the given provider.
|
||||
func ApplyRatio(provider Provider, ratio float64) Provider {
|
||||
return func() (uint64, error) {
|
||||
if ratio <= 0 || ratio > 1 {
|
||||
return 0, fmt.Errorf("invalid ratio: %f, ratio should be in the range (0.0,1.0]", ratio)
|
||||
}
|
||||
limit, err := provider()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return uint64(float64(limit) * ratio), nil
|
||||
}
|
||||
}
|
||||
|
||||
// ApplyFallback is a helper Provider function that sets the fallback provider.
|
||||
func ApplyFallback(provider Provider, fallback Provider) Provider {
|
||||
return func() (uint64, error) {
|
||||
limit, err := provider()
|
||||
if err != nil {
|
||||
return fallback()
|
||||
}
|
||||
return limit, nil
|
||||
}
|
||||
}
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
@ -63,7 +63,7 @@ codeberg.org/gruf/go-store/v2/util
|
|||
# github.com/DmitriyVTitov/size v1.5.0
|
||||
## explicit; go 1.14
|
||||
github.com/DmitriyVTitov/size
|
||||
# github.com/KimMachineGun/automemlimit v0.3.0
|
||||
# github.com/KimMachineGun/automemlimit v0.4.0
|
||||
## explicit; go 1.19
|
||||
github.com/KimMachineGun/automemlimit
|
||||
github.com/KimMachineGun/automemlimit/memlimit
|
||||
|
|
Loading…
Reference in a new issue