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
coala: Add file caching and remove Tagging #2016
Conversation
6d68870
to
bac2c36
Compare
@fneu please take a look ASAP |
import calendar | ||
import time | ||
import appdirs | ||
import pickle |
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.
Hm, I'm not completely sold on pickle, yet. It's nice that until now we have resided with human-readable files, although I get that pickle makes things a little easier in this case. And this is something that peolpe would most likely not interfere with besides deleting said file in case they suspect it leading to errors.
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.
@hypothesist what happens if coala is interrupted while writing to the pickled file? Will this break things (and therefore permanently break coala until a human intervenes?)
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.
On CTRL+C pickle ignores it and writes everything to file. If you kill the process its mostly corrupted^^
In this case we just need to catch UnpicklingError
^^
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.
@fneu I think it will, at worst, corrupt the file. I didn't think about the possibility of that happening.
So I think, as @Makman2 said, adding a UnpickingError should suffice. The worst that will happen in that case is that every project will need to be cached again (maybe we can display an error saying caching broke, so every project needs to be cached again). I don't think that's too bad.
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.
Yeah I think that's the way forward. Post a warning message, delete the
corrupt file, re-cache.
All in all I like this very much :)
Am 15. April 2016 9:02:27 vorm. schrieb Adhityaa Chandrasekar
notifications@github.com:
@@ -0,0 +1,142 @@
+import os
+import calendar
+import time
+import appdirs
+import pickle@fneu I think it will, at worst, corrupt the file. I didn't think about the
possibility of that happening.So I think, as @Makman2 said, adding a UnpickingError should suffice. The
worst that will happen in that case is that every project will need to be
cached again (maybe we can display an error saying caching broke, so every
project needs to be cached again). I don't think that's too bad.
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/coala-analyzer/coala/pull/2016/files/621fc8d315bd5a587846946475b6ce9370489585#r59833966
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.
@fneu I've added a verify_file_integrity
function that will check if all files are proper. It will delete all of them if even one of them is corrupted (doesn't make sense to have the others if they are all connected). This is done at the start of each coala execution (before the first time any pickling is done).
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.
sounds fine to me
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.
for me too 👍
this actually does look rather sane! there are still code paths not covered by tests, please complete them |
@hypothesist you write: "This should improve the running time of coala". I'm on windows right now and cannot check: Is there a run time decrease and how big is the improvement? |
@fneu depending on how many files were changed. Last time @hypothesist told me he was 66% faster^^ |
914e6b3
to
dd21d95
Compare
@@ -0,0 +1,171 @@ | |||
import os |
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.
@hypothesist Perhaps we should have it alphabetically sorted.
@hypothesist 1c45bd7 needs minor rework |
@@ -423,6 +436,22 @@ def yield_ignore_ranges(file_dict): | |||
len(file[line_number]))) | |||
|
|||
|
|||
def get_file_list(results): | |||
""" | |||
Gets the list of files that are affected in the given results. |
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.
@hypothesist You just missed this 😉
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.
Fixed it. In my defense, the whole file uses imperative! :P
user's config directory. | ||
""" | ||
path = appdirs.user_config_dir("coala") | ||
return os.path.join(path, filename) |
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.
don't we have a function like this in tagging somewhere?
@@ -132,6 +132,7 @@ def Analyze(self): | |||
global_bear_list=global_bears[section_name], | |||
local_bear_list=local_bears[section_name], | |||
print_results=lambda *args: True, | |||
cache=None, |
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.
you should at least add a TODO or something
unack 611bee3 |
ack 7abfbbb |
@@ -470,6 +509,8 @@ def process_queues(processes, | |||
filename as keys. | |||
:param print_results: Prints all given results appropriate to the | |||
output medium. | |||
:param cache: An instance of ``misc.Caching.FileCache`` to use | |||
as a file cache buffer. |
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.
file a newcomer issue about this being allowed None
ack 7aa7c3c |
This commit introduces helper functions that will be used in a later commit for caching (running coala only on changed files).
In this commit, coalib.misc.Caching is introduced which contains a class Cache which contains methods to act as a caching mechanism that will be useful to determine which files are new or changed and run coala only on those files to improve coala run time speed.
With `--changed-files` the user can run coala only on those files that had changed since the last time coala was run. This should improve the running time of coala. Fixes #1991
@sils1297 sorry, I amended the previous commits by habit. I'll detail the changes I made so that it's easier to review:
|
ack 622a3e5 |
ack 91c109d |
ack ad3ec72 |
@rultor merge |
@hypothesist OK, I'll try to merge now. You can check the progress of the merge here |
@hypothesist Done! FYI, the full log is here (took me 1min) |
With
--caching
the user can run coala only on those files thathad changed since the last time coala was run. This should improve
the running time of coala.