-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Implement a sqlite-based store for the cache #6023
Conversation
File system operations on OS X are pretty slow, and untarring a large archive of mypy cache information can get pretty slow. Work around this by using a sqlite database to store the entire cache in one file. To do this we introduce a generic interface for storing metadata, called `MetadataStore`. It presents an essentially key/value interface. We provide two implementations, one using the existing file system backing and one using sqlite. It is enabled with the option `--sqlite-cache`, but is not the default yet. I'm not sure what the right thing to do about testing is. I've tested it with the default changed, and everything passes.
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.
Thanks! This looks very good, I just have some documentation suggestions.
misc/convert-cache.py
Outdated
|
||
for s in input.list_all(): | ||
# print("Copying", s) | ||
assert output.write(s, input.read(s), input.getmtime(s)) |
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 would give a reasonable error message if this fails. Also, do we need to perform a cleanup for partially written cache to disk in this case?
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.
It's just a debugging script, so I dunno if it matters?
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.
Up to you, but if we expect that someone except us will use it (I assume), then think it is better to do it.
structure of files. | ||
* A hokey sqlite backed implementation, which basically simulates | ||
the file system in an effort to work around poor file system performance | ||
on OS X. |
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.
What about Windows? Is it also fast or also slow?
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 have no idea at all
mypy/metastore.py
Outdated
|
||
class SqliteMetadataStore(MetadataStore): | ||
def __init__(self, cache_dir_prefix: str) -> None: | ||
if cache_dir_prefix.startswith('/dev/null'): |
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 startswith
and not ==
? I would also documment this behavior in a docstring.
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 now.
File system operations on OS X are pretty slow, and untarring a large
archive of mypy cache information can get pretty slow. Work around
this by using a sqlite database to store the entire cache in one file.
To do this we introduce a generic interface for storing metadata,
called
MetadataStore
. It presents an essentially key/valueinterface. We provide two implementations, one using the existing file
system backing and one using sqlite.
It is enabled with the option
--sqlite-cache
, but is not the defaultyet.
I'm not sure what the right thing to do about testing is. I've tested
it with the default changed, and everything passes.