Skip to content

Commit cb5031d

Browse files
committed
chore: update hashtriemap implementation from the latest upstream
- Run rekres and update linters. - Pull latest hashtriemap changes. - Support Go 1.24 [swissmaps](golang/go#54766). Signed-off-by: Dmitriy Matrenichev <[email protected]>
1 parent e847d2a commit cb5031d

File tree

14 files changed

+1296
-385
lines changed

14 files changed

+1296
-385
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2024-05-27T12:37:27Z by kres b5844f8.
3+
# Generated on 2024-12-09T17:41:43Z by kres 8183c20.
44

55
name: default
66
concurrency:
@@ -77,7 +77,7 @@ jobs:
7777
run: |
7878
make unit-tests-race
7979
- name: coverage
80-
uses: codecov/codecov-action@v4
80+
uses: codecov/codecov-action@v5
8181
with:
8282
files: _out/coverage-unit-tests.txt
8383
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/slack-notify.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2024-03-11T19:57:58Z by kres latest.
3+
# Generated on 2024-12-09T17:41:43Z by kres 8183c20.
44

55
name: slack-notify
66
"on":
@@ -24,11 +24,12 @@ jobs:
2424
run: |
2525
echo pull_request_number=$(gh pr view -R ${{ github.repository }} ${{ github.event.workflow_run.head_repository.owner.login }}:${{ github.event.workflow_run.head_branch }} --json number --jq .number) >> $GITHUB_OUTPUT
2626
- name: Slack Notify
27-
uses: slackapi/slack-github-action@v1
27+
uses: slackapi/slack-github-action@v2
2828
with:
29-
channel-id: proj-talos-maintainers
29+
method: chat.postMessage
3030
payload: |
3131
{
32+
"channel": "proj-talos-maintainers",
3233
"attachments": [
3334
{
3435
"color": "${{ github.event.workflow_run.conclusion == 'success' && '#2EB886' || github.event.workflow_run.conclusion == 'failure' && '#A30002' || '#FFCC00' }}",
@@ -88,5 +89,4 @@ jobs:
8889
}
8990
]
9091
}
91-
env:
92-
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
92+
token: ${{ secrets.SLACK_BOT_TOKEN }}

.golangci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2024-10-17T09:56:58Z by kres 34e72ac.
3+
# Generated on 2024-12-09T17:41:43Z by kres 8183c20.
44

55
# options for analysis running
66
run:
@@ -116,7 +116,6 @@ linters:
116116
- gochecknoglobals
117117
- gochecknoinits
118118
- godox
119-
- gomnd
120119
- gomoddirectives
121120
- gosec
122121
- inamedparam

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# syntax = docker/dockerfile-upstream:1.10.0-labs
1+
# syntax = docker/dockerfile-upstream:1.12.0-labs
22

33
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
44
#
5-
# Generated on 2024-10-23T16:30:37Z by kres 6d3cad4.
5+
# Generated on 2024-12-09T17:41:43Z by kres 8183c20.
66

77
ARG TOOLCHAIN
88

99
# cleaned up specs and compiled versions
1010
FROM scratch AS generate
1111

1212
# runs markdownlint
13-
FROM docker.io/oven/bun:1.1.32-alpine AS lint-markdown
13+
FROM docker.io/oven/bun:1.1.38-alpine AS lint-markdown
1414
WORKDIR /src
15-
RUN bun i markdownlint-cli@0.42.0 [email protected]
15+
RUN bun i markdownlint-cli@0.43.0 [email protected]
1616
COPY .markdownlint.json .
1717
COPY ./README.md ./README.md
1818
RUN bunx markdownlint --ignore "CHANGELOG.md" --ignore "**/node_modules/**" --ignore '**/hack/chglog/**' --rules node_modules/sentences-per-line/index.js .

Makefile

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2024-10-23T16:30:37Z by kres 6d3cad4.
3+
# Generated on 2024-12-09T17:41:43Z by kres 8183c20.
44

55
# common variables
66

@@ -17,15 +17,15 @@ WITH_RACE ?= false
1717
REGISTRY ?= ghcr.io
1818
USERNAME ?= siderolabs
1919
REGISTRY_AND_USERNAME ?= $(REGISTRY)/$(USERNAME)
20-
PROTOBUF_GO_VERSION ?= 1.35.1
20+
PROTOBUF_GO_VERSION ?= 1.35.2
2121
GRPC_GO_VERSION ?= 1.5.1
22-
GRPC_GATEWAY_VERSION ?= 2.22.0
22+
GRPC_GATEWAY_VERSION ?= 2.24.0
2323
VTPROTOBUF_VERSION ?= 0.6.0
24-
GOIMPORTS_VERSION ?= 0.26.0
24+
GOIMPORTS_VERSION ?= 0.28.0
2525
DEEPCOPY_VERSION ?= v0.5.6
26-
GOLANGCILINT_VERSION ?= v1.61.0
26+
GOLANGCILINT_VERSION ?= v1.62.2
2727
GOFUMPT_VERSION ?= v0.7.0
28-
GO_VERSION ?= 1.23.2
28+
GO_VERSION ?= 1.23.4
2929
GO_BUILDFLAGS ?=
3030
GO_LDFLAGS ?=
3131
CGO_ENABLED ?= 0
@@ -41,11 +41,13 @@ PLATFORM ?= linux/amd64
4141
PROGRESS ?= auto
4242
PUSH ?= false
4343
CI_ARGS ?=
44+
BUILDKIT_MULTI_PLATFORM ?= 1
4445
COMMON_ARGS = --file=Dockerfile
4546
COMMON_ARGS += --provenance=false
4647
COMMON_ARGS += --progress=$(PROGRESS)
4748
COMMON_ARGS += --platform=$(PLATFORM)
4849
COMMON_ARGS += --push=$(PUSH)
50+
COMMON_ARGS += --build-arg=BUILDKIT_MULTI_PLATFORM=$(BUILDKIT_MULTI_PLATFORM)
4951
COMMON_ARGS += --build-arg=ARTIFACTS="$(ARTIFACTS)"
5052
COMMON_ARGS += --build-arg=SHA="$(SHA)"
5153
COMMON_ARGS += --build-arg=TAG="$(TAG)"
@@ -145,6 +147,15 @@ target-%: ## Builds the specified target defined in the Dockerfile. The build r
145147

146148
local-%: ## Builds the specified target defined in the Dockerfile using the local output type. The build result will be output to the specified local destination.
147149
@$(MAKE) target-$* TARGET_ARGS="--output=type=local,dest=$(DEST) $(TARGET_ARGS)"
150+
@PLATFORM=$(PLATFORM) DEST=$(DEST) bash -c '\
151+
for platform in $$(tr "," "\n" <<< "$$PLATFORM"); do \
152+
echo $$platform; \
153+
directory="$${platform//\//_}"; \
154+
if [[ -d "$$DEST/$$directory" ]]; then \
155+
mv -f "$$DEST/$$directory/"* $$DEST; \
156+
rmdir "$$DEST/$$directory/"; \
157+
fi; \
158+
done'
148159

149160
lint-golangci-lint: ## Runs golangci-lint linter.
150161
@$(MAKE) target-$@

concurrent/export_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
4+
5+
// Copyright 2024 The Go Authors. All rights reserved.
6+
// Use of this source code is governed by a BSD-style
7+
// license that can be found in the LICENSE file.
8+
9+
package concurrent
10+
11+
import (
12+
"unsafe"
13+
)
14+
15+
// NewBadHashTrieMap creates a new HashTrieMap for the provided key and value
16+
// but with an intentionally bad hash function.
17+
func NewBadHashTrieMap[K, V comparable]() *HashTrieMap[K, V] {
18+
// Stub out the good hash function with a terrible one.
19+
// Everything should still work as expected.
20+
var m HashTrieMap[K, V]
21+
22+
m.init()
23+
24+
m.keyHash = func(_ unsafe.Pointer, _ uintptr) uintptr {
25+
return 0
26+
}
27+
28+
return &m
29+
}
30+
31+
// NewTruncHashTrieMap creates a new HashTrieMap for the provided key and value
32+
// but with an intentionally bad hash function.
33+
func NewTruncHashTrieMap[K, V comparable]() *HashTrieMap[K, V] {
34+
// Stub out the good hash function with a terrible one.
35+
// Everything should still work as expected.
36+
var (
37+
m HashTrieMap[K, V]
38+
mx map[string]int
39+
)
40+
41+
hasher := efaceMapOf(mx)._type.Hasher
42+
m.keyHash = func(p unsafe.Pointer, n uintptr) uintptr {
43+
return hasher(p, n) & ((uintptr(1) << 4) - 1)
44+
}
45+
46+
return &m
47+
}

concurrent/go122.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,15 @@
88

99
//go:build go1.22 && !go1.24 && !nomaptypehash
1010

11-
//nolint:revive,govet,stylecheck,nlreturn,wsl
1211
package concurrent
1312

1413
import (
15-
"math/rand/v2"
1614
"unsafe"
1715
)
1816

19-
// NewHashTrieMap creates a new HashTrieMap for the provided key and value.
20-
func NewHashTrieMap[K, V comparable]() *HashTrieMap[K, V] {
21-
var m map[K]V
22-
23-
mapType := efaceMapOf(m)
24-
ht := &HashTrieMap[K, V]{
25-
root: newIndirectNode[K, V](nil),
26-
keyHash: mapType._type.Hasher,
27-
seed: uintptr(rand.Uint64()),
28-
}
29-
return ht
30-
}
31-
3217
// _MapType is runtime.maptype from runtime/type.go.
18+
//
19+
//nolint:govet
3320
type _MapType struct {
3421
_Type
3522
Key *_Type
@@ -44,6 +31,8 @@ type _MapType struct {
4431
}
4532

4633
// _Type is runtime._type from runtime/type.go.
34+
//
35+
//nolint:govet,revive
4736
type _Type struct {
4837
Size_ uintptr
4938
PtrBytes uintptr // number of (prefix) bytes in the type that can contain pointers

concurrent/go122_bench_test.go

Lines changed: 0 additions & 71 deletions
This file was deleted.

concurrent/go122_test.go

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)