Skip to content

Commit

Permalink
Merge pull request erlang#7236 from jhogberg/john/erts/extend-allocat…
Browse files Browse the repository at this point in the history
…ion-tags-26/OTP-18577

erts/instrument: Extend allocation tags with per-process/port and code tracking
  • Loading branch information
jhogberg committed May 27, 2023
2 parents 24b0d99 + 4ff9a93 commit a984d16
Show file tree
Hide file tree
Showing 15 changed files with 474 additions and 221 deletions.
2 changes: 1 addition & 1 deletion erts/doc/src/erts_alloc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@
<seeerl marker="runtime_tools:instrument"><c>instrument</c></seeerl>
module to inspect this information.</p>

<p>The runtime overhead is one word per allocation when enabled. This
<p>The runtime overhead is two words per allocation when enabled. This
may change at any time in the future.</p>

<p>The default is <c>true</c> for <c>binary_alloc</c> and
Expand Down
30 changes: 29 additions & 1 deletion erts/emulator/beam/erl_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,35 @@ handle_au_arg(struct au_init *auip,
auip->init.util.acful = 0;
}
} else if (has_prefix("atags", sub_param)) {
auip->init.util.atags = get_bool_value(sub_param + 5, argv, ip);
char *param_end = &sub_param[5];
char *value;

value = get_value(param_end, argv, ip);

if (sys_strcmp(value, "true") == 0) {
auip->init.util.atags = 1;
} else if (sys_strcmp(value, "false") == 0) {
auip->init.util.atags = 0;
} else if (sys_strcmp(value, "code") == 0) {
/* Undocumented option for point-of-origin tracking: overrides
* per-pid/port tracking in favor of tracking which Erlang code
* led to the allocation (best effort, but pretty accurate
* under the JIT). */
auip->init.util.atags = 2;

#if !defined(BEAMASM)
if (!erts_alcu_enable_code_atags) {
erts_fprintf(stderr,
"WARNING: The experimental +M<S>atags code "
"flag is inaccurate under the interpreter. "
"Consider running with the JIT instead\n");
}
#endif

erts_alcu_enable_code_atags = 1;
} else {
bad_value(sub_param, param_end, value);
}
}
else
goto bad_switch;
Expand Down
2 changes: 1 addition & 1 deletion erts/emulator/beam/erl_alloc.types
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ type MAP_TRAP SHORT_LIVED PROCESSES map_bif_trap_state

type ENVIRONMENT SYSTEM SYSTEM environment

type PERSISTENT_TERM LONG_LIVED CODE persisten_term
type PERSISTENT_TERM LONG_LIVED CODE persistent_term
type PERSISTENT_LOCK_Q SHORT_LIVED SYSTEM persistent_lock_q
type PERSISTENT_TERM_TMP SHORT_LIVED SYSTEM persistent_term_tmp_table

Expand Down

0 comments on commit a984d16

Please sign in to comment.