8000 Stack usage is awful · Issue #640 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content
Stack usage is awful #640
Closed
Closed
@pfalcon

Description

@pfalcon

I told long ago that I want to do basic stack usage info (nothing fancy, just by comparing addresses of stack-alloced vars). I didn't because I suspected that it will be such that the only outcome of that can be desire to drop everything and work on stack usage.

Anyway, I did that now (printed by mem_info() in unix port) and indeed it's huge:

def foo2():
    mem_info()

def foo():
    mem_info()
    foo2()

mem_info()
foo()

mem: total=2151, current=975, peak=1554
stack: 800
GC: total: 128000, used: 1216, free: 126784
 No. of 1-blocks: 24, 2-blocks: 14, max blk sz: 6
mem: total=2151, current=975, peak=1554
stack: 1280
GC: total: 128000, used: 1216, free: 126784
 No. of 1-blocks: 24, 2-blocks: 14, max blk sz: 6
mem: total=2151, current=975, peak=1554
stack: 1760
GC: total: 128000, used: 1216, free: 126784
 No. of 1-blocks: 24, 2-blocks: 14, max blk sz: 6

So, one level of Python function recursion costs 480 bytes of C stack (on x86).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0