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

refactor buffer copy logic to reduce flash memory usage #1777

Merged
merged 1 commit into from Apr 30, 2020

Conversation

JOE1994
Copy link
Contributor

@JOE1994 JOE1994 commented Apr 21, 2020

Pull Request Overview

Refactored buffer copy logic in capsules/src/process_console.rs to reduce flash memory usage.

Testing Strategy

Used tools/print_tock_memory_usage.py to compare memory usage before/after the change.

  1. Summary of changes in memory usage
    Changes made in this PR results in memory usage reduction of..

    • Kernel (flash) : 80 bytes of memory usage
    • Function groups (flash): 48 bytes of memory usage
  2. Memory usage before change

lonelyjoe@lonelyjoe-desktop:~/workspace/tock/boards/hail$ ../../tools/print_tock_memory_usage.py ../../target/thumbv7em-none-eabi/release/hail.elf
Tock memory usage report for ../../target/thumbv7em-none-eabi/release/hail.elf
Kernel occupies 105368 bytes of flash
  102172        code and constant strings
    3196        variable initializers
Kernel occupies 65532 bytes of RAM
    4096        stack
   58240        uninitialized variables
    3196        initialized variables
   61436        variables total
Applications allocated 49152 bytes of RAM

Variable groups (RAM): 56009 bytes
  capsules::*   2206 bytes
  components::* 17 bytes
  hail::*       50161 bytes
  kernel::*     12 bytes
  sam4l::*      3613 bytes

Embedded data (flash): 15981 bytes

Function groups (flash): 74898 bytes
  capsules::*   29296 bytes
  core::*       14602 bytes
  cortexm4::*   1972 bytes
  cortexm::*    1488 bytes
  hail::*       128 bytes
  kernel::*     18894 bytes
  sam4l::*      8468 bytes
  tock_cells::* 50 bytes
  1. Memory usage after change
AFTER

lonelyjoe@lonelyjoe-desktop:~/workspace/tock/boards/hail$ ../../tools/print_tock_memory_usage.py ../../target/thumbv7em-none-eabi/release/hail.elf
Tock memory usage report for ../../target/thumbv7em-none-eabi/release/hail.elf
Kernel occupies 105288 bytes of flash
  102092        code and constant strings
    3196        variable initializers
Kernel occupies 65532 bytes of RAM
    4096        stack
   58240        uninitialized variables
    3196        initialized variables
   61436        variables total
Applications allocated 49152 bytes of RAM

Variable groups (RAM): 56009 bytes
  capsules::*   2206 bytes
  components::* 17 bytes
  hail::*       50161 bytes
  kernel::*     12 bytes
  sam4l::*      3613 bytes

Embedded data (flash): 15981 bytes

Function groups (flash): 74850 bytes
  capsules::*   29248 bytes
  core::*       14602 bytes
  cortexm4::*   1972 bytes
  cortexm::*    1488 bytes
  hail::*       128 bytes
  kernel::*     18894 bytes
  sam4l::*      8468 bytes
  tock_cells::* 50 bytes

TODO or Help Wanted

I haven't performed performance comparisons before/after the change.
Is there a canonical way to do this in Tock?

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make formatall.

Copy link
Member

@ppannuto ppannuto left a comment

Choose a reason for hiding this comment

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

Wow do I wish that was a transformation the compiler could figure out.

Definitely less readable, IMHO, but the comment addresses that well enough.

@bradjc bradjc merged commit 312ab7f into tock:master Apr 30, 2020
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.

None yet

5 participants