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

Allow defining shared memory size at runtime #285

Merged
merged 4 commits into from
Aug 9, 2024

Conversation

NobinPegasus
Copy link
Contributor

Description

I have declared extern size_t BPFTIME_SHARED_MEMORY_SIZE; inside bpftime_shm_internal.hpp and inside bpftime_shm_internal.cpp defined the size_t BPFTIME_SHARED_MEMORY_SIZE = 20; // Default size

Then inside the cli/main.cpp I have added support for --shared-memory-size.

Fixes #282

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • [✅] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Test A
  • Test B

Test Configuration:

Checklist

  • [✅] My code follows the style guidelines of this project
  • [✅] I have performed a self-review of my own code
  • [✅] I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • [✅] I have checked my code and corrected any misspellings

@Officeyutong
Copy link
Contributor

@NobinPegasus Is this PR finished yet? I haven't seen things related to read environment variables

@NobinPegasus
Copy link
Contributor Author

@Officeyutong I've make changes in tools/cli/main.cpp. Can you check it? And provide feedback?

runtime/src/bpftime_shm_internal.cpp Outdated Show resolved Hide resolved
tools/cli/main.cpp Outdated Show resolved Hide resolved
@yunwei37
Copy link
Member

yunwei37 commented Aug 9, 2024

What I have done is:

  1. Add new env var for shm size
  2. Make the config a separate file
  3. Fix the wrong default value of the config

The document also needs to be changed, since we set the JIT as default engine.

Another thing I need to do in the next PR is

  • merge the syscall server config with this config
  • rename agent config to bpftime_config, so it's global

@yunwei37 yunwei37 changed the title Feature issue Allow defining shared memory size at runtime #282 Allow defining shared memory size at runtime #282 Aug 9, 2024
@yunwei37 yunwei37 changed the title Allow defining shared memory size at runtime #282 Allow defining shared memory size at runtime Aug 9, 2024
@yunwei37 yunwei37 merged commit b86c6a3 into eunomia-bpf:master Aug 9, 2024
70 checks passed
// memory size will determine the maximum size of the shared memory
// available for the eBPF programs and maps
// The value is in MB
int shm_memory_size = 20; // 20MB
Copy link
Contributor

Choose a reason for hiding this comment

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

Will bytes be better?

segment = boost::interprocess::managed_shared_memory(
boost::interprocess::open_or_create,
// Allocate 200M bytes of memory by default
shm_name, 200 << 20);
// Allocate 20M bytes of memory by default
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment should be updated

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

Successfully merging this pull request may close these issues.

[FEATURE] Allow defining shared memory size at runtime
3 participants