Skip to content

runtime: make BPF Loader v3 structs zero-alloc #5079

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ripatel-fd
Copy link
Contributor

types: add APIs for zero alloc decoding

  • Add helper for converting between pointer and flat option
    representation
  • Add decode_flat helper

runtime: make BPF Loader v3 structs zero-alloc

Removes dynamic allocations in BPF Loader v3 by turning pointer
option types into flat option types.

@ripatel-fd ripatel-fd force-pushed the ripatel/loader-v3-noalloc branch from 62ec884 to 41021bb Compare May 11, 2025 21:20
riptl added 2 commits May 11, 2025 21:25
- Add helper for converting between pointer and flat option
  representation
- Add decode_flat helper
Removes dynamic allocations in BPF Loader v3 by turning pointer
option types into flat option types.
@ripatel-fd ripatel-fd force-pushed the ripatel/loader-v3-noalloc branch from 41021bb to 8750751 Compare May 11, 2025 21:25
if( ptr ) (target . name) = *ptr; \
}

/* fd_types_option_flat_to_nullable creates a nullable pointer to a flat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* fd_types_option_flat_to_nullable creates a nullable pointer to a flat
/* fd_types_option_flat_to_nullable creates a nullable pointer from a flat

}
}
};
fd_types_option_flat_from_nullable(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fd_types_option_flat_from_nullable ends up getting repeated everywhere we set up a bpf loader state struct. I'd prefer using a setup / init function for fd_bpf_upfradeable_loader_state_t to reduce the repetition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cali-jumptrading Good point. We could also have a macro that expands to initializer syntax like this:

my_struct_t s = {
  .inner = {
    fd_types_option_flat_init_from_nullable(  option_name, pointer ),
    .bla = x,
  }
};

The macro name is disgusting. If you have better ideas, please shout!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants