Repository navigation
Conversation
GCproto is written as name in symbol then Go side reads remaning parts.
✅ All contributors are covered under a CLA with YandexSee CONTRIBUTING.md for more info about Yandex Contributor License Agreement. The following contributors were found: (Only the first commit for a unique contributor is listed) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on merge of #123
This PR merges LuaJIT frames into the native call stack. Before this, Lua frames were shown as a separate block at the bottom of the flamegraph, even below kernel, so the flamegraph didn’t show where execution crossed between Lua and C. VM dispatch frames such as
lj_BC_TSETSalso stayed visible even when the Lua frames already described what was running, making the flamegraph harder to read because of fragmentized nodes.Changes
How it works
Capture the VM range in eBPF. The Lua stack starts with a metadata frame containing the VM address range and unwind status. The agent gives it the same native mapping as the VM code so its addresses stay aligned with the native stack during profile conversion.
Find where Lua calls into C. Native C call markers split the Lua stack into segments. Protected calls such as
pcallandxpcallare special, they are C fast-functions, but they don't create a frame on a native stack, to prevent breaking merging FF frames hold the type. The merger walks from the root toward the leaf and matches the Lua segments to native frames whose addresses fall inside the VM range.Replace VM frames with Lua frames. A matched dispatch frame is replaced by its Lua segment. If the segment ends in an assembly fast function represented by the native VM frame, the merger keeps that native frame and drops the duplicate Lua builtin. For example,
tostringcan appear asLua caller → lj_ff_tostring → lj_strfmt_num.Keep the original frames when a match is uncertain. If a stack is truncated or the boundaries don’t line up, the merger keeps both stacks and places the Lua frames between the native user-space frames and the kernel frames. Such situations are still not uncommon, potential heuristics might be added in the future.
Lua collection remains opt-in and thus doesn't support backwards compatibility with previously recorded samples. Lua postprocessing runs after the existing Python and PHP passes.
Testing
Regression tests cover interleaved Lua and C calls, native fast functions, fallback, disabled merging, and profile conversion. The Go unwinder and C++ native pipeline suites passed all 65 tests after the wire fixtures were updated.