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

Feature issue Allow defining shared memory size at runtime #282 #285

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

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?

@@ -19,6 +19,8 @@

static bool global_shm_initialized = false;

size_t BPFTIME_SHARED_MEMORY_SIZE = 20; // Default size
Copy link
Contributor

Choose a reason for hiding this comment

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

non-const variables should not be in upper case

.help("Set the size of the shared memory in megabytes")
.default_value(std::string("20")) // defaulting to the original #define value
.action([](const std::string& value) {
BPFTIME_SHARED_MEMORY_SIZE = std::stoi(value); // Convert MB to bytes
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you tested this program? CLI will not be linked with runtime

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
2 participants