Skip to content

Commit

Permalink
feat: try pre-reading parent dir on dir read
Browse files Browse the repository at this point in the history
fix: use PATH_CACHE_SIZE for path info cache
  • Loading branch information
likeazir committed Oct 6, 2023
1 parent a88bd48 commit 32465ec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/pkg/netclient/netclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"io/fs"
"math"
"net"
"path/filepath"
"readnetfs/internal/pkg/cacheclient"
"readnetfs/internal/pkg/common"
"readnetfs/internal/pkg/fsclient"
Expand Down Expand Up @@ -43,7 +44,7 @@ func (f *NetClient) Purge() {
}

func NewNetClient(statsdAddrPort string, peerNodes []string) *NetClient {
fPathRemoteCache := expirable.NewLRU[fsclient.RemotePath, []string](cacheclient.MEM_TOTAL_CACHE_B/cacheclient.MEM_PER_FILE_CACHE_B,
fPathRemoteCache := expirable.NewLRU[fsclient.RemotePath, []string](cacheclient.PATH_CACHE_SIZE,
func(key fsclient.RemotePath, value []string) {}, cacheclient.PATH_TTL)
pMap := make(map[string]*PeerInfo)
for _, peer := range peerNodes {
Expand Down Expand Up @@ -175,6 +176,8 @@ func (f *NetClient) FileInfo(path fsclient.RemotePath) (fs.FileInfo, error) {
return info, nil
}
}
//trigger parent dir read to fill cache for future requests
go f.ReadDir(fsclient.RemotePath(filepath.Dir(string(path))))
_, _ = fmt.Fprintf(f.statsdSocket, "requests.outgoing.file_info:1|c\n")
return nil, errors.New("no peer has file" + string(path))
}
Expand Down

0 comments on commit 32465ec

Please sign in to comment.