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

Investigate malloc/free invocations #170

Closed
jserv opened this issue Jul 19, 2023 · 1 comment
Closed

Investigate malloc/free invocations #170

jserv opened this issue Jul 19, 2023 · 1 comment
Assignees

Comments

@jserv
Copy link
Contributor

jserv commented Jul 19, 2023

rvsim.c is a minimal RV32I simulator without dynamic memory allocation.
Run:

$ build/rv32emu build/rvsim.elf 

Expected results:

...
00000008: 00b76463 ; bltu a3,a0,8        
0000000c: 00008067 ; jalr x0,ra,0        [branch] x[0] <= 16
pc: 0000004c x8:  00000000 x16: 00000005 x24: 00000000
x1: 0000004c x9:  00000000 x17: 00000004 x25: 00000000
x2: 00000000 x10: 00000054 x18: 00000000 x26: 00000000
x3: 00000000 x11: 00000005 x19: 00000000 x27: 00000000
x4: 00000000 x12: 00000060 x20: 00000000 x28: 00000000
x5: 00000000 x13: 00000068 x21: 00000000 x29: 00000000
x6: 00000000 x14: 00000005 x22: 00000000 x30: 00000000
x7: 00000000 x15: 00000060 x23: 00000000 x31: 00000000

Use uftrace to track the number of malloc invocation:

$ uftrace build/rv32emu build/rvsim.elf | egrep "malloc|calloc" | wc -l

It shows 1813 invocations of malloc and calloc, which should be eliminated for performance consideration.

Related: #94

@jserv
Copy link
Contributor Author

jserv commented Oct 2, 2023

With commit 0031224, the command uftrace build/rv32emu build/rvsim.elf | egrep "malloc|calloc" | wc -l now yields a count of 2, indicating a significant reduction in memory usage.

@jserv jserv closed this as completed Oct 2, 2023
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

No branches or pull requests

2 participants