Home » Developing U++ » U++ Developers corner » theide with libclang
Re: theide with libclang [message #58909 is a reply to message #58579] |
Sat, 24 September 2022 08:44 |
|
mirek
Messages: 13976 Registered: November 2005
|
Ultimate Member |
|
|
OK, so one week in, I guess I owe the community a bit of explanation about libclang and the way theide uses it...
So, obviously what libclang does is parsing the files and giving info about them. Additionally, it can provide autocomplete lists at specified point in the source files, but NOT HEADERS (and also not inside templates, but that is store for another time).
The important thing to know is that parsing the file with all headers is long: on my not so slow machine, it can take up to several seconds to parse the file. To remedy this, libclang has a concept of "preamble" and "reparsing". Preamble is basically automated precompiled header - if file starts with multiple headers, preamble is creating and when after the first parse the file is reparsed or autocomplete requested, preamble is used to greatly speedup the process. With preamble, autocomplete (after the first parse) is almost immediate. That said, premable creation is sort of fragile. Also, normally it gets created in system temp directory, which would be fine unless sometimes libclang does not delete it. But it can be solved be setting env variable which we do now.
So what we do now is the when you start editing some file, in the background thread the first parse of the file is started with a request to create preamble. In theide, you can know that this is happening by left bar going "sort of orange" for a couple of seconds - it does that each time file is parsed or reparsed. If you then change the file, it gets (after some time of inactivity) reparsed again. Parsing current file gets it ready for autocomplete, but also provides information about file for file annotations, current file navigation and "jumps" (Alt-J / Ctrl clicks).
Originally, there was just one parsed file, which meant each time after switching to another file it had to have that initial a couple of seconds parsing period. Later I have added a cache, there are now several files with parsed info. Downside is that each "parsing unit" consumes a lot of memory, about 300MB so with 12 entries in the cache, you can do the math....
Include files that clang is unable to process: What we do is that we find "master file" - the well defined file that includes the header and we pretend that we are parsing that one. It is not so simple: we still want to use preamble to make things fast and if we just parsed master file and hoped to catch the info include file from it, it would not work with preambles as our include file would actually be in preamble. I have spent a lot of time trying to solve this: What we actually do now is that we create a syntetic file content that actually manually does including so that it all works (it is hard to explain in detail; in assist diagnostic mode you can see the content of the syntetic file with Assist/Current parsed file content).
So that is about all I can say about "current file" without going into gruesome details; if you want to study the code, libclang/CurrentFile.cpp and ide/AssistTrick.cpp are good starting points.
Next troublesome part of code is "Indexer" - that is something that scans the whole sources and creates a program database of, well, everything everywhere. That is needed for Navigator and Alt+J command. We are using blitz(like) process there and we are running that in multiple threads. Now there is "Scheduler" (Indexer::SchedulerThread()) thread that scans for changed files and basically prepares jobs for "Indexing" (Indexer::IndexerThread) threads. Once again, each of indexer threads can eat up to 300MB of memory, so finetuning default values will take some time. More indexer threads mean faster reindexing but perhaps too much memory...
In terms of slowdown/freezing during reindexing, well, the plan was to give indexer threads really low priority. It should be possible with
clang_CXIndex_setGlobalOptions(clang.index, CXGlobalOpt_ThreadBackgroundPriorityForIndexing);
but maybe this does not work as expected in Linux. In Windows, it seems to work fine.
Now for testing and troubleshooting, please note that there is "Assist diagnostics" option in Assist/Debug. When active, it will start reporting in Console what it is doing and also there are new entries at the end of assist menu, showing a dump of actual index, errors libclang reported during parsing and what was given to clang to parse as current file.
So if e.g. there is no autocomplete for include files, please check "Current file parse errors" and "Current parsed file content".
I know this is a big change (and one I was extremly hesitant to do) and not everything works smoothly at this point, but hopefully all will be finetuned in time. I guess we fixed a lot already in the first week....
Mirek
[Updated on: Sat, 24 September 2022 08:47] Report message to a moderator
|
|
|
|
|
theide with libclang
By: mirek on Sun, 26 June 2022 09:32
|
|
|
Re: theide with libclang, first milestone finished
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Sun, 26 June 2022 14:18
|
|
|
Re: theide with libclang, first milestone finished
By: Klugier on Sun, 26 June 2022 16:37
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Sun, 26 June 2022 18:07
|
|
|
Re: theide with libclang, first milestone finished
By: Tom1 on Mon, 27 June 2022 10:58
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Mon, 27 June 2022 11:16
|
|
|
Re: theide with libclang, first milestone finished
By: Tom1 on Mon, 27 June 2022 11:25
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Mon, 27 June 2022 14:35
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Sun, 03 July 2022 05:28
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Sun, 03 July 2022 16:19
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Mon, 04 July 2022 00:08
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Thu, 07 July 2022 13:23
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Thu, 07 July 2022 16:33
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Thu, 07 July 2022 17:01
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Thu, 07 July 2022 17:02
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Thu, 07 July 2022 18:41
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Thu, 07 July 2022 18:49
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Thu, 07 July 2022 18:55
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Thu, 07 July 2022 19:05
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Thu, 07 July 2022 19:10
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Thu, 07 July 2022 19:39
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Sat, 09 July 2022 00:32
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Sat, 09 July 2022 13:11
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Sat, 09 July 2022 19:44
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Sun, 10 July 2022 00:49
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Sun, 10 July 2022 01:49
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Sun, 10 July 2022 02:53
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Sun, 10 July 2022 08:46
|
|
|
Re: theide with libclang, first milestone finished
By: Klugier on Sun, 10 July 2022 11:06
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Sun, 10 July 2022 16:56
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Mon, 11 July 2022 18:40
|
|
|
Re: theide with libclang, first milestone finished
By: Klugier on Mon, 11 July 2022 21:57
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Mon, 11 July 2022 22:27
|
|
|
Re: theide with libclang, first milestone finished
By: Klugier on Mon, 11 July 2022 22:49
|
|
|
Re: theide with libclang, first milestone finished
By: Klugier on Mon, 11 July 2022 23:00
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Mon, 15 August 2022 10:44
|
|
|
Re: theide with libclang, first milestone finished
By: Klugier on Mon, 15 August 2022 18:44
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Tue, 16 August 2022 08:04
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Fri, 19 August 2022 13:04
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Fri, 19 August 2022 13:05
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Sat, 20 August 2022 20:00
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Sat, 20 August 2022 20:33
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Sun, 21 August 2022 00:46
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Tue, 30 August 2022 16:04
|
|
|
Re: theide with libclang, first milestone finished
By: Tom1 on Wed, 31 August 2022 10:00
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Wed, 31 August 2022 10:13
|
|
|
Re: theide with libclang, first milestone finished
By: Tom1 on Wed, 31 August 2022 10:50
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Wed, 31 August 2022 11:37
|
|
|
Re: theide with libclang, first milestone finished
By: Tom1 on Wed, 31 August 2022 12:33
|
|
|
Re: theide with libclang, first milestone finished
By: Tom1 on Thu, 15 September 2022 08:31
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Thu, 15 September 2022 09:48
|
|
|
Re: theide with libclang, first milestone finished
By: Tom1 on Thu, 15 September 2022 14:10
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Fri, 16 September 2022 11:28
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Sat, 17 September 2022 05:54
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Sat, 17 September 2022 06:44
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Sat, 17 September 2022 11:04
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Sat, 17 September 2022 12:23
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Sat, 17 September 2022 12:48
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Sat, 17 September 2022 12:57
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Sat, 17 September 2022 13:01
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Sat, 17 September 2022 12:37
|
|
|
Re: theide with libclang, first milestone finished
By: Tom1 on Sat, 20 August 2022 20:34
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Sun, 21 August 2022 00:42
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Thu, 07 July 2022 19:45
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Thu, 07 July 2022 20:15
|
|
|
Re: theide with libclang, first milestone finished
By: mirek on Thu, 07 July 2022 20:44
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Thu, 07 July 2022 21:35
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Thu, 07 July 2022 21:42
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Thu, 07 July 2022 22:04
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Thu, 07 July 2022 18:58
|
|
|
Re: theide with libclang, first milestone finished
By: Novo on Thu, 07 July 2022 18:00
|
|
|
Re: theide with libclang
By: mirek on Thu, 07 July 2022 15:32
|
|
|
Re: theide with libclang
By: Novo on Tue, 16 August 2022 19:18
|
|
|
Re: theide with libclang
By: mirek on Fri, 19 August 2022 13:03
|
|
|
Re: theide with libclang
By: Novo on Tue, 16 August 2022 19:25
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
By: mirek on Sun, 18 September 2022 13:05
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
By: Novo on Sun, 18 September 2022 16:57
|
|
|
Re: theide with libclang
By: Novo on Sun, 18 September 2022 21:23
|
|
|
Re: theide with libclang
By: mirek on Tue, 20 September 2022 13:09
|
|
|
Re: theide with libclang
By: Novo on Tue, 20 September 2022 19:16
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
By: mirek on Tue, 20 September 2022 19:37
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
By: Novo on Wed, 21 September 2022 01:33
|
|
|
Re: theide with libclang
By: Novo on Wed, 21 September 2022 01:56
|
|
|
Re: theide with libclang
By: mirek on Wed, 21 September 2022 10:52
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
By: Novo on Fri, 23 September 2022 05:41
|
|
|
Re: theide with libclang
By: Novo on Fri, 23 September 2022 05:52
|
|
|
Re: theide with libclang
By: mirek on Fri, 23 September 2022 10:48
|
|
|
Re: theide with libclang
By: Lance on Sat, 24 September 2022 04:41
|
|
|
Re: theide with libclang
By: peterh on Sat, 24 September 2022 07:26
|
|
|
Re: theide with libclang
By: mirek on Sat, 24 September 2022 08:08
|
|
|
Re: theide with libclang
By: Lance on Sat, 24 September 2022 15:00
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
By: Lance on Sun, 25 September 2022 02:13
|
|
|
Re: theide with libclang
By: Klugier on Sun, 25 September 2022 13:48
|
|
|
Re: theide with libclang
By: Lance on Sun, 25 September 2022 14:48
|
|
|
Re: theide with libclang
By: Klugier on Sun, 25 September 2022 15:28
|
|
|
Re: theide with libclang
By: Lance on Sun, 25 September 2022 15:30
|
|
|
Re: theide with libclang
By: Klugier on Sun, 25 September 2022 15:47
|
|
|
Re: theide with libclang
By: Lance on Sun, 25 September 2022 16:05
|
|
|
Re: theide with libclang
By: mirek on Sun, 25 September 2022 16:57
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
By: mirek on Sun, 25 September 2022 23:26
|
|
|
Re: theide with libclang
By: Lance on Tue, 27 September 2022 01:48
|
|
|
Re: theide with libclang
By: Klugier on Tue, 27 September 2022 20:35
|
|
|
Re: theide with libclang
By: Lance on Tue, 27 September 2022 23:11
|
|
|
Re: theide with libclang
By: Lance on Tue, 27 September 2022 23:12
|
|
|
Re: theide with libclang
By: Tom1 on Sat, 01 October 2022 18:46
|
|
|
Re: theide with libclang
By: Klugier on Sat, 01 October 2022 22:49
|
|
|
Re: theide with libclang
By: Lance on Sun, 02 October 2022 02:19
|
|
|
Re: theide with libclang
By: mirek on Sun, 02 October 2022 11:57
|
|
|
Re: theide with libclang
By: Lance on Sun, 02 October 2022 15:27
|
|
|
Re: theide with libclang
By: mirek on Sun, 02 October 2022 16:17
|
|
|
Re: theide with libclang
By: Tom1 on Sun, 02 October 2022 19:03
|
|
|
Re: theide with libclang
By: mirek on Sun, 02 October 2022 22:07
|
|
|
Re: theide with libclang
By: Lance on Mon, 03 October 2022 00:58
|
|
|
Re: theide with libclang
By: Tom1 on Mon, 03 October 2022 09:34
|
|
|
Re: theide with libclang
By: Tom1 on Mon, 03 October 2022 10:05
|
|
|
Re: theide with libclang
By: mirek on Mon, 03 October 2022 10:34
|
|
|
Re: theide with libclang
By: Tom1 on Mon, 03 October 2022 11:30
|
|
|
Re: theide with libclang
By: mirek on Mon, 03 October 2022 10:48
|
|
|
Re: theide with libclang
By: Tom1 on Mon, 03 October 2022 11:35
|
|
|
Re: theide with libclang
By: Tom1 on Mon, 03 October 2022 11:45
|
|
|
Re: theide with libclang
By: mirek on Mon, 03 October 2022 13:38
|
|
|
Re: theide with libclang
By: mirek on Mon, 03 October 2022 10:37
|
|
|
Re: theide with libclang
By: Lance on Mon, 03 October 2022 15:51
|
|
|
Re: theide with libclang
By: Klugier on Mon, 03 October 2022 23:20
|
|
|
Re: theide with libclang
By: mirek on Sat, 08 October 2022 19:47
|
|
|
Re: theide with libclang
By: Lance on Sat, 08 October 2022 21:29
|
|
|
Re: theide with libclang
By: Tom1 on Sat, 08 October 2022 21:54
|
|
|
Re: theide with libclang
By: mirek on Sat, 08 October 2022 23:04
|
|
|
Re: theide with libclang
By: mirek on Sun, 09 October 2022 20:44
|
|
|
Re: theide with libclang
By: Tom1 on Sun, 09 October 2022 21:19
|
|
|
Re: theide with libclang
By: mirek on Sun, 09 October 2022 23:18
|
|
|
Re: theide with libclang
By: Lance on Sun, 25 September 2022 15:28
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
By: mirek on Sat, 24 September 2022 08:44
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
By: peterh on Sat, 24 September 2022 10:03
|
|
|
Re: theide with libclang
By: mirek on Sat, 24 September 2022 10:16
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
By: mirek on Sat, 24 September 2022 21:44
|
|
|
Re: theide with libclang
|
|
|
Re: theide with libclang
By: mirek on Sun, 25 September 2022 23:23
|
|
|
Re: theide with libclang
By: peterh on Sat, 15 October 2022 11:33
|
|
|
Re: theide with libclang
By: mirek on Sun, 16 October 2022 13:28
|
|
|
Re: theide with libclang
By: Lance on Wed, 26 October 2022 16:00
|
|
|
Re: theide with libclang
By: mirek on Wed, 26 October 2022 22:07
|
|
|
Re: theide with libclang
By: mirek on Thu, 27 October 2022 12:21
|
|
|
Re: theide with libclang
By: mirek on Thu, 27 October 2022 12:26
|
|
|
Re: theide with libclang
By: Lance on Tue, 01 November 2022 23:32
|
|
|
Re: theide with libclang
By: Lance on Wed, 02 November 2022 00:15
|
|
|
Re: theide with libclang
By: Lance on Wed, 02 November 2022 01:58
|
|
|
Re: theide with libclang
By: mirek on Wed, 02 November 2022 15:58
|
|
|
Re: theide with libclang
By: mirek on Wed, 02 November 2022 10:21
|
|
|
Re: theide with libclang
By: mirek on Wed, 02 November 2022 19:13
|
|
|
Re: theide with libclang
By: Lance on Wed, 02 November 2022 22:52
|
|
|
Re: theide with libclang
By: Lance on Thu, 03 November 2022 20:06
|
|
|
Re: theide with libclang
By: mirek on Mon, 21 November 2022 16:46
|
|
|
Re: theide with libclang
By: zsolt on Tue, 22 November 2022 08:28
|
|
|
Re: theide with libclang
By: mirek on Tue, 22 November 2022 10:28
|
|
|
Re: theide with libclang
By: zsolt on Tue, 22 November 2022 11:21
|
|
|
Re: theide with libclang
By: mirek on Tue, 22 November 2022 11:25
|
|
|
Re: theide with libclang
By: zsolt on Tue, 22 November 2022 11:40
|
|
|
Re: theide with libclang
By: Lance on Wed, 23 November 2022 00:44
|
|
|
Re: theide with libclang
By: mirek on Wed, 23 November 2022 10:46
|
|
|
Re: theide with libclang
By: Lance on Thu, 24 November 2022 03:12
|
Goto Forum:
Current Time: Fri May 10 22:44:09 CEST 2024
Total time taken to generate the page: 0.01779 seconds
|