Closed 3v1n0 closed 6 years ago
Indeed, I noticed this too. I need to take a look. In the meantime, you can use the version published on pypi.
The one in pypi is using the old system? Thus I should use the 2 passes?
Ok, I have a quickfix, I will check it again to see if it is 100% correct but it should solve the issue. I invite you to test. The way I tried to make "lazy" property was incorrect, so these properties that were lazy because of their cost, were recomputed over and over, making them so much more costly...
diff --git a/compdb/backend/json.py b/compdb/backend/json.py
index 4aa94b2..caa9308 100644
--- a/compdb/backend/json.py
+++ b/compdb/backend/json.py
@@ -11,6 +11,7 @@ from compdb.models import (CompileCommand, CompilationDatabaseInterface)
class JSONCompilationDatabase(CompilationDatabaseInterface):
def __init__(self, json_db_path):
self.json_db_path = json_db_path
+ self.__data = None
@classmethod
def probe_directory(cls, directory):
@@ -48,7 +49,7 @@ class JSONCompilationDatabase(CompilationDatabaseInterface):
@property
def _data(self):
- if not hasattr(self, '__data'):
+ if self.__data is None:
with open(self.json_db_path) as f:
self.__data = json.load(f)
return self.__data
diff --git a/compdb/includedb.py b/compdb/includedb.py
index 40f3935..61c4f0c 100644
--- a/compdb/includedb.py
+++ b/compdb/includedb.py
@@ -141,6 +141,7 @@ See also https://www.python.org/doc/essays/graphs/
def __init__(self, graph, database):
self.graph = graph
self.database = database
+ self.__db_index = None
def __repr__(self):
return '<IncludedByGraph: graph = {}, database = {}>'.format(
@@ -177,7 +178,7 @@ See also https://www.python.org/doc/essays/graphs/
@property
def _db_index(self):
- if not hasattr(self, '__db_index'):
+ if self.__db_index is None:
self.__db_index = frozenset(self.database.get_all_files())
return self.__db_index
Yes, works great here. and everything is way faster (even for those who was able to complete before)
The fix is okay, I submitted it. Great to hear it's faster now. There are rooms for better performances but I would say this is a reasonable baseline now.
Thanks for reporting the issue.
I'm running compdb over compile_commands.json files that are generated by bear or ninja.
In the previous version, when I had to generate the headersdb.json and then join it with the compile commands, it was working fine.
In the current implementation, instead, compdb hangs and it doesn't finish its job.
One project I'm currently having troubles with is https://github.com/GNOME/mutter/
When I interrupt the execution it stops at this state, but I don't think it helps. Let me know what you'd need in order to debug this.