Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions support/ebpf/interpreter_dispatcher.ebpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,17 +434,17 @@ static EBPF_INLINE bool get_node_env_ptr(V8ProcInfo *proc, u64 *env_ptr_out)
return true;
}

static EBPF_INLINE bool get_node_async_id(V8ProcInfo *proc, u32 tid, u64 *out)
static EBPF_INLINE bool get_node_async_id(V8ProcInfo *proc, u64 pid_tgid, u64 *out)
{
int err;

u64 env_ptr;
// Try to get fresh env_ptr
if (get_node_env_ptr(proc, &env_ptr)) {
bpf_map_update_elem(&v8_cached_env_ptrs, &tid, &env_ptr, BPF_ANY);
bpf_map_update_elem(&v8_cached_env_ptrs, &pid_tgid, &env_ptr, BPF_ANY);
} else {
// Fallback to cached value from previous successful extraction
u64 *cached_env_ptr = bpf_map_lookup_elem(&v8_cached_env_ptrs, &tid);
u64 *cached_env_ptr = bpf_map_lookup_elem(&v8_cached_env_ptrs, &pid_tgid);
if (cached_env_ptr && *cached_env_ptr != 0) {
// TODO[btv] -- Figure out why the environment is sometimes null.
// It doesn't seem to matter in practice, since the environment rarely (never?)
Expand Down Expand Up @@ -649,7 +649,8 @@ static EBPF_INLINE void maybe_add_node_custom_labels(PerCPURecord *record)
}

u64 id;
bool success = get_node_async_id(v8_proc, record->trace.tid, &id);
u64 pid_tgid = (u64)record->trace.pid << 32 | record->trace.tid;
bool success = get_node_async_id(v8_proc, pid_tgid, &id);
if (success) {
if (id == 0) {
increment_metric(metricID_UnwindNodeClWarnIdZero);
Expand Down
Binary file modified support/ebpf/tracer.ebpf.amd64
Binary file not shown.
Binary file modified support/ebpf/tracer.ebpf.arm64
Binary file not shown.
2 changes: 1 addition & 1 deletion support/ebpf/v8_tracer.ebpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bpf_map_def SEC("maps") v8_procs = {
// Map from thread IDs to cached Node.js environment pointers
bpf_map_def SEC("maps") v8_cached_env_ptrs = {
.type = BPF_MAP_TYPE_LRU_HASH,
.key_size = sizeof(u32), // TID
.key_size = sizeof(u64), // pid+tid
.value_size = sizeof(u64), // cached environment pointer
.max_entries = 4096, // more threads than processes
};
Expand Down
Loading