Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Issue 1870263002: cipd: instance cache (Closed)

Created:
4 years, 8 months ago by nodir
Modified:
4 years, 8 months ago
Reviewers:
Vadim Sh.
CC:
chromium-reviews, infra-reviews+luci-go_chromium.org, andrew.wang, todd, tandrii+luci-go_chromium.org, M-A Ruel
Base URL:
https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Target Ref:
refs/heads/master
Project:
luci-go
Visibility:
Public.

Description

cipd: instance cache Cache package instances on file system in a shared cache, as specified by -cache-dir flag. Use LRU for GC. The implementation is similar to the one of tag cache: a binary-protobuf file with cache state is loaded/saved every time it is accessed. The state contains last access time of instances. If the state file is not found, corrupted or was not synced with fs for a long time, the state is synced. Newly discovered instances are considered last accessed at EPOCH. GC happens on sync or when an instance is added: cutoff date is determined and first N instances that were accessed before cutoff date are removed, where N is the number of instance beyond cache limit. R=vadimsh@chromium.org BUG=601017 Committed: https://github.com/luci/luci-go/commit/6c20df86be89df4837ccf85f19827e69b1cf584c

Patch Set 1 #

Patch Set 2 : cipd: instance cache #

Total comments: 16

Patch Set 3 : addressed comments #

Total comments: 2

Patch Set 4 : read/write state file each time #

Patch Set 5 : add tests, fix gc #

Total comments: 10

Patch Set 6 : restore check, improve comment #

Unified diffs Side-by-side diffs Delta from patch set Stats (+639 lines, -22 lines) Patch
M client/cipd/client.go View 1 2 3 4 5 5 chunks +79 lines, -8 lines 0 comments Download
A client/cipd/internal/instancecache.go View 1 2 3 4 1 chunk +320 lines, -0 lines 0 comments Download
A client/cipd/internal/instancecache_test.go View 1 2 3 4 1 chunk +138 lines, -0 lines 0 comments Download
M client/cipd/internal/messages/messages.proto View 1 2 3 2 chunks +19 lines, -0 lines 0 comments Download
M client/cipd/internal/messages/messages.pb.go View 2 chunks +74 lines, -14 lines 0 comments Download
M client/cmd/cipd/main.go View 1 2 2 chunks +9 lines, -0 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 23 (10 generated)
nodir
PTAL. Tested locally by doing cipd init -cache-dir ~/cipd-cache cipd install packages... Will write unit ...
4 years, 8 months ago (2016-04-08 22:35:10 UTC) #1
nodir
I will remove dep on local.FileSystem. It is an overkill
4 years, 8 months ago (2016-04-11 14:35:39 UTC) #2
Vadim Sh.
it is not, but you are not using it correctly you shouldn't be using ioutil.WriteFile: ...
4 years, 8 months ago (2016-04-11 16:29:13 UTC) #3
Vadim Sh.
also mention in the comments that cache doesn't validate hash of files (and FetchInstance too) ...
4 years, 8 months ago (2016-04-11 16:52:03 UTC) #4
nodir
https://codereview.chromium.org/1870263002/diff/20001/client/cipd/client.go File client/cipd/client.go (right): https://codereview.chromium.org/1870263002/diff/20001/client/cipd/client.go#newcode804 client/cipd/client.go:804: if _, err := output.Seek(0, 0); err != nil ...
4 years, 8 months ago (2016-04-11 22:16:17 UTC) #7
Vadim Sh.
Consider also reducing time a cache state is open, e.g. instead of doing: 1) Open. ...
4 years, 8 months ago (2016-04-11 23:47:50 UTC) #8
nodir
sigh, I did that and then saw tagcache reads and writes once per run
4 years, 8 months ago (2016-04-11 23:51:42 UTC) #9
nodir
PTAL https://codereview.chromium.org/1870263002/diff/80001/client/cipd/client.go File client/cipd/client.go (right): https://codereview.chromium.org/1870263002/diff/80001/client/cipd/client.go#newcode788 client/cipd/client.go:788: func (client *clientImpl) FetchInstance(pin common.Pin, output io.WriteSeeker) error ...
4 years, 8 months ago (2016-04-13 02:05:30 UTC) #13
nodir
Added tests, ready for review. PTAL!
4 years, 8 months ago (2016-04-13 19:15:47 UTC) #16
Vadim Sh.
lgtm https://codereview.chromium.org/1870263002/diff/200001/client/cipd/client.go File client/cipd/client.go (left): https://codereview.chromium.org/1870263002/diff/200001/client/cipd/client.go#oldcode761 client/cipd/client.go:761: err := common.ValidatePin(pin) you lost this check https://codereview.chromium.org/1870263002/diff/200001/client/cipd/client.go ...
4 years, 8 months ago (2016-04-13 21:49:02 UTC) #17
nodir
https://codereview.chromium.org/1870263002/diff/200001/client/cipd/client.go File client/cipd/client.go (left): https://codereview.chromium.org/1870263002/diff/200001/client/cipd/client.go#oldcode761 client/cipd/client.go:761: err := common.ValidatePin(pin) On 2016/04/13 21:49:02, Vadim Sh. wrote: ...
4 years, 8 months ago (2016-04-13 23:23:52 UTC) #18
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1870263002/220001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1870263002/220001
4 years, 8 months ago (2016-04-13 23:36:58 UTC) #21
commit-bot: I haz the power
4 years, 8 months ago (2016-04-13 23:40:56 UTC) #23
Message was sent while issue was closed.
Committed patchset #6 (id:220001) as
https://github.com/luci/luci-go/commit/6c20df86be89df4837ccf85f19827e69b1cf584c

Powered by Google App Engine
This is Rietveld 408576698