Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] Log Memory.Footprint test results #8170

Merged
merged 2 commits into from
Feb 28, 2017
Merged

Conversation

anandthakker
Copy link
Contributor

@anandthakker anandthakker commented Feb 22, 2017

Even when we're passing this test, it can be very useful to have a log of the memory usage value, so that we can get a sense of the memory impact of new features and also to make sure that it's reasonable when we to increase the thresholds for these checks, when necessary.

Closes #8149 (leaving integration w/ the fancy nightly metrics graph for another day)

@mention-bot
Copy link

@anandthakker, thanks for your PR! By analyzing this pull request, we identified @tmpsantos and @jfirebaugh to be potential reviewers.

@anandthakker anandthakker changed the title Move Memory.Footprint from unit test => benchmark [core] Move Memory.Footprint from unit test => benchmark Feb 22, 2017
Copy link
Contributor

@jfirebaugh jfirebaugh left a comment

Choose a reason for hiding this comment

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

👍 Just one suggestion for output:

Vector: 6.74865e+07 OK
Raster: 2.43709e+07 OK

Can you change these to print in regular notation (or MB units)?

@tmpsantos
Copy link
Contributor

Can we hold on merging this? I would like to review it tomorrow with more time.

Copy link
Contributor

@tmpsantos tmpsantos left a comment

Choose a reason for hiding this comment

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

I don't object to this change but looking carefully I don't see what value we are adding moving it from gtest to gbenchmark.

gbenchmark was designed to see how many times you can run a test in a time frame and I would prefer to keep it this way.

For instance the json output of gbenchmark with this test would be misleading.

Why not keep it on gtest? I think for this particular case it is even more prepared for having a XML generated that we could use to plot a graph:

https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md#logging-additional-information

@@ -4,4 +4,5 @@ namespace mbgl {

int runBenchmark(int argc, char* argv[]);


Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed.

#include <unistd.h>

/*
* Begin getRSS.c
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move this to benchmark/src/mbgl/benchmark/getrss.c? Maybe add the function prototypes to utils.hpp.


namespace mbgl {
namespace benchmark {
bool memoryFootprintBenchmark();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, we don't indent inside the namespace

.travis.yml Outdated
@@ -173,7 +173,8 @@ matrix:
- mapbox_export_mesa_library_path
script:
- make qt-app
- LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so make run-qt-test-Memory.*:*.Load
- LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so make run-qt-test-*.Load
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep the other memory tests.

result.data = it->second;
} else {
auto data = std::make_shared<std::string>(
util::read_file(std::string("test/fixtures/resources/") + path));
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy the test resources used by this test to benchmark/fixtures/.

/** End getRSS.c */


using namespace mbgl;
Copy link
Contributor

Choose a reason for hiding this comment

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

No needed, you are already using namespace mbgl {

std::unordered_map<std::string, std::shared_ptr<std::string>> cache;
};

TEST(Memory, Vector) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not remove this. These (Memory.Vector and Memory.Raster) are the only tests we have that do a full pass rendering inside valgrind looking for memory leaks.

@anandthakker
Copy link
Contributor Author

Thanks for the review @tmpsantos

Why not keep it on gtest? I think for this particular case it is even more prepared for having a XML generated that we could use to plot a graph:

https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md#logging-additional-information

Somehow in my attempts to get gtest to simply log additional info to the screen, I missed this. You're right: if we can use gtest's existing functionality, then I should rework this PR to:

  1. Keep the more portable version of getRSS (it's convenient to be able to at least run the memory test on non-linux box, even if it's not as reliable without jemalloc)
  2. Use gtest's RecordProperty feature to record the memory metrics to XML output
  3. Add a simple travis step that greps (or whatever) for these values from the XML results, so that we can see them in the travis logs. Later, when we have a chance, we can add this to the nightly metrics charts.

@tmpsantos
Copy link
Contributor

Keep the more portable version of getRSS (it's convenient to be able to at least run the memory test on non-linux box, even if it's not as reliable without jemalloc)

👍

Use gtest's RecordProperty feature to record the memory metrics to XML output
Add a simple travis step that greps (or whatever) for these values from the XML results, so that we can see them in the travis logs. Later, when we have a chance, we can add this to the nightly metrics charts.

This would be an amazing follow-up. There was prior work done here for binary size:
#7005

Metrics can be seen here:
https://mapbox.github.io/mapbox-gl-native/metrics/binary-size/

@anandthakker
Copy link
Contributor Author

@tmpsantos updated to output results from gtest as we discussed, and laid the groundwork for reporting / visualizing the benchmark over time in log_memory_benchmarks.cpp

It appears there isn't currently a nightly build for qt, and I think posting for every build would be overkill. Should we add a nightly-release workflow to the qt bitrise setup?

@anandthakker anandthakker changed the title [core] Move Memory.Footprint from unit test => benchmark [core] Log Memory.Footprint test results Feb 27, 2017
@anandthakker anandthakker merged commit 4b81c92 into master Feb 28, 2017
@anandthakker anandthakker deleted the log-memory-usage branch February 28, 2017 22:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants