-
Notifications
You must be signed in to change notification settings - Fork 57
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
Huge size of .nb-gradle\private\cache\ folder #258
Comments
If the size itself is not a problem for you, then I wouldn't worry. Each file stores the model of the associated subproject, so that if you restart NB and open that project, the plugin can quickly load them without parsing the build script (it will still schedule a model update in the background).
|
I usually have no problem deleting the dotted folders such as That said, can an alternative be that the NetBeans gradle caches are under the user's temp directory? Since they shouldn't be committed to any repository and are only relevant to the active model-state, shouldn't they be more deletable? |
Size on disk is not a problem, but excessive size of data to be generated and processed can be a hidden problem. I may be completely wrong about 'excessive', just giving a 'notice'. By points:
|
Projects are rather independent in NB, so I cannot just easily share data amongst them. I could do that through some global cache but I don't think reducing the memory footprint worth other adverse effect (many lookup will be slower). Still, within a single project it can be reasonable and that would reduce the memory footprint considerably. That is, for many projects there are four sets:
For the majority projects |
I've got back to the project having that huge number of gradle sub-modules and got a reason to raise this issue once again. I've opened a root module plus around 10 of sub-modules and Gradle plugin anyway started loading all other (let's say hidden) modules. Full cycle finished in around 2 hours :( It seems like serializing/deserializing of project model is rather memory intensive operation -> nevertheless 'average' memory usage is far from 100%, GC takes very long time - it looks like 80% of loading of individual module is GC, so ... may it have sense to use another serialization format? As far as I understand - to make project workable in NB the only needed staff is "source sets" (what is few folder paths) and dependencies (at most 200 path, and this is at most 50K of memory for veeery long paths). From the screenshot below i see loading of a single project consumes around 250M (5000 times more than 50K) - huge pressure on GC is not a surprise in such conditions. |
Thanks for these details. For overall speed: Though, I can't see your case: According to my experience project loading time is heavily dominated by the configuration resolution which is not done within the NB process. However, as I have read, Gradleware claims that they improved it a lot in 3.2-rc-1, so you might want to give it a shot. For memory consumption: This is a though issue, the latest release should already have decreased the memory consumption considerably. However, currently each projects have their own dependency list for each source set for quick access (even worse because there is a separate compile and runtime set). This is necessary to be able to quickly provide the classpath for source files. There are two things I think it is possible to do:
I will try to check these things tomorrow but can't promise anything because I'm feeling sick today. |
There is another thing to consider and see if it improves your situation considerably:
|
PS: doing above-mentioned change in |
While it looks like that all projects are loaded independently, it is not exactly the case. What actually happens is that after the first subproject of a multi-project build gets loaded, it will fill the in-memory cache with all the other subprojects of the same multi-project build. So, subsequent project loads should be instantaneous. If this is not the case for you, it is likely that the project cache is too small for you (you can increase it in the globa settings: Misc./Gradle/Others. To be honest, I would expect In the mean time, I will try to experiment with |
I have created a file_reference_cache branch where I try to share equivalent |
I have added delayed project model persisting to both master and file_reference_cache. This should improve perceived performance. |
Ok, it seems that root cause of the problem for me was 'relatively small' cache of the projects you've mentioned above - with default limit of 100 projects are loaded in 1 hour 14minutes (using code from Now - about performance with cache size of 100. I've added logged to file (NB's log is limited by size) operations which are displayed via
Same for cache size =500
So it seems that with 'cache misses' there is huge amount of 'rework' is performed. Not sure - shouldn't it just be re-loaded from file cache? |
Removing the maximum size of the cache would cause a memory leak because it could just grow endlessly (the limit is how many projects you have on your disk). So, I would not do that. Using the file cache would be reasonable but in the current implementation there is no way to know how up-to-date is the file cache. The current purpose of the file cache is to immediately let you use a project after starting NB without having to wait for project load. However, I think there is a reasonable solution (work around) for your problem. Actually, the plugin knows that you will have problem, it just ignores it and lets you suffer :). That is, in the introduceModel of DefaultGradleModelLoader, I could increase the cache if it is too small and even report the issue in a balloon. |
Not sure why do you say 'grow endlessly' - if i open 3 roots with 500 modules - this 500 is the natural limit and new projects will not appear from nowhere. With manual configuration of limit - i'll just always go and set that limit which corresponds to actual max number of modules. I see no reason in doing this. I expect that after opening another project group with another set of projects - old modules will be unloaded automatically from in-memory cache. |
They will not be removed just because you have closed a project. The least recently used models from the cache will be removed when it reaches its limit. NetBeans might ask the plugin to load a project for many reason and I can't tell if a project will no longer be needed. That is, if it was requested, you might need it again soon. Regardless, I have added some code to automatically insrease the cache size if you load a huge multi-project build and report this to you. That said, this won't solve the issue when you have multiple multi-project builds loaded. Detecting such issue will need a more complicated logic. |
The plugin should now be able to increase cache size based on the currently opened projects (and also reports if it had to increase the size). This should fix problems of the people unaware of the cache and its effects. |
Got time to check this - "should now be able to increase cache size based on the currently opened projects". Behavior with manually configured size = 500
Behavior with default size = 100 So ... it seems it does not work. |
How many pending projects you have is not relevant. What I would be curious had you waited, would it increase the project cache size to something acceptable after completion. That said, I don't expect this solution to be exactly as efficient as if you had set the cache size to a good value manually. My expectation is that in case of your 3 large multi-project builds there will be 5 complete project loads (maybe a few more if you are unlucky). However after that, next time, the cache size should have been increased to a size where it will be able to load your projects without a problem. That said, I still recommend to adjust the cache size manually. This patch has two purpose:
|
Size of
cache
folder for my project is 200MB. This may be OK in general, but some things are looking strange:cache
contains 316 file - not 1:1 match, but looks to be very close.cache
folder is in range 630Kb..695Kb. 99files have identical file size: 634731 bytes, but they are not binary equal. I have no idea what is inside, but its seems that very repetitive information is stored across them.The text was updated successfully, but these errors were encountered: