-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: proper context management of handlers #2322
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2322 +/- ##
==========================================
+ Coverage 89.77% 90.83% +1.05%
==========================================
Files 222 222
Lines 11958 11976 +18
==========================================
+ Hits 10735 10878 +143
+ Misses 1223 1098 -125
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Latency summaryCurrent PR yields:
Breakdown
Backed by latency-tracking. Further commits will update this comment. |
294155f
to
e15f54e
Compare
Can you perhaps try to apply the fix without the refactoring first? See if we can isolate it |
I am not having a fix, It is just a feeling that the structure is not robust and may cause it |
Fixes #2320 |
@nan-wang can u review again, I made sure it only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you run a benchmark? When I tried to do it with ctx mger, it slowed it down a bit. I think we should know. Use some of the crud tests or the benchmark in test_dump_dbms
Run on master:
on this branch:
I am not seeing any big conclusion. |
self.body = open(self.path, self.mode) | ||
self.header = open(self.path + '.head', self.mode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we opening the files in __init__
? Shouldn't we only open them in __enter__
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid the concerns from @nan-wang , we avoid opening and closing at everybatch which could damage performance. But we still check the need for opening
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. So we're kinda using "half" of what a ctx mger should do (open and close within in the context, right)?
return self | ||
|
||
def __exit__(self, exc_type, exc_val, exc_tb): | ||
self.flush() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we close()
on exit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we wanted to avoid the need to reopen all the time, but at least we assume the data is flushed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closing the file after every 'add' will be quite expensive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, got it. That's what I tried in the previous approach. And we're kinda doing "half" of the ctx management. Makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 questions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Try to have a better and more robust implementation of
BinaryPbIndexer
and the access to theWriting
andReadHandlers
.I believe this can be a cause of #2320