Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong [v3]

2022-06-08 Thread Ioi Lam
On Tue, 7 Jun 2022 10:07:08 GMT, Yi Yang wrote: >> It seems that calculation of >> MemoryMXBean.getNonHeapMemoryUsage(jmm_GetMemoryUsage) is wrong. >> >> Currently, >> `NonHeapUsage=CodeCache+Metaspace(ClassTypeSpace+NonClassTypeSpace)+CompressedClassSpace(ClassTypeSpace)` >> >> ==> CodeHeap

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong [v3]

2022-06-07 Thread Yi Yang
> It seems that calculation of > MemoryMXBean.getNonHeapMemoryUsage(jmm_GetMemoryUsage) is wrong. > > Currently, > `NonHeapUsage=CodeCache+Metaspace(ClassTypeSpace+NonClassTypeSpace)+CompressedClassSpace(ClassTypeSpace)` > > ==> CodeHeap 'non-nmethods' 1532544 (Used) > ==> CodeHeap 'profiled

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong [v2]

2022-06-07 Thread Yi Yang
> It seems that calculation of > MemoryMXBean.getNonHeapMemoryUsage(jmm_GetMemoryUsage) is wrong. > > Currently, > `NonHeapUsage=CodeCache+Metaspace(ClassTypeSpace+NonClassTypeSpace)+CompressedClassSpace(ClassTypeSpace)` > > ==> CodeHeap 'non-nmethods' 1532544 (Used) > ==> CodeHeap 'profiled

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-27 Thread Ioi Lam
On Fri, 27 May 2022 07:22:11 GMT, Thomas Stuefe wrote: > > If we remove `CompressedClassSpace`, we can only > > `getMemoryPool("Metaspace")`. Although metaspace is not baked in the > > specification, IMHO it's easier for developers to understand what is > > `metaspace` compared to the

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-27 Thread Thomas Stuefe
On Fri, 27 May 2022 06:25:45 GMT, Yi Yang wrote: > > If we remove `CompressedClassSpace`, we can only > `getMemoryPool("Metaspace")`. Although metaspace is not baked in the > specification, IMHO it's easier for developers to understand what is > `metaspace` compared to the concepts of `Non

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-27 Thread Thomas Stuefe
On Fri, 27 May 2022 06:22:36 GMT, Ioi Lam wrote: > > The basic problem is that we have two non-heap pools: > > > > * `MetaspacePool` > > > > * consists of `ClassType` and `NonClassType` parts > > * `CompressedKlassSpacePool` > > > > but the `CompressedKlassSpacePool` is actually the

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-27 Thread Yi Yang
On Fri, 27 May 2022 06:22:36 GMT, Ioi Lam wrote: > I think the right fix is to just convert the MetaspacePool into > NonClassMetaspacePool and only report the non-class values. Yes, it's okay for me. But I have another concern. The compressed class pool is not directly used by other VM

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-27 Thread Ioi Lam
On Fri, 27 May 2022 05:31:24 GMT, David Holmes wrote: > The basic problem is that we have two non-heap pools: > > * `MetaspacePool` > > * consists of `ClassType` and `NonClassType` parts > * `CompressedKlassSpacePool` > > but the `CompressedKlassSpacePool` is actually the "ClassType" part

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-26 Thread David Holmes
On Mon, 23 May 2022 07:28:41 GMT, Yi Yang wrote: > It seems that calculation of > MemoryMXBean.getNonHeapMemoryUsage(jmm_GetMemoryUsage) is wrong. > > Currently, > `NonHeapUsage=CodeCache+Metaspace(ClassTypeSpace+NonClassTypeSpace)+CompressedClassSpace(ClassTypeSpace)` > > ==> CodeHeap

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-26 Thread David Holmes
On Fri, 27 May 2022 02:12:32 GMT, Yi Yang wrote: >> Yes counting it twice is wrong but this is the wrong fix. The pools are not >> defined correctly. > >> Sorry for chiming in in a not very helpful way, but I am not sure what even >> the point is of this API. >> >> I'm seriously interested in

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-26 Thread Yi Yang
On Thu, 26 May 2022 22:17:17 GMT, David Holmes wrote: >> Beside my general points, I think this patch makes sense. I agree with >> @kelthuzadx that counting Classspace twice is wrong, whatever the intention >> of this API originally was. > > Yes counting it twice is wrong but this is the wrong

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-26 Thread David Holmes
On Thu, 26 May 2022 13:47:55 GMT, Thomas Stuefe wrote: >> In any case, it's unreasonable for getNonHeapMemoryUsage to count a piece of >> memory repeatedly, right? In the extreme case, we might add all nested pools >> of metaspace, and we will get Metaspace x2 + CodeCache when using >>

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-26 Thread Mandy Chung
On Mon, 23 May 2022 07:28:41 GMT, Yi Yang wrote: > It seems that calculation of > MemoryMXBean.getNonHeapMemoryUsage(jmm_GetMemoryUsage) is wrong. > > Currently, > `NonHeapUsage=CodeCache+Metaspace(ClassTypeSpace+NonClassTypeSpace)+CompressedClassSpace(ClassTypeSpace)` > > ==> CodeHeap

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-26 Thread Thomas Stuefe
On Thu, 26 May 2022 11:32:46 GMT, Yi Yang wrote: >> I think the problem is the definition of the pools. We seem to have nested >> pools but it is far from clear that this API/mechanism was designed/intended >> to support nested pools. > > In any case, it's unreasonable for

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-26 Thread Thomas Stuefe
On Thu, 26 May 2022 12:47:42 GMT, David Holmes wrote: >> In any case, it's unreasonable for getNonHeapMemoryUsage to count a piece of >> memory repeatedly, right? In the extreme case, we might add all nested pools >> of metaspace, and we will get Metaspace x2 + CodeCache when using >>

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-26 Thread David Holmes
On Thu, 26 May 2022 11:32:46 GMT, Yi Yang wrote: >> I think the problem is the definition of the pools. We seem to have nested >> pools but it is far from clear that this API/mechanism was designed/intended >> to support nested pools. > > In any case, it's unreasonable for

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-26 Thread Yi Yang
On Thu, 26 May 2022 07:34:59 GMT, David Holmes wrote: >> This is also acceptable, but if we add more memory pools, we might add more >> special pools to exclude their space from nonheap. Instead, we can specify >> exactly which pools we need to accumulate, which is what this change did. > > I

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-26 Thread David Holmes
On Thu, 26 May 2022 05:59:30 GMT, Yi Yang wrote: >> src/hotspot/share/services/management.cpp line 753: >> >>> 751: for (int i = 0; i < MemoryService::num_memory_pools(); i++) { >>> 752: MemoryPool* pool = MemoryService::get_memory_pool(i); >>> 753: if (pool->is_codeheap() ||

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-26 Thread Yi Yang
On Thu, 26 May 2022 05:08:13 GMT, Ioi Lam wrote: >> It seems that calculation of >> MemoryMXBean.getNonHeapMemoryUsage(jmm_GetMemoryUsage) is wrong. >> >> Currently, >> `NonHeapUsage=CodeCache+Metaspace(ClassTypeSpace+NonClassTypeSpace)+CompressedClassSpace(ClassTypeSpace)` >> >> ==>

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-25 Thread Ioi Lam
On Mon, 23 May 2022 07:28:41 GMT, Yi Yang wrote: > It seems that calculation of > MemoryMXBean.getNonHeapMemoryUsage(jmm_GetMemoryUsage) is wrong. > > Currently, > `NonHeapUsage=CodeCache+Metaspace(ClassTypeSpace+NonClassTypeSpace)+CompressedClassSpace(ClassTypeSpace)` > > ==> CodeHeap

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-23 Thread Yi Yang
On Mon, 23 May 2022 09:58:46 GMT, David Holmes wrote: > Sorry but I can't agree with this change as presented. By definition the > total non-heap memory is the sum of all pools which identify as non-heap as > per the specification: > > "The non-heap memory consists of one or more memory

Re: RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-23 Thread David Holmes
On Mon, 23 May 2022 07:28:41 GMT, Yi Yang wrote: > It seems that calculation of > MemoryMXBean.getNonHeapMemoryUsage(jmm_GetMemoryUsage) is wrong. > > Currently, NonHeapUsage = CodeCache + Metaspace + CompressedClassSpace > > ==> CodeHeap 'non-nmethods' 1532544 (Used) > ==> CodeHeap 'profiled

RFR: 8287135: Calculation of jmm_GetMemoryUsage is wrong

2022-05-23 Thread Yi Yang
It seems that calculation of MemoryMXBean.getNonHeapMemoryUsage(jmm_GetMemoryUsage) is wrong. Currently, NonHeapUsage = CodeCache + Metaspace + CompressedClassSpace ==> CodeHeap 'non-nmethods' 1532544 (Used) ==> CodeHeap 'profiled nmethods' 0 ==> CodeHeap 'non-profiled nmethods' 13952 ==>