Skip to content

Commit

Permalink
Switch to github.com/hashicorp/golang-lru/arc/v2 (#5363)
Browse files Browse the repository at this point in the history
The ARC code disappeared from github.com/hashicorp/golang-lru/[email protected]
and reappeared in a new module, github.com/hashicorp/golang-lru/arc/v2.
(You'd think that change would warrant a new major version number but a
golang-lru maintainer says you're wrong.)

Switching to this module will allow us to upgrade to
github.com/apache/arrow-go/v18, which has an indirect dependency on
github.com/hashicorp/golang-lru/[email protected].
  • Loading branch information
nwt authored Oct 24, 2024
1 parent bb91e09 commit fe6a967
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/golang/mock v1.5.0
github.com/gorilla/mux v1.7.5-0.20200711200521-98cb6bf42e08
github.com/gosuri/uilive v0.0.4
github.com/hashicorp/golang-lru/v2 v2.0.1
github.com/hashicorp/golang-lru/arc/v2 v2.0.7
github.com/kr/text v0.2.0
github.com/lestrrat-go/strftime v1.0.6
github.com/paulbellamy/ratecounter v0.2.0
Expand Down Expand Up @@ -53,6 +53,7 @@ require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/flatbuffers v23.5.26+incompatible // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/asmfmt v1.3.2 // indirect
github.com/klauspost/compress v1.16.7 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,10 @@ github.com/gosuri/uilive v0.0.4 h1:hUEBpQDj8D8jXgtCdBu7sWsy5sbW/5GhuO8KBwJ2jyY=
github.com/gosuri/uilive v0.0.4/go.mod h1:V/epo5LjjlDE5RJUcqx8dbw+zc93y5Ya3yg8tfZ74VI=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru/v2 v2.0.1 h1:5pv5N1lT1fjLg2VQ5KWc7kmucp2x/kvFOnxuVTqZ6x4=
github.com/hashicorp/golang-lru/v2 v2.0.1/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/hashicorp/golang-lru/arc/v2 v2.0.7 h1:QxkVTxwColcduO+LP7eJO56r2hFiG8zEbfAAzRv52KQ=
github.com/hashicorp/golang-lru/arc/v2 v2.0.7/go.mod h1:Pe7gBlGdc8clY5LJ0LpJXMt5AmgmWNH1g+oFFVUHOEc=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/influxdata/influxdb v1.7.6/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY=
Expand Down
14 changes: 7 additions & 7 deletions lake/commits/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/brimdata/super/zio"
"github.com/brimdata/super/zio/zngio"
"github.com/brimdata/super/zngbytes"
lru "github.com/hashicorp/golang-lru/v2"
arc "github.com/hashicorp/golang-lru/arc/v2"
"github.com/segmentio/ksuid"
"go.uber.org/zap"
)
Expand All @@ -31,21 +31,21 @@ type Store struct {
logger *zap.Logger
path *storage.URI

cache *lru.ARCCache[ksuid.KSUID, *Object]
paths *lru.ARCCache[ksuid.KSUID, []ksuid.KSUID]
snapshots *lru.ARCCache[ksuid.KSUID, *Snapshot]
cache *arc.ARCCache[ksuid.KSUID, *Object]
paths *arc.ARCCache[ksuid.KSUID, []ksuid.KSUID]
snapshots *arc.ARCCache[ksuid.KSUID, *Snapshot]
}

func OpenStore(engine storage.Engine, logger *zap.Logger, path *storage.URI) (*Store, error) {
cache, err := lru.NewARC[ksuid.KSUID, *Object](1024)
cache, err := arc.NewARC[ksuid.KSUID, *Object](1024)
if err != nil {
return nil, err
}
paths, err := lru.NewARC[ksuid.KSUID, []ksuid.KSUID](1024)
paths, err := arc.NewARC[ksuid.KSUID, []ksuid.KSUID](1024)
if err != nil {
return nil, err
}
snapshots, err := lru.NewARC[ksuid.KSUID, *Snapshot](32)
snapshots, err := arc.NewARC[ksuid.KSUID, *Snapshot](32)
if err != nil {
return nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions lake/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"github.com/brimdata/super/zio/zngio"
"github.com/brimdata/super/zngbytes"
"github.com/brimdata/super/zson"
lru "github.com/hashicorp/golang-lru/v2"
arc "github.com/hashicorp/golang-lru/arc/v2"
"github.com/segmentio/ksuid"
"go.uber.org/zap"
)
Expand All @@ -44,7 +44,7 @@ type Root struct {
logger *zap.Logger
path *storage.URI

poolCache *lru.ARCCache[ksuid.KSUID, *Pool]
poolCache *arc.ARCCache[ksuid.KSUID, *Pool]
pools *pools.Store
vCache *vcache.Cache
}
Expand All @@ -55,7 +55,7 @@ type LakeMagic struct {
}

func newRoot(engine storage.Engine, logger *zap.Logger, path *storage.URI) *Root {
poolCache, err := lru.NewARC[ksuid.KSUID, *Pool](1024)
poolCache, err := arc.NewARC[ksuid.KSUID, *Pool](1024)
if err != nil {
panic(err)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/storage/cache/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import (

"github.com/brimdata/super/lake/data"
"github.com/brimdata/super/pkg/storage"
lru "github.com/hashicorp/golang-lru/v2"
arc "github.com/hashicorp/golang-lru/arc/v2"
"github.com/prometheus/client_golang/prometheus"
)

type LocalCache struct {
storage.Engine
metrics
lru *lru.ARCCache[string, []byte]
lru *arc.ARCCache[string, []byte]
cacheable Cacheable
}

func NewLocalCache(engine storage.Engine, cacheable Cacheable, size int, registerer prometheus.Registerer) (*LocalCache, error) {
lru, err := lru.NewARC[string, []byte](size)
lru, err := arc.NewARC[string, []byte](size)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit fe6a967

Please sign in to comment.