Skip to content

Remove unnecessary logic in new_stack_fast #3566

New issue

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

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

Already on GitHub? # to your account

Closed
brson opened this issue Sep 23, 2012 · 3 comments
Closed

Remove unnecessary logic in new_stack_fast #3566

brson opened this issue Sep 23, 2012 · 3 comments
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-cleanup Category: PRs that clean code up or issues documenting cleanup.

Comments

@brson
Copy link
Contributor

brson commented Sep 23, 2012

Currently looks like this:

    // The minimum stack size, in bytes, of a Rust stack, excluding red zone                                       
    size_t min_sz = sched_loop->min_stack_size;                                                                    

    // Try to reuse an existing stack segment                                                                      
    if (stk != NULL && stk->next != NULL) {                                                                        
        size_t next_sz = user_stack_size(stk->next);                                                               
        if (min_sz <= next_sz && requested_sz <= next_sz) {                                                        
            stk = stk->next;                                                                                       
            return;                                                                                                
        }                                                                                                          
    }  

I think that min_sz <= next_sz is an invariant. We should never be allocating a next_sz that is smaller than min_stack_siz. Change it to an assert (that it preferably disabled when RUST_NBEBUG). This saves a number of instructions and makes accessing the sched_loop unnecessary on the fast path.

@catamorphism
Copy link
Contributor

Nominating for milestone 5, production-ready

@graydon
Copy link
Contributor

graydon commented Jun 20, 2013

just a bug, removing milestone/nomination.

@emberian
Copy link
Member

oldrt gone, closing.

bors pushed a commit to rust-lang-ci/rust that referenced this issue May 15, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-cleanup Category: PRs that clean code up or issues documenting cleanup.
Projects
None yet
Development

No branches or pull requests

4 participants