Skip to content

Instantly share code, notes, and snippets.

@phuslu
phuslu / Dockerfile
Created April 15, 2025 08:04
alpine
# A seashell buried in the sand, meant only to hear the sea at night.
# see https://hub.docker.com/r/phuslu/alpine/
FROM alpine:3.21
RUN \
apk update && \
apk upgrade && \
apk add --update --no-cache \
bash \
bind-tools \
@phuslu
phuslu / bench_test.go
Last active January 23, 2024 10:24
fast parse DeletionTimestamp from pod
package bench
import (
"testing"
)
func BenchmarkParseDeletionTimestamp(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
_, _ = ParseDeletionTimestamp(data)
@phuslu
phuslu / cachingmap.go
Last active May 9, 2024 03:50
双缓冲实现无锁map,读取性能和GC友好度最好,一致性较差,写入延迟一般建议设置为分钟级。 https://twitter.com/phuslu/status/1745276311235395708
type CachingMap[K comparable, V any] struct {
// double buffering mechanism
index int64
maps [2]map[K]V
// write queue
queue chan struct {
key K
value V
}