From 3554991444c979c8c4fabc62383d1a032ae3e5fe Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Mon, 6 May 2024 19:44:22 +0000 Subject: [PATCH] update go-structr -> v0.8.2 which includes some minor memory usage improvements (#2904) --- go.mod | 2 +- go.sum | 4 ++-- vendor/codeberg.org/gruf/go-structr/cache.go | 14 ++++++++++++++ vendor/codeberg.org/gruf/go-structr/item.go | 6 +++++- vendor/codeberg.org/gruf/go-structr/queue.go | 6 ++++++ vendor/modules.txt | 2 +- 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 0fb22aef3..771f5bbae 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( codeberg.org/gruf/go-runners v1.6.2 codeberg.org/gruf/go-sched v1.2.3 codeberg.org/gruf/go-store/v2 v2.2.4 - codeberg.org/gruf/go-structr v0.8.0 + codeberg.org/gruf/go-structr v0.8.2 codeberg.org/superseriousbusiness/exif-terminator v0.7.0 github.com/DmitriyVTitov/size v1.5.0 github.com/KimMachineGun/automemlimit v0.6.0 diff --git a/go.sum b/go.sum index 0705382a2..0504533bd 100644 --- a/go.sum +++ b/go.sum @@ -74,8 +74,8 @@ codeberg.org/gruf/go-sched v1.2.3 h1:H5ViDxxzOBR3uIyGBCf0eH8b1L8wMybOXcdtUUTXZHk codeberg.org/gruf/go-sched v1.2.3/go.mod h1:vT9uB6KWFIIwnG9vcPY2a0alYNoqdL1mSzRM8I+PK7A= codeberg.org/gruf/go-store/v2 v2.2.4 h1:8HO1Jh2gg7boQKA3hsDAIXd9zwieu5uXwDXEcTOD9js= codeberg.org/gruf/go-store/v2 v2.2.4/go.mod h1:zI4VWe5CpXAktYMtaBMrgA5QmO0sQH53LBRvfn1huys= -codeberg.org/gruf/go-structr v0.8.0 h1:aZ+ziv2R6zTU16PW7B2d349wY9Du3mObc3hCeUIqtME= -codeberg.org/gruf/go-structr v0.8.0/go.mod h1:K1FXkUyO6N/JKt8aWqyQ8rtW7Z9ZmXKWP8mFAQ2OJjE= +codeberg.org/gruf/go-structr v0.8.2 h1:0zH5HuOZWTVOGqIq8o5W1jRi944CQWdPXUWZfKUbF0o= +codeberg.org/gruf/go-structr v0.8.2/go.mod h1:K1FXkUyO6N/JKt8aWqyQ8rtW7Z9ZmXKWP8mFAQ2OJjE= codeberg.org/superseriousbusiness/exif-terminator v0.7.0 h1:Y6VApSXhKqExG0H2hZ2JelRK4xmWdjDQjn13CpEfzko= codeberg.org/superseriousbusiness/exif-terminator v0.7.0/go.mod h1:gCWKduudUWFzsnixoMzu0FYVdxHWG+AbXnZ50DqxsUE= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= diff --git a/vendor/codeberg.org/gruf/go-structr/cache.go b/vendor/codeberg.org/gruf/go-structr/cache.go index d9bcc58d3..17c491158 100644 --- a/vendor/codeberg.org/gruf/go-structr/cache.go +++ b/vendor/codeberg.org/gruf/go-structr/cache.go @@ -556,6 +556,12 @@ func (c *Cache[T]) Cap() int { func (c *Cache[T]) store_value(index *Index, key Key, value T) { // Alloc new index item. item := new_indexed_item() + if cap(item.indexed) < len(c.indices) { + + // Preallocate item indices slice to prevent Go auto + // allocating overlying large slices we don't need. + item.indexed = make([]*index_entry, 0, len(c.indices)) + } // Create COPY of value. value = c.copy(value) @@ -622,6 +628,14 @@ func (c *Cache[T]) store_error(index *Index, key Key, err error) { // Alloc new index item. item := new_indexed_item() + if cap(item.indexed) < len(c.indices) { + + // Preallocate item indices slice to prevent Go auto + // allocating overlying large slices we don't need. + item.indexed = make([]*index_entry, 0, len(c.indices)) + } + + // Set error val. item.data = err // Append item to index. diff --git a/vendor/codeberg.org/gruf/go-structr/item.go b/vendor/codeberg.org/gruf/go-structr/item.go index 602c5b84a..9e837e157 100644 --- a/vendor/codeberg.org/gruf/go-structr/item.go +++ b/vendor/codeberg.org/gruf/go-structr/item.go @@ -51,8 +51,12 @@ func (i *indexed_item) drop_index(entry *index_entry) { continue } + // Unset tptr value to + // ensure GC can take it. + i.indexed[x] = nil + // Move all index entries down + reslice. - copy(i.indexed[x:], i.indexed[x+1:]) + _ = copy(i.indexed[x:], i.indexed[x+1:]) i.indexed = i.indexed[:len(i.indexed)-1] break } diff --git a/vendor/codeberg.org/gruf/go-structr/queue.go b/vendor/codeberg.org/gruf/go-structr/queue.go index 91092790a..d7c21daaa 100644 --- a/vendor/codeberg.org/gruf/go-structr/queue.go +++ b/vendor/codeberg.org/gruf/go-structr/queue.go @@ -276,6 +276,12 @@ func (q *Queue[T]) pop_n(n int, next func() *list_elem) []T { func (q *Queue[T]) index(value T) *indexed_item { item := new_indexed_item() + if cap(item.indexed) < len(q.indices) { + + // Preallocate item indices slice to prevent Go auto + // allocating overlying large slices we don't need. + item.indexed = make([]*index_entry, 0, len(q.indices)) + } // Set item value. item.data = value diff --git a/vendor/modules.txt b/vendor/modules.txt index 3d8b748df..3d9374a85 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -62,7 +62,7 @@ codeberg.org/gruf/go-sched ## explicit; go 1.19 codeberg.org/gruf/go-store/v2/storage codeberg.org/gruf/go-store/v2/util -# codeberg.org/gruf/go-structr v0.8.0 +# codeberg.org/gruf/go-structr v0.8.2 ## explicit; go 1.21 codeberg.org/gruf/go-structr # codeberg.org/superseriousbusiness/exif-terminator v0.7.0