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
|
||||
|
||||
\ data-room { } { integer integer array } define-primitive
|
||||
\ data-room { } { array } define-primitive
|
||||
\ data-room make-flushable
|
||||
|
||||
\ code-room { } { integer integer integer integer } define-primitive
|
||||
\ code-room { } { array } define-primitive
|
||||
\ code-room make-flushable
|
||||
|
||||
\ 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.
|
||||
USING: kernel sequences arrays generic assocs io math
|
||||
namespaces parser prettyprint strings io.styles words
|
||||
|
@ -8,48 +8,41 @@ IN: tools.memory
|
|||
|
||||
<PRIVATE
|
||||
|
||||
: write-size ( n -- )
|
||||
: kilobytes ( n -- str )
|
||||
number>string
|
||||
dup length 4 > [ 3 cut* "," glue ] when
|
||||
" KB" append write-cell ;
|
||||
" KB" append ;
|
||||
|
||||
: write-total/used/free ( free total str -- )
|
||||
[
|
||||
write-cell
|
||||
dup write-size
|
||||
over - write-size
|
||||
write-size
|
||||
] with-row ;
|
||||
: memory-table. ( sizes seq -- )
|
||||
swap [ kilobytes ] map zip simple-table. ;
|
||||
|
||||
: write-total ( n str -- )
|
||||
[
|
||||
write-cell
|
||||
write-size
|
||||
[ ] with-cell
|
||||
[ ] with-cell
|
||||
] with-row ;
|
||||
: young-room. ( seq -- )
|
||||
{ "Total:" "Allocated:" "Free:" } memory-table. ;
|
||||
|
||||
: write-headings ( seq -- )
|
||||
[ [ write-cell ] each ] with-row ;
|
||||
: nursery-room. ( seq -- ) "- Nursery space" print young-room. ;
|
||||
|
||||
: (data-room.) ( -- )
|
||||
data-room 2 <groups> [
|
||||
[ first2 ] [ number>string "Generation " prepend ] bi*
|
||||
write-total/used/free
|
||||
] each-index
|
||||
"Decks" write-total
|
||||
"Cards" write-total ;
|
||||
: aging-room. ( seq -- ) "- Aging space" print young-room. ;
|
||||
|
||||
: write-labeled-size ( n string -- )
|
||||
[ write-cell write-size ] with-row ;
|
||||
: mark-sweep-table. ( sizes -- )
|
||||
{ "Total:" "Allocated:" "Contiguous free:" "Total free:" } memory-table. ;
|
||||
|
||||
: (code-room.) ( -- )
|
||||
code-room {
|
||||
[ "Size:" write-labeled-size ]
|
||||
[ "Used:" write-labeled-size ]
|
||||
[ "Total free space:" write-labeled-size ]
|
||||
[ "Largest free block:" write-labeled-size ]
|
||||
} spread ;
|
||||
: tenured-room. ( seq -- ) "- Tenured space" print mark-sweep-table. ;
|
||||
|
||||
: misc-room. ( seq -- )
|
||||
"- Miscellaneous buffers" print
|
||||
{ "Card array:" "Deck array:" "Mark stack:" } memory-table. ;
|
||||
|
||||
: 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 -- )
|
||||
[ [ class ] dip inc-at ]
|
||||
|
@ -57,18 +50,7 @@ IN: tools.memory
|
|||
|
||||
PRIVATE>
|
||||
|
||||
: 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 ;
|
||||
: room. ( -- ) data-room. nl code-room. ;
|
||||
|
||||
: heap-stats ( -- counts sizes )
|
||||
[ ] instances H{ } clone H{ } clone
|
||||
|
@ -76,7 +58,7 @@ PRIVATE>
|
|||
|
||||
: heap-stats. ( -- )
|
||||
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
|
||||
|
|
|
@ -197,12 +197,18 @@ void factor_vm::primitive_modify_code_heap()
|
|||
/* Push the free space and total size of the code heap */
|
||||
void factor_vm::primitive_code_room()
|
||||
{
|
||||
growable_array a(this);
|
||||
|
||||
cell 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));
|
||||
dpush(tag_fixnum(total_free / 1024));
|
||||
dpush(tag_fixnum(max_free / 1024));
|
||||
|
||||
a.add(tag_fixnum(code->seg->size >> 10));
|
||||
a.add(tag_fixnum(used >> 10));
|
||||
a.add(tag_fixnum(total_free >> 10));
|
||||
a.add(tag_fixnum(max_free >> 10));
|
||||
|
||||
a.trim();
|
||||
dpush(a.elements.value());
|
||||
}
|
||||
|
||||
struct stack_trace_stripper {
|
||||
|
|
|
@ -204,22 +204,26 @@ void factor_vm::primitive_size()
|
|||
/* Push memory usage statistics in data heap */
|
||||
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);
|
||||
|
||||
a.add(tag_fixnum((nursery.end - nursery.here) >> 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->here - data->aging->start) >> 10));
|
||||
a.add(tag_fixnum((data->aging->end - data->aging->here) >> 10));
|
||||
|
||||
//XXX
|
||||
cell 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(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();
|
||||
dpush(a.elements.value());
|
||||
|
|
Loading…
Reference in New Issue