IdeaJol icon indicating copy to clipboard operation
IdeaJol copied to clipboard

Inspections

Open stokito opened this issue 6 years ago • 2 comments

The plugin can provide some inspections but I'm not sure which one. I have the only one idea: to inspect object which layout is bigger than a cache line i.e. 64 bytes. But here occurs a problem with configuration:

  1. Which layout should be used? This should be configurable somehow.
  2. Should we inspect all classes or a simplest DTO's? For example it's ok to have a big object for a Controller class because anyway it's a singleton.
  3. Should we inspect platform and dependencies classes or only app code? It's a good thing to notify a user that it uses a class from library which have a big footprint.

I should ask in JOL dev list which inspections are possible.

stokito avatar Aug 09 '18 09:08 stokito

Also another problem here is that the inspection can be time consuming because of converting PSI tree to ClassData #10. Maybe to make a quick calculation we can make it ourself.

stokito avatar Aug 09 '18 10:08 stokito

First version was implemented and sent to be published. Inspection called "Java | Memory | Class have too big memory footprint" and shows a warning "Class have too big memory footprint". I tried on my working project and results are quite interesting. ATM we have few problems:

  1. Threshold is set to 64 (cache line) and this cause a lot of files to be reported. Maybe we have to change the default threshold.
  2. The whole class is getting marked with warning making the code unpleasant. Hotfix working only if set cursor on class name. I have to consult with JB plugin devs about how to do it better.
  3. Analyze is time consuming but it turned out not so slow as I expected. #10 should help a little bit. Also in fact we don't have to calculate full size, we need just to know that is bigger than threshold and skip other fields.
  4. A lot of DTOs are really HUGE: more than 3 cache lines it's quite ok here. I need to add an option to disable DTOs checking (by suffix DTO or Jackson annotation).
  5. Needs to be added to business login suffixes Handler, Factory, Provider, Utils, Registry, Filter, Interceptor, Executor, Test, Spec. The checking should be allowed by an option.
  6. It's better to show the size of object directly in message: "Class have too big memory footprint: 232" but this may consume more memory in IntelliJ.
  7. Tests are analyzed too which is not so useful.
  8. Most container and entity classes i.e. not DTOs but those who have hashCode() method are quite small. This is a good news.

stokito avatar Oct 01 '18 10:10 stokito