RFR: 8257234 : Add gz option to SA jmap to write a gzipped heap dump [v9]

Lin Zang lzang at openjdk.java.net
Tue Jan 26 10:25:43 UTC 2021


On Tue, 26 Jan 2021 04:41:40 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:

>> So the problem is that the code in GzipRandomAccess.getAccess() returns NULL if it doesn't find the "HPROF BLOCKSIZE" comment, but you are also saying that tools like heaphero.io work fine without the comment. So maybe you just need to fix GzipRandomAccess.getAccess() to use a default blocksize if none is specified.
>> 
>> On the other hand, it seems it would be best if the SA hprof file was no different than the jcmd hprof file, and the SA file also included the comment. But as you said GZIPOutputStream() does not support adding a comment in the same manner as the zlib library does. I'm not sure how you would go about adding the support, so probably it is not worth it.
>
> As for any testing requirement, maybe you could pass in a flag to Reader indicating whether or not the testing requires the "HPROF BLOCKSIZE"  comment.

Hi Chris,
I did more investigation today, IMHO, it is too complicated to modify the GzipRandomAccess because there are lots codes required to be modified in getAccess() and read() to handle the differences of headers, and also it may not be ok to define a default value for "HPROF BLOCKSIZE=" because the value seems to be used as a hint for decompression. 
On the other hand, I think it is possible to define a private class in HeapHprofBinWriter.cpp  that extends GZIPOutputStream, and then overwrite writeHeader() to add HPROF BLOCKSIZE as file commends, I saw there is logic in GZipInputStream's readHeader() that process this kind of info as file comments.  Then we can have same format of gziped heap dump file from jmap. 
I am working on the patch and will update when it is ready.

Thanks.
Lin

-------------

PR: https://git.openjdk.java.net/jdk/pull/1712


More information about the serviceability-dev mailing list