Skip to content

Commit

Permalink
chore: update hashtriemap implementation from the latest upstream
Browse files Browse the repository at this point in the history
- Run rekres and update linters.
- Pull latest hashtriemap changes.
- Support Go 1.24 [swissmaps](golang/go#54766).

Signed-off-by: Dmitriy Matrenichev <[email protected]>
  • Loading branch information
DmitriyMV committed Dec 9, 2024
1 parent e847d2a commit ddc3af8
Show file tree
Hide file tree
Showing 14 changed files with 1,296 additions and 381 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-05-27T12:37:27Z by kres b5844f8.
# Generated on 2024-12-09T17:41:43Z by kres 8183c20.

name: default
concurrency:
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
run: |
make unit-tests-race
- name: coverage
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
files: _out/coverage-unit-tests.txt
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/slack-notify.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-03-11T19:57:58Z by kres latest.
# Generated on 2024-12-09T17:41:43Z by kres 8183c20.

name: slack-notify
"on":
Expand All @@ -24,11 +24,12 @@ jobs:
run: |
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
- name: Slack Notify
uses: slackapi/slack-github-action@v1
uses: slackapi/slack-github-action@v2
with:
channel-id: proj-talos-maintainers
method: chat.postMessage
payload: |
{
"channel": "proj-talos-maintainers",
"attachments": [
{
"color": "${{ github.event.workflow_run.conclusion == 'success' && '#2EB886' || github.event.workflow_run.conclusion == 'failure' && '#A30002' || '#FFCC00' }}",
Expand Down Expand Up @@ -88,5 +89,4 @@ jobs:
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
token: ${{ secrets.SLACK_BOT_TOKEN }}
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-10-17T09:56:58Z by kres 34e72ac.
# Generated on 2024-12-09T17:41:43Z by kres 8183c20.

# options for analysis running
run:
Expand Down Expand Up @@ -116,7 +116,6 @@ linters:
- gochecknoglobals
- gochecknoinits
- godox
- gomnd
- gomoddirectives
- gosec
- inamedparam
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# syntax = docker/dockerfile-upstream:1.10.0-labs
# syntax = docker/dockerfile-upstream:1.12.0-labs

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

ARG TOOLCHAIN

# cleaned up specs and compiled versions
FROM scratch AS generate

# runs markdownlint
FROM docker.io/oven/bun:1.1.32-alpine AS lint-markdown
FROM docker.io/oven/bun:1.1.38-alpine AS lint-markdown
WORKDIR /src
RUN bun i markdownlint-cli@0.42.0 [email protected]
RUN bun i markdownlint-cli@0.43.0 [email protected]
COPY .markdownlint.json .
COPY ./README.md ./README.md
RUN bunx markdownlint --ignore "CHANGELOG.md" --ignore "**/node_modules/**" --ignore '**/hack/chglog/**' --rules node_modules/sentences-per-line/index.js .
Expand Down
23 changes: 17 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-10-23T16:30:37Z by kres 6d3cad4.
# Generated on 2024-12-09T17:41:43Z by kres 8183c20.

# common variables

Expand All @@ -17,15 +17,15 @@ WITH_RACE ?= false
REGISTRY ?= ghcr.io
USERNAME ?= siderolabs
REGISTRY_AND_USERNAME ?= $(REGISTRY)/$(USERNAME)
PROTOBUF_GO_VERSION ?= 1.35.1
PROTOBUF_GO_VERSION ?= 1.35.2
GRPC_GO_VERSION ?= 1.5.1
GRPC_GATEWAY_VERSION ?= 2.22.0
GRPC_GATEWAY_VERSION ?= 2.24.0
VTPROTOBUF_VERSION ?= 0.6.0
GOIMPORTS_VERSION ?= 0.26.0
GOIMPORTS_VERSION ?= 0.28.0
DEEPCOPY_VERSION ?= v0.5.6
GOLANGCILINT_VERSION ?= v1.61.0
GOLANGCILINT_VERSION ?= v1.62.2
GOFUMPT_VERSION ?= v0.7.0
GO_VERSION ?= 1.23.2
GO_VERSION ?= 1.23.4
GO_BUILDFLAGS ?=
GO_LDFLAGS ?=
CGO_ENABLED ?= 0
Expand All @@ -41,11 +41,13 @@ PLATFORM ?= linux/amd64
PROGRESS ?= auto
PUSH ?= false
CI_ARGS ?=
BUILDKIT_MULTI_PLATFORM ?= 1
COMMON_ARGS = --file=Dockerfile
COMMON_ARGS += --provenance=false
COMMON_ARGS += --progress=$(PROGRESS)
COMMON_ARGS += --platform=$(PLATFORM)
COMMON_ARGS += --push=$(PUSH)
COMMON_ARGS += --build-arg=BUILDKIT_MULTI_PLATFORM=$(BUILDKIT_MULTI_PLATFORM)
COMMON_ARGS += --build-arg=ARTIFACTS="$(ARTIFACTS)"
COMMON_ARGS += --build-arg=SHA="$(SHA)"
COMMON_ARGS += --build-arg=TAG="$(TAG)"
Expand Down Expand Up @@ -145,6 +147,15 @@ target-%: ## Builds the specified target defined in the Dockerfile. The build r

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.
@$(MAKE) target-$* TARGET_ARGS="--output=type=local,dest=$(DEST) $(TARGET_ARGS)"
@PLATFORM=$(PLATFORM) DEST=$(DEST) bash -c '\
for platform in $$(tr "," "\n" <<< "$$PLATFORM"); do \
echo $$platform; \
directory="$${platform//\//_}"; \
if [[ -d "$$DEST/$$directory" ]]; then \
mv -f "$$DEST/$$directory/"* $$DEST; \
rmdir "$$DEST/$$directory/"; \
fi; \
done'

lint-golangci-lint: ## Runs golangci-lint linter.
@$(MAKE) target-$@
Expand Down
47 changes: 47 additions & 0 deletions concurrent/export_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

// Copyright 2024 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 concurrent

import (
"unsafe"
)

// NewBadHashTrieMap creates a new HashTrieMap for the provided key and value
// but with an intentionally bad hash function.
func NewBadHashTrieMap[K, V comparable]() *HashTrieMap[K, V] {
// Stub out the good hash function with a terrible one.
// Everything should still work as expected.
var m HashTrieMap[K, V]

m.init()

m.keyHash = func(_ unsafe.Pointer, _ uintptr) uintptr {
return 0
}

return &m
}

// NewTruncHashTrieMap creates a new HashTrieMap for the provided key and value
// but with an intentionally bad hash function.
func NewTruncHashTrieMap[K, V comparable]() *HashTrieMap[K, V] {
// Stub out the good hash function with a terrible one.
// Everything should still work as expected.
var (
m HashTrieMap[K, V]
mx map[string]int
)

hasher := efaceMapOf(mx)._type.Hasher
m.keyHash = func(p unsafe.Pointer, n uintptr) uintptr {
return hasher(p, n) & ((uintptr(1) << 4) - 1)
}

return &m
}
19 changes: 4 additions & 15 deletions concurrent/go122.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,15 @@

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

//nolint:revive,govet,stylecheck,nlreturn,wsl
package concurrent

import (
"math/rand/v2"
"unsafe"
)

// NewHashTrieMap creates a new HashTrieMap for the provided key and value.
func NewHashTrieMap[K, V comparable]() *HashTrieMap[K, V] {
var m map[K]V

mapType := efaceMapOf(m)
ht := &HashTrieMap[K, V]{
root: newIndirectNode[K, V](nil),
keyHash: mapType._type.Hasher,
seed: uintptr(rand.Uint64()),
}
return ht
}

// _MapType is runtime.maptype from runtime/type.go.
//
//nolint:govet
type _MapType struct {
_Type
Key *_Type
Expand All @@ -44,6 +31,8 @@ type _MapType struct {
}

// _Type is runtime._type from runtime/type.go.
//
//nolint:govet,revive
type _Type struct {
Size_ uintptr
PtrBytes uintptr // number of (prefix) bytes in the type that can contain pointers
Expand Down
71 changes: 0 additions & 71 deletions concurrent/go122_bench_test.go

This file was deleted.

35 changes: 0 additions & 35 deletions concurrent/go122_test.go

This file was deleted.

Loading

0 comments on commit ddc3af8

Please sign in to comment.