Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2152] neofs-node: Update container list cache properly #2176

Merged
merged 4 commits into from
Jan 25, 2023

Conversation

fyrchik
Copy link
Contributor

@fyrchik fyrchik commented Dec 26, 2022

Close #2152 .
Close #2155. (?) @acid-ant
Close #2052. (?)

Update the list of all containers if needed.

Signed-off-by: Evgenii Stratonikov e.stratonikov@yadro.com

@codecov
Copy link

codecov bot commented Dec 26, 2022

Codecov Report

Merging #2176 (eaae20e) into master (dc9d41e) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master    #2176      +/-   ##
==========================================
- Coverage   30.75%   30.74%   -0.01%     
==========================================
  Files         382      382              
  Lines       28230    28231       +1     
==========================================
  Hits         8681     8681              
- Misses      18818    18819       +1     
  Partials      731      731              
Impacted Files Coverage Δ
cmd/neofs-node/cache.go 0.00% <0.00%> (ø)
cmd/neofs-node/container.go 0.00% <ø> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -312,41 +312,41 @@ func (s *ttlContainerLister) List(id *user.ID) ([]cid.ID, error) {
// All described race cases aren't critical since cache values expire anyway, we just try
// to increase cache actuality w/o huge overhead on synchronization.
func (s *ttlContainerLister) update(owner user.ID, cnr cid.ID, add bool) {
strOwner := owner.EncodeToString()
for _, key := range []string{"", owner.EncodeToString()} {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"" for "owner-less" containers? Why in this order then? I'd expect a check for direct owner hit first and a fallback then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we need both. continue inside the cycle is just for the case when we do not cache the result.

Copy link
Member

@roman-khimov roman-khimov Dec 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can "" case grow a lot in some cases? What if a container is cached as owner-less, but then is added with an owner? Something's fishy here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing bad happens -- both lists are completely independent.
I have removed caching for the full-list because on close inspection we do not really use it that often.

…Writer`

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
`Get` needs write mutex and makes our item move to top.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
We rarely need to list all containers: as one example
we need it for tree service synchronization once per epoch.
Given that cache TTL has the order of block time it makes no sense
to cache the list of all containers.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
Copy link
Member

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks a little more risky this way, but if it solves the problem and List(nil) is once-per-epoch thing then it should be OK.

@@ -314,16 +315,21 @@ func (s *ttlContainerLister) List(id *user.ID) ([]cid.ID, error) {
func (s *ttlContainerLister) update(owner user.ID, cnr cid.ID, add bool) {
strOwner := owner.EncodeToString()

val, ok := (*ttlNetCache)(s).cache.Get(strOwner)
val, ok := s.inner.cache.Peek(strOwner)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does Get -> Peek change solve?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peek is faster (read-only) and does not update the position of an item in LRU cache -- which is what we do here, we don't use anything, just passively update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants