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

nuttxgdb memory commands performance optimization #14916

Merged
merged 10 commits into from
Nov 24, 2024

Conversation

XuNeo
Copy link
Contributor

@XuNeo XuNeo commented Nov 23, 2024

Note: Please adhere to Contributing Guidelines.

Summary

This PR is not ready for review for now. because it depends on previous unmerged PRs.

Optimize the performance of memleak, memdump commands.

Tested on a complex project, results are promising.


Command                 Time cost(s)           Time saving(s)   Peformance Boost
                        Before      After
memleak                 39.494172   22.366415   17.127757       1.8
memdump                 41.872441   26.458386   15.414055       1.6
memdump -a 0x1234       28.116294   1.114119    27.002175       25.2
memdump --no-backtrace    N/A       1.114119
memmap                  7.973809    6.836468    1.137341        1.2

Optimize memdump command to include overhead dump.

Impact

Update this section, where applicable, on how change affects users,
build process, hardware, documentation, security, compatibility, etc.

Testing

Update this section with details on how did you verify the change,
what Host was used for build (OS, CPU, compiler, ..), what Target was
used for verification (arch, board:config, ..), etc. Providing build
and runtime logs from before and after change is highly appreciated.

@github-actions github-actions bot added Area: Tooling Area: Memory Management Memory Management issues Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. labels Nov 23, 2024
Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@acassis
Copy link
Contributor

acassis commented Nov 23, 2024

@XuNeo please include Documentation/ for this new tools/scripts

@XuNeo XuNeo force-pushed the nuttxgdb-memory-optimization branch from 305dffc to 8626b2b Compare November 24, 2024 03:49
Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@XuNeo XuNeo marked this pull request as ready for review November 24, 2024 11:11
@XuNeo XuNeo changed the title WIP: nuttxgdb memory commands performance optimization nuttxgdb memory commands performance optimization Nov 24, 2024
Tested on a complex project, results are promising.

Command                 Time cost(s)           Time saving(s)   Peformance Boost
                        Before      After
memleak                 39.494172   22.366415   17.127757       1.8
memdump                 41.872441   26.458386   15.414055       1.6
memdump -a 0x1234       28.116294   1.114119    27.002175       25.2
memdump --no-backtrace    N/A       1.114119
memmap                  7.973809    6.836468    1.137341        1.2

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
This will make it easier to debug memory corruption when agacent node is corrupted.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
Make the dump_nodes etc more common to use.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
igned-off-by: xuxingliang <xuxingliang@xiaomi.com>
This is useful to exclude memory nodes for mempool.

E.g.

(gdb) mm dump --nob --top 5 --sort size --nop --no-pid -1
  Pool          CNT          PID         Size  Overhead          Seqno            Address Backtrace
     H            1            0     16777264        44             13         0x41a79010
     H            2          160      1536048        44     1129827490         0x41d6aad0
     H            1        45374      1536176        44     1129829080         0x45ef1010
     H            3          141       408440        44         145817         0x43905bf0
     H            7          158       131120        44          32955         0x4308d090
Total 14 blks, 23528696 bytes
(gdb) mm dump --nob --top 5 --sort size --nop
  Pool          CNT          PID         Size  Overhead          Seqno            Address Backtrace
     H            1            0     16777264        44             13         0x41a79010
*    H            6           -1      1048640        44         116954         0x436a0fd0
*    H            5           -1      1048640        44         146821         0x43b24fd0
*    H            3           -1      1048640        44          66161         0x4335bfd0
*    H            3           -1      1048640        44         156337         0x43d3ffd0
Total 18 blks, 16777264 bytes

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
1. The prev free flag should use field size instead of preceding to compare.
2. If not prev-free, then prevnode should be None.
3. Cast type to mm_freenode_s in order to access flink, blink when node is free.
4. Heap itself is also included in first region.

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
@XuNeo XuNeo force-pushed the nuttxgdb-memory-optimization branch from 8626b2b to c6e0e5d Compare November 24, 2024 11:28
Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

It could be disabled at compile time. Use utils.get_task_name to handle it

Signed-off-by: xuxingliang <xuxingliang@xiaomi.com>
@XuNeo XuNeo force-pushed the nuttxgdb-memory-optimization branch from c6e0e5d to c3b9054 Compare November 24, 2024 12:29
Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@xiaoxiang781216 xiaoxiang781216 merged commit 358261a into apache:master Nov 24, 2024
27 checks passed
@XuNeo XuNeo deleted the nuttxgdb-memory-optimization branch November 24, 2024 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Memory Management Memory Management issues Area: Tooling Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants