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

fix: add delete() for cached property #2144

Merged
merged 1 commit into from Mar 12, 2021
Merged

Conversation

cristianmtr
Copy link
Contributor

@cristianmtr cristianmtr commented Mar 10, 2021

  • provide overridden method for del for @cached_property
  • correct closing of query handler in BinaryPb

NOTE

@florian-hoenicke @JoanFM @maximilianwerk

Closing the query_handler is now coherent, but makes the update and delete ops slower. This is a trade-off we need to discuss perhaps.

Before, we were only closing the qhandler's body but still relying on its header to get the keys. That was a bit of smell due to the design of the Write/ReadHandlers in BinaryPb. Once we call close we shouldn't be able to access it, but we are.

Do we want to keep the old way (less readable, but more efficient), or this way (more readable, less efficient)?

@cristianmtr cristianmtr requested a review from a team as a code owner March 10, 2021 16:44
@jina-bot jina-bot added size/S area/core This issue/PR affects the core codebase area/helper This issue/PR affects the helper functionality area/testing This issue/PR affects testing component/executor executor/indexer labels Mar 10, 2021
@codecov
Copy link

codecov bot commented Mar 10, 2021

Codecov Report

Merging #2144 (147b3f6) into master (441966b) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2144      +/-   ##
==========================================
- Coverage   90.38%   90.37%   -0.02%     
==========================================
  Files         211      211              
  Lines       11199    11205       +6     
==========================================
+ Hits        10122    10126       +4     
- Misses       1077     1079       +2     
Flag Coverage Δ
daemon 50.38% <7.14%> (-0.02%) ⬇️
jina 90.82% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
jina/executors/indexers/keyvalue.py 98.37% <100.00%> (ø)
jina/executors/indexers/vector.py 95.68% <100.00%> (ø)
jina/helper.py 83.65% <100.00%> (+0.21%) ⬆️
jina/peapods/runtimes/zmq/zed.py 91.48% <0.00%> (-1.42%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 441966b...147b3f6. Read the comment docs.

@cristianmtr cristianmtr changed the title fix: add delete for cached prop fix: add delete() for cached property Mar 10, 2021
JoanFM
JoanFM previously requested changes Mar 10, 2021
jina/helper.py Show resolved Hide resolved
jina/helper.py Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Mar 10, 2021

Latency summary

Current PR yields:

  • 😶 index QPS at 1006, delta to last 3 avg.: -3%
  • 😶 query QPS at 17, delta to last 3 avg.: -3%

Breakdown

Version Index QPS Query QPS
current 1006 17
1.0.8 1059 17
1.0.7 1030 17

Backed by latency-tracking. Further commits will update this comment.

@cristianmtr
Copy link
Contributor Author

@JoanFM (not sure why I can't quote your comments)

I think this is a code smell that we are caching something we should not cache

Yes, that is a smell buried deep in Jina unfortunately. We are caching the query handler, for example in here

I see why this is necessary as we want to avoid the performance hit of having to build it up every time.

not really a fan of this to be honest. We assume that close is an special method, which may not be true

Hm I see. Is there any alternative you can think of? We could check that the field name is something like 'query handler' etc., but that would be just as bad.

We are making a similar assumption here:

call_obj_fn(self.write_handler, 'close')

@cristianmtr cristianmtr requested a review from JoanFM March 10, 2021 17:09
@JoanFM
Copy link
Member

JoanFM commented Mar 10, 2021

@JoanFM (not sure why I can't quote your comments)

I think this is a code smell that we are caching something we should not cache

Yes, that is a smell buried deep in Jina unfortunately. We are caching the query handler, for example in here

I see why this is necessary as we want to avoid the performance hit of having to build it up every time.

not really a fan of this to be honest. We assume that close is an special method, which may not be true

Hm I see. Is there any alternative you can think of? We could check that the field name is something like 'query handler' etc., but that would be just as bad.

We are making a similar assumption here:

call_obj_fn(self.write_handler, 'close')

Can't we maybe have a private class that can control if a handler is to be reread or recomputed or something?

@cristianmtr
Copy link
Contributor Author

Can't we maybe have a private class that can control if a handler is to be reread or recomputed or something?

Not sure I understand what you mean. Another class decorator, like cached_property?

@maximilianwerk
Copy link
Member

Can't we maybe have a private class that can control if a handler is to be reread or recomputed or something?

What we could do is to have an argument for the decorator, which says, if it is closable of not in order to make it explicit instead of implicit. Anyhow, the current solution is fine in my opinion.

Copy link
Member

@maximilianwerk maximilianwerk left a comment

Choose a reason for hiding this comment

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

LGTM

@cristianmtr cristianmtr merged commit 982fd9e into master Mar 12, 2021
@cristianmtr cristianmtr deleted the fix-delete-cached-prop branch March 12, 2021 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core This issue/PR affects the core codebase area/helper This issue/PR affects the helper functionality area/testing This issue/PR affects testing component/executor executor/indexer size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants