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

Refactor how data is loaded in KVS walk/lookup #1069

Closed
wants to merge 4 commits into from

Conversation

chu11
Copy link
Member

@chu11 chu11 commented May 18, 2017

Per discussion in #1066, it is difficult to splice out some of the KVS functions into separate files/APIs b/c of dependencies in certain libraries/calls. One of the major dependencies was functions calling the load() function, which may load data from the KVS cache, or issue a RPC to the content cache and stall.

This patch refactors the walk() and lookup() functions to not load data from the content cache or stall. Instead, it only checks the KVS cache. If the KVS cache does not have the data that it desires, the missing reference is passed all the way back to the caller. It is then the caller's responsibility to call load() which will issue a RPC to the content cache.

This decoupling will eventually allow us to splice off some functions like walk() into other convenience APIs/files.

@garlick
Copy link
Member

garlick commented May 18, 2017

Does that mean nothing will ever end up in the cache? Or does the original caller put it in there?

@codecov-io
Copy link

codecov-io commented May 18, 2017

Codecov Report

Merging #1069 into master will increase coverage by 0.01%.
The diff coverage is 92%.

@@            Coverage Diff            @@
##           master   #1069      +/-   ##
=========================================
+ Coverage   77.78%   77.8%   +0.01%     
=========================================
  Files         148     148              
  Lines       25771   25786      +15     
=========================================
+ Hits        20047   20063      +16     
+ Misses       5724    5723       -1
Impacted Files Coverage Δ
src/modules/kvs/cache.c 93.65% <100%> (+0.15%) ⬆️
src/modules/kvs/kvs.c 80.49% <90.9%> (+0.04%) ⬆️
src/common/libflux/request.c 89.04% <0%> (-1.37%) ⬇️
src/common/libflux/response.c 83.76% <0%> (-0.86%) ⬇️
src/common/libutil/dirwalk.c 90% <0%> (-0.72%) ⬇️
src/modules/kvs/libkvs.c 75.38% <0%> (-0.12%) ⬇️
src/common/libflux/message.c 81.45% <0%> (ø) ⬆️
src/common/libflux/handle.c 84.98% <0%> (+0.28%) ⬆️
src/common/libflux/rpc.c 92.36% <0%> (+0.36%) ⬆️
src/broker/modservice.c 80.19% <0%> (+0.99%) ⬆️
... and 2 more

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 78.048% when pulling 93bc6b8 on chu11:kvsrefactor5-loadrefactor into 583c8ec on flux-framework:master.

Remove confusing logic behind stall variable.
@chu11
Copy link
Member Author

chu11 commented May 18, 2017

@garlick The caller will then put it into the cache by calling load(). Effectively, what was once:

get_request_cb()
-> lookup()
    -> walk()
        -> load()
            -> cache_lookup()
            -> if miss, rpc to content store

is now

get_request_cb()
-> lookup()
    -> walk()
        -> cache_lookup(), if miss return missing reference
-> if miss
    -> load() missing reference, rpc to content store

BTW, realized I can do some cleanup by introducing a convenience function in cache API. So hold up on button push. But principle of patch still there.

Add extra tests for invalid cache entries.  Test that checks
for invalid entries work and expire fails for non valid entries.
@chu11 chu11 force-pushed the kvsrefactor5-loadrefactor branch from 93bc6b8 to ad942a5 Compare May 18, 2017 03:22
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 78.02% when pulling ad942a5 on chu11:kvsrefactor5-loadrefactor into 583c8ec on flux-framework:master.

chu11 added 2 commits May 17, 2017 20:42
Add convenience function cache_lookup_and_get_json(), which
returns a json value of a cache entry if it is found and the
cache entry is deemed valid.
The load() function may load data from the KVS cache or it may
issue a rpc to retrieve data from the broker content cache if the
data is not yet locally cached.

The load() function's dependency on both cache and rpc APIs makes
it difficult to splice out functions that call load() into separate
APIs.

This patch removes the call of load() from the lookup() and
walk() functions.  In lookup() and walk(), data is instead looked
up only in the local KVS cache.  If it is not stored there locally,
it is the responsibility of the original caller to then call load()
to load the missing data.  A in/out parameter will pass the missing
reference all the way back to the original caller.
@chu11 chu11 force-pushed the kvsrefactor5-loadrefactor branch from ad942a5 to 552710a Compare May 18, 2017 03:42
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 78.054% when pulling 552710a on chu11:kvsrefactor5-loadrefactor into 583c8ec on flux-framework:master.

@chu11
Copy link
Member Author

chu11 commented May 19, 2017

Per discussion in PR #1066, we have decided not to splice out this "mini-checkpoint" of a pull request.

@chu11 chu11 closed this May 19, 2017
@chu11 chu11 deleted the kvsrefactor5-loadrefactor branch June 5, 2021 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants