mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 16:10:54 +00:00
Avoid mallocs in process_sample()
This commit is contained in:
2
TODO
2
TODO
@ -23,6 +23,8 @@ Before 1.0.4:
|
|||||||
|
|
||||||
Before 1.2:
|
Before 1.2:
|
||||||
|
|
||||||
|
* Kernel binary when available, is better than kallsyms.
|
||||||
|
|
||||||
* Hack around gtk+ bug where it mispositions the window.
|
* Hack around gtk+ bug where it mispositions the window.
|
||||||
|
|
||||||
* Counters must not be destroyed during tracker setup. They have to exist
|
* Counters must not be destroyed during tracker setup. They have to exist
|
||||||
|
|||||||
@ -885,6 +885,7 @@ process_sample (state_t *state, StackStash *resolved, sample_t *sample)
|
|||||||
{
|
{
|
||||||
const context_info_t *context = NULL;
|
const context_info_t *context = NULL;
|
||||||
const char *cmdline;
|
const char *cmdline;
|
||||||
|
uint64_t stack_addrs[256];
|
||||||
uint64_t *resolved_traces;
|
uint64_t *resolved_traces;
|
||||||
process_t *process;
|
process_t *process;
|
||||||
StackNode *n;
|
StackNode *n;
|
||||||
@ -908,7 +909,10 @@ process_sample (state_t *state, StackStash *resolved, sample_t *sample)
|
|||||||
for (n = sample->trace; n != NULL; n = n->parent)
|
for (n = sample->trace; n != NULL; n = n->parent)
|
||||||
len++;
|
len++;
|
||||||
|
|
||||||
resolved_traces = g_new (uint64_t, len);
|
if (len > 256)
|
||||||
|
resolved_traces = g_new (uint64_t, len);
|
||||||
|
else
|
||||||
|
resolved_traces = stack_addrs;
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
for (n = sample->trace; n != NULL; n = n->parent)
|
for (n = sample->trace; n != NULL; n = n->parent)
|
||||||
@ -946,7 +950,8 @@ process_sample (state_t *state, StackStash *resolved, sample_t *sample)
|
|||||||
|
|
||||||
stack_stash_add_trace (resolved, resolved_traces, len, 1);
|
stack_stash_add_trace (resolved, resolved_traces, len, 1);
|
||||||
|
|
||||||
g_free (resolved_traces);
|
if (resolved_traces != stack_addrs)
|
||||||
|
g_free (resolved_traces);
|
||||||
}
|
}
|
||||||
|
|
||||||
Profile *
|
Profile *
|
||||||
|
|||||||
Reference in New Issue
Block a user