Skip to content

Measure and report maximum stack usage. #175

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

Merged
merged 2 commits into from
Jul 23, 2017

Conversation

dhalbert
Copy link
Collaborator

@dhalbert dhalbert commented Jul 23, 2017

Adds code to measure the maximum excursion of the stack. Enabled only when doing a DEBUG build: make -DDEBUG=1.

New debug-only module added: ustack. This provides:

ustack.stack_size() - return the maximum size of the stack.
ustack.stack_usage() - return how much stack is currently in use. Same as micropython.stack_use(), but duplicated here for convenience.
ustack.max_stack_usage() - return the maximum excursion of the stack so far since CircuitPython started.

Related change: Debugging modules used to be enabled if if the general cpp flag DEBUG was defined. However, I created a new #define called MICROPY_DEBUG_MODULES so they can be enabled/disabled separately.

Also checked into why NDEBUG makes the code size a bit smaller (per @tannewt's TODO in atmel-samd/Makefile. NDEBUG is the standard way of disabling assert() statements, so apparently that's the reason. Changed comment to reflect that.

(This pull request improves on the previous request #150 and brings it up to date for master.)

dhalbert added 2 commits July 22, 2017 17:04
Add separate cpp flag for enabling modules: MICROPY_DEBUG_MODULES
@tannewt tannewt self-requested a review July 23, 2017 19:26
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Looks really good! Thanks Dan!

@tannewt tannewt merged commit f91493c into adafruit:master Jul 23, 2017
@dhalbert dhalbert deleted the max_stack_use-2 branch July 23, 2017 20:51
romanz pushed a commit to romanz/micropython that referenced this pull request Mar 17, 2019
Adapted from adafruit#175

f91493c Dan Halbert:  Measure and report maximum stack usage. (micropython#175)
@kevinjwalters
Copy link

@dhalbert @tannewt I think the implementation of mp_stack_fill_with_sentinel() disappeared with f1c6cb7 ? It still features in

mp_stack_fill_with_sentinel();

void mp_stack_fill_with_sentinel(void);

Intentional?

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