vm: room. now prints mark stack size, and total/contiguous free space
parent
49baf397f4
commit
cf247c23a2
|
@ -507,10 +507,10 @@ M: bad-executable summary
|
||||||
|
|
||||||
\ (save-image-and-exit) { byte-array } { } define-primitive
|
\ (save-image-and-exit) { byte-array } { } define-primitive
|
||||||
|
|
||||||
\ data-room { } { integer integer array } define-primitive
|
\ data-room { } { array } define-primitive
|
||||||
\ data-room make-flushable
|
\ data-room make-flushable
|
||||||
|
|
||||||
\ code-room { } { integer integer integer integer } define-primitive
|
\ code-room { } { array } define-primitive
|
||||||
\ code-room make-flushable
|
\ code-room make-flushable
|
||||||
|
|
||||||
\ micros { } { integer } define-primitive
|
\ micros { } { integer } define-primitive
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
! Copyright (C) 2005, 2008 Slava Pestov.
|
! Copyright (C) 2005, 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: kernel sequences arrays generic assocs io math
|
USING: kernel sequences arrays generic assocs io math
|
||||||
namespaces parser prettyprint strings io.styles words
|
namespaces parser prettyprint strings io.styles words
|
||||||
|
@ -8,48 +8,41 @@ IN: tools.memory
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
: write-size ( n -- )
|
: kilobytes ( n -- str )
|
||||||
number>string
|
number>string
|
||||||
dup length 4 > [ 3 cut* "," glue ] when
|
dup length 4 > [ 3 cut* "," glue ] when
|
||||||
" KB" append write-cell ;
|
" KB" append ;
|
||||||
|
|
||||||
: write-total/used/free ( free total str -- )
|
: memory-table. ( sizes seq -- )
|
||||||
[
|
swap [ kilobytes ] map zip simple-table. ;
|
||||||
write-cell
|
|
||||||
dup write-size
|
|
||||||
over - write-size
|
|
||||||
write-size
|
|
||||||
] with-row ;
|
|
||||||
|
|
||||||
: write-total ( n str -- )
|
: young-room. ( seq -- )
|
||||||
[
|
{ "Total:" "Allocated:" "Free:" } memory-table. ;
|
||||||
write-cell
|
|
||||||
write-size
|
|
||||||
[ ] with-cell
|
|
||||||
[ ] with-cell
|
|
||||||
] with-row ;
|
|
||||||
|
|
||||||
: write-headings ( seq -- )
|
: nursery-room. ( seq -- ) "- Nursery space" print young-room. ;
|
||||||
[ [ write-cell ] each ] with-row ;
|
|
||||||
|
|
||||||
: (data-room.) ( -- )
|
: aging-room. ( seq -- ) "- Aging space" print young-room. ;
|
||||||
data-room 2 <groups> [
|
|
||||||
[ first2 ] [ number>string "Generation " prepend ] bi*
|
|
||||||
write-total/used/free
|
|
||||||
] each-index
|
|
||||||
"Decks" write-total
|
|
||||||
"Cards" write-total ;
|
|
||||||
|
|
||||||
: write-labeled-size ( n string -- )
|
: mark-sweep-table. ( sizes -- )
|
||||||
[ write-cell write-size ] with-row ;
|
{ "Total:" "Allocated:" "Contiguous free:" "Total free:" } memory-table. ;
|
||||||
|
|
||||||
: (code-room.) ( -- )
|
: tenured-room. ( seq -- ) "- Tenured space" print mark-sweep-table. ;
|
||||||
code-room {
|
|
||||||
[ "Size:" write-labeled-size ]
|
: misc-room. ( seq -- )
|
||||||
[ "Used:" write-labeled-size ]
|
"- Miscellaneous buffers" print
|
||||||
[ "Total free space:" write-labeled-size ]
|
{ "Card array:" "Deck array:" "Mark stack:" } memory-table. ;
|
||||||
[ "Largest free block:" write-labeled-size ]
|
|
||||||
} spread ;
|
: data-room. ( -- )
|
||||||
|
"==== DATA HEAP" print nl
|
||||||
|
data-room
|
||||||
|
3 cut [ nursery-room. nl ] dip
|
||||||
|
3 cut [ aging-room. nl ] dip
|
||||||
|
4 cut [ tenured-room. nl ] dip
|
||||||
|
misc-room. ;
|
||||||
|
|
||||||
|
: code-room. ( -- )
|
||||||
|
"==== CODE HEAP" print nl
|
||||||
|
code-room mark-sweep-table. ;
|
||||||
|
|
||||||
: heap-stat-step ( obj counts sizes -- )
|
: heap-stat-step ( obj counts sizes -- )
|
||||||
[ [ class ] dip inc-at ]
|
[ [ class ] dip inc-at ]
|
||||||
|
@ -57,18 +50,7 @@ IN: tools.memory
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: room. ( -- )
|
: room. ( -- ) data-room. nl code-room. ;
|
||||||
"==== DATA HEAP" print
|
|
||||||
standard-table-style [
|
|
||||||
{ "" "Total" "Used" "Free" } write-headings
|
|
||||||
(data-room.)
|
|
||||||
] tabular-output
|
|
||||||
nl nl
|
|
||||||
"==== CODE HEAP" print
|
|
||||||
standard-table-style [
|
|
||||||
(code-room.)
|
|
||||||
] tabular-output
|
|
||||||
nl ;
|
|
||||||
|
|
||||||
: heap-stats ( -- counts sizes )
|
: heap-stats ( -- counts sizes )
|
||||||
[ ] instances H{ } clone H{ } clone
|
[ ] instances H{ } clone H{ } clone
|
||||||
|
@ -76,7 +58,7 @@ PRIVATE>
|
||||||
|
|
||||||
: heap-stats. ( -- )
|
: heap-stats. ( -- )
|
||||||
heap-stats dup keys natural-sort standard-table-style [
|
heap-stats dup keys natural-sort standard-table-style [
|
||||||
{ "Class" "Bytes" "Instances" } write-headings
|
[ { "Class" "Bytes" "Instances" } [ write-cell ] each ] with-row
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
dup pprint-cell
|
dup pprint-cell
|
||||||
|
|
|
@ -197,12 +197,18 @@ void factor_vm::primitive_modify_code_heap()
|
||||||
/* Push the free space and total size of the code heap */
|
/* Push the free space and total size of the code heap */
|
||||||
void factor_vm::primitive_code_room()
|
void factor_vm::primitive_code_room()
|
||||||
{
|
{
|
||||||
|
growable_array a(this);
|
||||||
|
|
||||||
cell used, total_free, max_free;
|
cell used, total_free, max_free;
|
||||||
code->allocator->usage(&used,&total_free,&max_free);
|
code->allocator->usage(&used,&total_free,&max_free);
|
||||||
dpush(tag_fixnum(code->seg->size / 1024));
|
|
||||||
dpush(tag_fixnum(used / 1024));
|
a.add(tag_fixnum(code->seg->size >> 10));
|
||||||
dpush(tag_fixnum(total_free / 1024));
|
a.add(tag_fixnum(used >> 10));
|
||||||
dpush(tag_fixnum(max_free / 1024));
|
a.add(tag_fixnum(total_free >> 10));
|
||||||
|
a.add(tag_fixnum(max_free >> 10));
|
||||||
|
|
||||||
|
a.trim();
|
||||||
|
dpush(a.elements.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stack_trace_stripper {
|
struct stack_trace_stripper {
|
||||||
|
|
|
@ -204,22 +204,26 @@ void factor_vm::primitive_size()
|
||||||
/* Push memory usage statistics in data heap */
|
/* Push memory usage statistics in data heap */
|
||||||
void factor_vm::primitive_data_room()
|
void factor_vm::primitive_data_room()
|
||||||
{
|
{
|
||||||
dpush(tag_fixnum((data->cards_end - data->cards) >> 10));
|
|
||||||
dpush(tag_fixnum((data->decks_end - data->decks) >> 10));
|
|
||||||
|
|
||||||
growable_array a(this);
|
growable_array a(this);
|
||||||
|
|
||||||
a.add(tag_fixnum((nursery.end - nursery.here) >> 10));
|
|
||||||
a.add(tag_fixnum((nursery.size) >> 10));
|
a.add(tag_fixnum((nursery.size) >> 10));
|
||||||
|
a.add(tag_fixnum((nursery.here - nursery.start) >> 10));
|
||||||
|
a.add(tag_fixnum((nursery.end - nursery.here) >> 10));
|
||||||
|
|
||||||
a.add(tag_fixnum((data->aging->end - data->aging->here) >> 10));
|
|
||||||
a.add(tag_fixnum((data->aging->size) >> 10));
|
a.add(tag_fixnum((data->aging->size) >> 10));
|
||||||
|
a.add(tag_fixnum((data->aging->here - data->aging->start) >> 10));
|
||||||
|
a.add(tag_fixnum((data->aging->end - data->aging->here) >> 10));
|
||||||
|
|
||||||
//XXX
|
|
||||||
cell used, total_free, max_free;
|
cell used, total_free, max_free;
|
||||||
data->tenured->usage(&used,&total_free,&max_free);
|
data->tenured->usage(&used,&total_free,&max_free);
|
||||||
a.add(tag_fixnum(total_free >> 10));
|
|
||||||
a.add(tag_fixnum(data->tenured->size >> 10));
|
a.add(tag_fixnum(data->tenured->size >> 10));
|
||||||
|
a.add(tag_fixnum(used >> 10));
|
||||||
|
a.add(tag_fixnum(total_free >> 10));
|
||||||
|
a.add(tag_fixnum(max_free >> 10));
|
||||||
|
|
||||||
|
a.add(tag_fixnum((data->cards_end - data->cards) >> 10));
|
||||||
|
a.add(tag_fixnum((data->decks_end - data->decks) >> 10));
|
||||||
|
a.add(tag_fixnum((data->tenured->mark_stack.capacity()) >> 10));
|
||||||
|
|
||||||
a.trim();
|
a.trim();
|
||||||
dpush(a.elements.value());
|
dpush(a.elements.value());
|
||||||
|
|
Loading…
Reference in New Issue