Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347648 - Retained size column is not compared
Summary: Retained size column is not compared
Status: RESOLVED FIXED
Alias: None
Product: MAT
Classification: Tools
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 1.11.0   Edit
Assignee: Andrew Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 298078
  Show dependency tree
 
Reported: 2011-05-30 08:58 EDT by Krum Tsvetkov CLA
Modified: 2020-09-30 03:12 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Krum Tsvetkov CLA 2011-05-30 08:58:35 EDT
When comparing two or more tables, the retained size is not compared, even if it has been calculated for the "source" tables.

We need to find a way to improve this. The reason is that Retained Size is not part of the table definition, but rather a derived column which can be added to any table. The current implementation of the comparison features doesn't take this into account.
Comment 1 Andrew Johnson CLA 2020-03-07 16:48:11 EST
I think I know how to fix this one. The comparison needs to use the RefinedTable or RefinedTree. CompareBasketView needs to extract this from 
ResultPane using getAdapter and the panes (QueryResultPane) needs to supply it if requested.

Perhaps getAdapter for IResultTable should still return the original unrefined table even though RefinedTable also implements that.

The comparison will also then use the filtered version of the tables, which I hope won't be a problem and might be useful, it just needs to be documented.

There was a slight bug with Merge Paths from GC Roots by Class as the precalculated retained sizes were not used. This is because the cached
version was not found as getElements() returned different but equivalent rows each times, but equals and hashCode had the rows as different.
Comment 2 Andrew Johnson CLA 2020-03-09 10:16:24 EDT
There is a slight problem with retained sizes. These can be approximate or precise, depending on the method of calculation.
Internally approximate sizes are stored as negative, and displayed as >=value.

So:
Class Name                          | Objects #1 | Objects #2 | Shallow Heap #1 | Shallow Heap #2 | Retained Heap #1 | Retained Heap #2
----------------------------------------------------------------------------------------------------------------------------------------
                                    |            |            |                 |                 |                  |                 
byte[]                              |      3,603 |    552,515 |      30,248,168 |     588,956,544 |       30,248,168 |   >= 588,956,544
char[]                              |    122,615 |  1,532,892 |      10,622,368 |      99,591,896 |    >= 10,622,368 |       99,591,896
org.eclipse.mat.snapshot.model.Field|    209,215 |    429,687 |       5,021,160 |      10,312,488 |     >= 9,540,248 |    >= 30,759,816
----------------------------------------------------------------------------------------------------------------------------------------

is a table with approximate values in different columns.
As a difference:

Class Name                          | Objects #1 | Objects #2-#1 | Shallow Heap #1 | Shallow Heap #2-#1 | Retained Heap #1 | Retained Heap #2-#1
-------------------------------------------------------------------------------------------------------------------------------------------------
byte[]                              |      3,603 |      +548,912 |      30,248,168 |       +558,708,376 |       30,248,168 |        -619,204,712
char[]                              |    122,615 |    +1,410,277 |      10,622,368 |        +88,969,528 |    >= 10,622,368 |        +110,214,264
org.eclipse.mat.snapshot.model.Field|    209,215 |      +220,472 |       5,021,160 |         +5,291,328 |     >= 9,540,248 |         -21,219,568
-------------------------------------------------------------------------------------------------------------------------------------------------

so the differences are 
byte[] 30,248,168 >=588,956,544 : -588,956,544 - 30,248,168 = -619,204,712
char[] >=10,622,368 99,591,896 : 99,591,896 -  -10,622,368 = +110,214,264
org.eclipse.mat.snapshot.model.Field >= 9,540,248 >= 30,759,816 : -30,759,816 - -9,540,248 = -21,219,568

Actually for byte[] it should be >=+558,708,376
char[] <= 88,969,528
org.eclipse.mat.snapshot.model.Field >= 21,219,568

Converting and displaying this is going to be complicated as values can be exact, or approximate above or below
a positive or negative figure.

These figures could then be used for another table comparison which adds to the complication.
Comment 3 Andrew Johnson CLA 2020-03-11 11:56:42 EDT
The display figures can also be indeterminate, for subtracting two figures >=.
I have a solution which involves encoding the size delta. This is already done for retained sizes which 
can be exact or approximate (>=value). A negative size means >= which is used by the formatter and converted to an ordinary number by a Filter.ValueConverter for filtering (and should be for sorting, though the retained size has a special comparator.

Now we have 4 states, exact, >=value, <=value and uncertain: ~value and we can choose ranges of 
long to represent each one. The exact >= and <= ranges should be small enough for exact conversions
to and from double for the value converter.

The table result would now look like this:

Class Name                          | Objects #1 | Objects #2-#1 | Shallow Heap #1 | Shallow Heap #2-#1 | Retained Heap #1 | Retained Heap #2-#1
-------------------------------------------------------------------------------------------------------------------------------------------------
byte[]                              |      3,603 |      +548,912 |      30,248,168 |       +558,708,376 |       30,248,168 |      ≥ +558,708,376
char[]                              |    122,615 |    +1,410,277 |      10,622,368 |        +88,969,528 |    >= 10,622,368 |       ≤ +88,969,528
org.eclipse.mat.snapshot.model.Field|    209,215 |      +220,472 |       5,021,160 |         +5,291,328 |     >= 9,540,248 |       ≈ +21,219,568
-------------------------------------------------------------------------------------------------------------------------------------------------

Note the last column.
Comment 4 Eclipse Genie CLA 2020-03-16 11:59:37 EDT
New Gerrit change created: https://git.eclipse.org/r/159461
Comment 6 Andrew Johnson CLA 2020-03-26 03:08:38 EDT
I have merged some changes to fix this.
Comments welcome.
Comment 7 Eclipse Genie CLA 2020-04-10 14:32:53 EDT
New Gerrit change created: https://git.eclipse.org/r/160767
Comment 9 Andrew Johnson CLA 2020-08-30 09:58:43 EDT
This is now fixed (please reopen if not).