Skip to content

Commit

Permalink
perf: use less memory (#647)
Browse files Browse the repository at this point in the history
  • Loading branch information
proost authored Oct 14, 2024
1 parent b93778c commit 1aee272
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
15 changes: 7 additions & 8 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (

type singleClient struct {
conn conn
stop uint32
cmd Builder
retry bool
retryHandler retryHandler
stop uint32
retry bool
DisableCache bool
}

Expand Down Expand Up @@ -195,13 +195,12 @@ func (c *singleClient) Close() {
}

type dedicatedSingleClient struct {
conn conn
wire wire
mark uint32
cmd Builder

retry bool
conn conn
wire wire
cmd Builder
retryHandler retryHandler
mark uint32
retry bool
}

func (c *dedicatedSingleClient) B() Builder {
Expand Down
23 changes: 11 additions & 12 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ var ErrInvalidShardsRefreshInterval = errors.New("ShardsRefreshInterval must be
type clusterClient struct {
pslots [16384]conn
rslots []conn
opt *ClientOption
sc call
rOpt *ClientOption
conns map[string]connrole
connFn connFn
sc call
opt *ClientOption
retryHandler retryHandler
stopCh chan struct{}
cmd Builder
mu sync.RWMutex
stop uint32
cmd Builder
retry bool
retryHandler retryHandler
stopCh chan struct{}
}

// NOTE: connrole and conn must be initialized at the same time
Expand Down Expand Up @@ -1143,17 +1143,16 @@ func (c *clusterClient) shouldRefreshRetry(err error, ctx context.Context) (addr
}

type dedicatedClusterClient struct {
client *clusterClient
conn conn
wire wire
pshks *pshks

client *clusterClient
conn conn
wire wire
pshks *pshks
mu sync.Mutex
cmd Builder
retryHandler retryHandler
retry bool
slot uint16
mark bool
retry bool
retryHandler retryHandler
}

func (c *dedicatedClusterClient) acquire(ctx context.Context, slot uint16) (wire wire, err error) {
Expand Down
12 changes: 6 additions & 6 deletions sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ func newSentinelClient(opt *ClientOption, connFn connFn, retryer retryHandler) (

type sentinelClient struct {
mConn atomic.Value
sConn conn
mAddr string
sAddr string
connFn connFn
mOpt *ClientOption
sOpt *ClientOption
connFn connFn
sConn conn
sentinels *list.List
mAddr string
sAddr string
sc call
retryHandler retryHandler
cmd Builder
mu sync.Mutex
stop uint32
cmd Builder
retry bool
retryHandler retryHandler
replica bool
}

Expand Down

0 comments on commit 1aee272

Please sign in to comment.