comparison src/share/vm/memory/metaspaceShared.cpp @ 7591:c793367610c1

8005467: CDS size information is incorrect and unfriendly Summary: Changed words to bytes, and added usage percentage information Reviewed-by: coleenp, twisti Contributed-by: ioi.lam@oracle.com
author coleenp
date Tue, 15 Jan 2013 17:05:53 -0500
parents 6c3f47d964f3
children 868d87ed63c8
comparison
equal deleted inserted replaced
7590:fe1472c87a27 7591:c793367610c1
1 /* 1 /*
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
371 WriteClosure wc(md_top, md_end); 371 WriteClosure wc(md_top, md_end);
372 MetaspaceShared::serialize(&wc); 372 MetaspaceShared::serialize(&wc);
373 md_top = wc.get_top(); 373 md_top = wc.get_top();
374 374
375 // Print shared spaces all the time 375 // Print shared spaces all the time
376 const char* fmt = "%s space: " PTR_FORMAT " out of " PTR_FORMAT " words allocated at " PTR_FORMAT "."; 376 const char* fmt = "%s space: %9d [ %4.1f%% of total] out of %9d bytes [%4.1f%% used] at " PTR_FORMAT;
377 Metaspace* ro_space = _loader_data->ro_metaspace(); 377 Metaspace* ro_space = _loader_data->ro_metaspace();
378 Metaspace* rw_space = _loader_data->rw_metaspace(); 378 Metaspace* rw_space = _loader_data->rw_metaspace();
379 tty->print_cr(fmt, "ro", ro_space->used_words(Metaspace::NonClassType), 379 const size_t BPW = BytesPerWord;
380 ro_space->capacity_words(Metaspace::NonClassType), 380
381 ro_space->bottom()); 381 // Allocated size of each space (may not be all occupied)
382 tty->print_cr(fmt, "rw", rw_space->used_words(Metaspace::NonClassType), 382 const size_t ro_alloced = ro_space->capacity_words(Metaspace::NonClassType) * BPW;
383 rw_space->capacity_words(Metaspace::NonClassType), 383 const size_t rw_alloced = rw_space->capacity_words(Metaspace::NonClassType) * BPW;
384 rw_space->bottom()); 384 const size_t md_alloced = md_end-md_low;
385 tty->print_cr(fmt, "md", md_top - md_low, md_end-md_low, md_low); 385 const size_t mc_alloced = mc_end-mc_low;
386 tty->print_cr(fmt, "mc", mc_top - mc_low, mc_end-mc_low, mc_low); 386 const size_t total_alloced = ro_alloced + rw_alloced + md_alloced + mc_alloced;
387
388 // Occupied size of each space.
389 const size_t ro_bytes = ro_space->used_words(Metaspace::NonClassType) * BPW;
390 const size_t rw_bytes = rw_space->used_words(Metaspace::NonClassType) * BPW;
391 const size_t md_bytes = size_t(md_top - md_low);
392 const size_t mc_bytes = size_t(mc_top - mc_low);
393
394 // Percent of total size
395 const size_t total_bytes = ro_bytes + rw_bytes + md_bytes + mc_bytes;
396 const double ro_t_perc = ro_bytes / double(total_bytes) * 100.0;
397 const double rw_t_perc = rw_bytes / double(total_bytes) * 100.0;
398 const double md_t_perc = md_bytes / double(total_bytes) * 100.0;
399 const double mc_t_perc = mc_bytes / double(total_bytes) * 100.0;
400
401 // Percent of fullness of each space
402 const double ro_u_perc = ro_bytes / double(ro_alloced) * 100.0;
403 const double rw_u_perc = rw_bytes / double(rw_alloced) * 100.0;
404 const double md_u_perc = md_bytes / double(md_alloced) * 100.0;
405 const double mc_u_perc = mc_bytes / double(mc_alloced) * 100.0;
406 const double total_u_perc = total_bytes / double(total_alloced) * 100.0;
407
408 tty->print_cr(fmt, "ro", ro_bytes, ro_t_perc, ro_alloced, ro_u_perc, ro_space->bottom());
409 tty->print_cr(fmt, "rw", rw_bytes, rw_t_perc, rw_alloced, rw_u_perc, rw_space->bottom());
410 tty->print_cr(fmt, "md", md_bytes, md_t_perc, md_alloced, md_u_perc, md_low);
411 tty->print_cr(fmt, "mc", mc_bytes, mc_t_perc, mc_alloced, mc_u_perc, mc_low);
412 tty->print_cr("total : %9d [100.0%% of total] out of %9d bytes [%4.1f%% used]",
413 total_bytes, total_alloced, total_u_perc);
387 414
388 // Update the vtable pointers in all of the Klass objects in the 415 // Update the vtable pointers in all of the Klass objects in the
389 // heap. They should point to newly generated vtable. 416 // heap. They should point to newly generated vtable.
390 patch_klass_vtables(vtbl_list, vtable); 417 patch_klass_vtables(vtbl_list, vtable);
391 418