adds -Dmemory-log=true build option to save |mass output to a file

This commit is contained in:
Joe Bryan 2019-01-29 22:13:31 -05:00
parent 7ce31c1a59
commit 98590cccb5
4 changed files with 29 additions and 1 deletions

View File

@ -13,5 +13,6 @@
#mesondefine U3_MEMORY_DEBUG #mesondefine U3_MEMORY_DEBUG
#mesondefine U3_CPU_DEBUG #mesondefine U3_CPU_DEBUG
#mesondefine U3_EVENT_TIME_DEBUG #mesondefine U3_EVENT_TIME_DEBUG
#mesondefine U3_MEMORY_LOG
#endif /*CONFIG_H*/ #endif /*CONFIG_H*/

View File

@ -240,6 +240,7 @@ conf_data.set('URBIT_VERSION', '"0.7.0"')
conf_data.set('U3_MEMORY_DEBUG', get_option('gc')) conf_data.set('U3_MEMORY_DEBUG', get_option('gc'))
conf_data.set('U3_CPU_DEBUG', get_option('prof')) conf_data.set('U3_CPU_DEBUG', get_option('prof'))
conf_data.set('U3_EVENT_TIME_DEBUG', get_option('event-time')) conf_data.set('U3_EVENT_TIME_DEBUG', get_option('event-time'))
conf_data.set('U3_MEMORY_LOG', get_option('memory-log'))
osdet = host_machine.system() osdet = host_machine.system()
cc = meson.get_compiler('c') cc = meson.get_compiler('c')

View File

@ -4,5 +4,7 @@ option('prof', type : 'boolean', value : false,
description : 'Activate profiling. Run with -P.') description : 'Activate profiling. Run with -P.')
option('event-time', type : 'boolean', value : false, option('event-time', type : 'boolean', value : false,
description : 'Print timing information per event.') description : 'Print timing information per event.')
option('memory-log', type : 'boolean', value : false,
description : 'Write memory usage to a logfile.')
option('nix', type: 'boolean', value: false, option('nix', type: 'boolean', value: false,
description: 'Build using nix.') description: 'Build using nix.')

View File

@ -1856,7 +1856,25 @@ _raft_grab(u3_noun rus)
if ( u3_nul != u3A->sac ) { if ( u3_nul != u3A->sac ) {
c3_w usr_w = 0, man_w = 0, ova_w = 0, sac_w = 0; c3_w usr_w = 0, man_w = 0, ova_w = 0, sac_w = 0;
FILE* fil_u = stderr; FILE* fil_u;
#ifdef U3_MEMORY_LOG
{
c3_c* wen_c = u3r_string(u3A->wen);
c3_c nam_c[2048];
snprintf(nam_c, 2048, "%s/.urb/put/%s-mass.txt", u3_Host.dir_c, wen_c);
fil_u = fopen(nam_c, "w");
fprintf(fil_u, "%s\r\n", wen_c);
free(wen_c);
}
#else
{
fil_u = stderr;
}
#endif
c3_assert( u3R == &(u3H->rod_u) ); c3_assert( u3R == &(u3H->rod_u) );
@ -1876,6 +1894,12 @@ _raft_grab(u3_noun rus)
u3a_print_memory(fil_u, "sweep", u3a_sweep()); u3a_print_memory(fil_u, "sweep", u3a_sweep());
#ifdef U3_MEMORY_LOG
{
fclose(fil_u);
}
#endif
// u3h_free(u3R->cax.har_p); // u3h_free(u3R->cax.har_p);
// u3R->cax.har_p = u3h_new(); // u3R->cax.har_p = u3h_new();