Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Free unwind information shapes #131

Merged
merged 1 commit into from
Jan 13, 2025
Merged
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 src/profiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ impl NativeUnwindState {
pub struct Profiler {
// Prevent the links from being removed.
_links: Vec<Link>,
_inner_unwind_info_map_shapes: Vec<MapHandle>,
native_unwinder_open_object: ManuallyDrop<Box<MaybeUninit<OpenObject>>>,
native_unwinder: ManuallyDrop<ProfilerSkel<'static>>,
tracers_open_object: ManuallyDrop<Box<MaybeUninit<OpenObject>>>,
Expand Down Expand Up @@ -213,7 +212,7 @@ impl Profiler {
) -> Vec<MapHandle> {
let mut map_shapes = Vec::with_capacity(native_unwind_info_bucket_sizes.len());

// Create the maps that hold unwind information for the native unwinder.
// Create the map shapes that hold unwind information for the native unwinder.
for (i, native_unwind_info_bucket_size) in
native_unwind_info_bucket_sizes.iter().enumerate()
{
Expand All @@ -223,7 +222,7 @@ impl Profiler {
};
let inner_map_shape = MapHandle::create(
MapType::Array,
Some(format!("inner_{}", i)),
Some(format!("inner_shape_{}", i)),
4,
8,
*native_unwind_info_bucket_size,
Expand Down Expand Up @@ -305,6 +304,9 @@ impl Profiler {
Self::set_profiler_map_sizes(&mut open_skel, &profiler_config);

let native_unwinder = ManuallyDrop::new(open_skel.load().expect("load skel"));
// The unwind information shapes are no longer needed after the native unwinder is loaded.
std::mem::drop(inner_unwind_info_map_shapes);

// SAFETY: native_unwinder never outlives native_unwinder_open_object
let native_unwinder = unsafe {
std::mem::transmute::<ManuallyDrop<ProfilerSkel<'_>>, ManuallyDrop<ProfilerSkel<'static>>>(
Expand Down Expand Up @@ -362,7 +364,6 @@ impl Profiler {

Profiler {
_links: Vec::new(),
_inner_unwind_info_map_shapes: inner_unwind_info_map_shapes,
native_unwinder_open_object,
native_unwinder,
tracers_open_object,
Expand Down