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

Added simple stats tracking memory usage #241

Merged
merged 7 commits into from
Aug 28, 2020
Merged

Conversation

mjp41
Copy link
Member

@mjp41 mjp41 commented Aug 26, 2020

These statistics can be maintained with effectively zero cost to
realistic applications. They do not track the precise amount of
memory used, but are an over-approximation.

These statistics can be maintained with effectively zero cost to
realistic applications.  They do not track the precise amount of
memory used, but are an over-approximation.
@mjp41
Copy link
Member Author

mjp41 commented Aug 26, 2020

This is not quite finished as the API is not surfaced properly. After suggestions for what to do.

  • Expose a struct, and return that
  • Expose a struct, and fill in a reference to that
  • Two function one to return peak, and one to return current usage

The C++ code just returns a pair, but I guess we want a C function for broader use.

@mjp41
Copy link
Member Author

mjp41 commented Aug 26, 2020

Addresses #240

@mjp41
Copy link
Member Author

mjp41 commented Aug 26, 2020

Output from the new unit test:

> Debug\func-memory_usage-1.exe
Memory Usages Changed to (1130560, 1130560)
Memory Usages Changed to (2179136, 2179136)
Memory Usages Changed to (3227712, 3227712)
Memory Usages Changed to (4276288, 4276288)
Memory Usages Changed to (5324864, 5324864)
Init complete!
Memory Usages Changed to (4276288, 5324864)
Phase 0 remove complete!
Memory Usages Changed to (5324864, 5324864)
Memory Usages Changed to (6373440, 6373440)
Phase 0 add complete!
Memory Usages Changed to (5324864, 6373440)
Phase 1 remove complete!
Memory Usages Changed to (6373440, 6373440)
Memory Usages Changed to (7422016, 7422016)
Phase 1 add complete!
Memory Usages Changed to (6373440, 7422016)
Phase 2 remove complete!
Memory Usages Changed to (7422016, 7422016)
Memory Usages Changed to (8470592, 8470592)
Phase 2 add complete!
Memory Usages Changed to (7422016, 8470592)
Phase 3 remove complete!
Memory Usages Changed to (8470592, 8470592)
Memory Usages Changed to (9519168, 9519168)
Phase 3 add complete!
Memory Usages Changed to (8470592, 9519168)
Phase 4 remove complete!
Memory Usages Changed to (9519168, 9519168)
Memory Usages Changed to (10567744, 10567744)
Phase 4 add complete!
Memory Usages Changed to (9519168, 10567744)
Phase 5 remove complete!
Memory Usages Changed to (10567744, 10567744)
Memory Usages Changed to (11616320, 11616320)
Phase 5 add complete!
Memory Usages Changed to (10567744, 11616320)
Phase 6 remove complete!
Memory Usages Changed to (11616320, 11616320)
Memory Usages Changed to (12664896, 12664896)
Phase 6 add complete!
Memory Usages Changed to (11616320, 12664896)
Phase 7 remove complete!
Memory Usages Changed to (12664896, 12664896)
Memory Usages Changed to (13713472, 13713472)
Phase 7 add complete!
Memory Usages Changed to (12664896, 13713472)
Phase 8 remove complete!
Memory Usages Changed to (13713472, 13713472)
Memory Usages Changed to (14762048, 14762048)
Phase 8 add complete!
Memory Usages Changed to (13713472, 14762048)
Phase 9 remove complete!
Memory Usages Changed to (14762048, 14762048)
Memory Usages Changed to (15810624, 15810624)
Phase 9 add complete!
Memory Usages Changed to (14762048, 15810624)
Memory Usages Changed to (13713472, 15810624)
Phase 0 remove complete!
Memory Usages Changed to (14762048, 15810624)
Phase 0 add complete!
Memory Usages Changed to (13713472, 15810624)
Memory Usages Changed to (12664896, 15810624)
Phase 1 remove complete!
Memory Usages Changed to (13713472, 15810624)
Phase 1 add complete!
Memory Usages Changed to (12664896, 15810624)
Memory Usages Changed to (11616320, 15810624)
Phase 2 remove complete!
Memory Usages Changed to (12664896, 15810624)
Phase 2 add complete!
Memory Usages Changed to (11616320, 15810624)
Memory Usages Changed to (10567744, 15810624)
Phase 3 remove complete!
Memory Usages Changed to (11616320, 15810624)
Phase 3 add complete!
Memory Usages Changed to (10567744, 15810624)
Memory Usages Changed to (9519168, 15810624)
Phase 4 remove complete!
Memory Usages Changed to (10567744, 15810624)
Phase 4 add complete!
Memory Usages Changed to (9519168, 15810624)
Memory Usages Changed to (8470592, 15810624)
Phase 5 remove complete!
Memory Usages Changed to (9519168, 15810624)
Phase 5 add complete!
Memory Usages Changed to (8470592, 15810624)
Memory Usages Changed to (7422016, 15810624)
Phase 6 remove complete!
Memory Usages Changed to (8470592, 15810624)
Phase 6 add complete!
Memory Usages Changed to (7422016, 15810624)
Memory Usages Changed to (6373440, 15810624)
Phase 7 remove complete!
Memory Usages Changed to (7422016, 15810624)
Phase 7 add complete!
Memory Usages Changed to (6373440, 15810624)
Memory Usages Changed to (5324864, 15810624)
Phase 8 remove complete!
Memory Usages Changed to (6373440, 15810624)
Phase 8 add complete!
Memory Usages Changed to (5324864, 15810624)
Memory Usages Changed to (4276288, 15810624)
Phase 9 remove complete!
Memory Usages Changed to (5324864, 15810624)
Phase 9 add complete!
Memory Usages Changed to (4276288, 15810624)
Memory Usages Changed to (3227712, 15810624)
Memory Usages Changed to (2179136, 15810624)
Teardown complete!

@mjp41 mjp41 marked this pull request as ready for review August 27, 2020 12:01
@mjp41
Copy link
Member Author

mjp41 commented Aug 27, 2020

I have incorporated your (@davidchisnall, @achamayou ) comments from #240 as best I can. Please check you feel this is a reasonable interpretation of your constraints and suggestions.

@achamayou
Copy link
Member

That looks good to me, I think it meets both the requirements of the OE memory tests and those of users deploying Open Enclave-based services who want to monitor their memory usage.

@mjp41 mjp41 merged commit 77ebff6 into microsoft:master Aug 28, 2020
@mjp41 mjp41 deleted the memory_usage branch August 28, 2020 13:03
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.

2 participants