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

Add feature flag for reducing randomness in memalloc test #622

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aditijannu
Copy link

No description provided.

#[cfg(feature = "reduce_randomness")]
{
align = PAGE_SIZE;
size = match memsize {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: Can we have the size conditionally defined in the match case before this? Since both the size and the layout is being conditionally defined, I was thinking if we can have the size in the condition block this

/* Create a random size depending on the memory type */
        let (scan_interval, mut size, limit) = match memsize {
            MemSize::Large => {
                (
                    SCAN_INTERVAL_LARGE_THREAD,
                    #[cfg(feature = "reduce_randomness")] {crate::TO_GB * 1} 
                    #[cfg(not(feature = "reduce_randomness"))] {TO_GB * get_random_num(LARGE_THREAD_MEM_START, LARGE_THREAD_MEM_END)},
                    LIMIT_LARGE_THREAD,
                )
            }
            MemSize::Medium => {
                (
                    SCAN_INTERVAL_MEDIUM_THREAD,
                    // similarly for medium and small threads
                    TO_MB * get_random_num(MEDIUM_THREAD_MEM_START, MEDIUM_THREAD_MEM_END),
                    LIMIT_MEDIUM_THREAD,
                )
            }
            MemSize::Small => {
                (
                    SCAN_INTERVAL_SMALL_THREAD,
                    TO_KB * get_random_num(SMALL_THREAD_MEM_START, SMALL_THREAD_MEM_END),
                    LIMIT_SMALL_THREAD,
                )
            }
        };

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.

2 participants