Skip to content

Conversation

@liyuqian
Copy link
Contributor

@liyuqian liyuqian commented Dec 9, 2019

The waiting time would give our cleanup more room to finish the job, and
thus make our result more accurate.

See also flutter/engine#14265

The waiting time would give our cleanup more room to finish the job, and
thus to make our result more accurate.

See also flutter/engine#14265
@liyuqian liyuqian added a: tests "flutter test", flutter_test, or one of our tests c: performance Relates to speed or footprint issues (see "perf:" labels) perf: memory Performance issues related to memory labels Dec 9, 2019
@liyuqian liyuqian requested a review from dnfield December 9, 2019 20:23
@fluttergithubbot fluttergithubbot added the c: contributor-productivity Team-specific productivity, code health, technical debt. label Dec 9, 2019
@fluttergithubbot
Copy link
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@liyuqian
Copy link
Contributor Author

liyuqian commented Dec 9, 2019

CC @terrylucas @cobblest : this test currently only captures the memory difference between the start and the end of the app. It would be nice to capture the max memory usage during the middle of the app (#44013), and I believe that there's more to be improved there (e.g., the IO thread should be able to abandon jobs that are no longer relevant).

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

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

LGTM.

@dnfield
Copy link
Contributor

dnfield commented Dec 9, 2019

Agreed on @liyuqian -ideally we'd know average/median memory usage, high and low point.

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
debugPrint('==== MEMORY BENCHMARK ==== $state ====');
debugPrint('This was lifecycle event number $iteration in this instance');
Copy link
Contributor

Choose a reason for hiding this comment

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

fwiw, this was useful debugging information when examining the test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

afaik, this life cycle state is only printed when one try to switch between multiple apps, or go back to the home screen. In this specific memory test, we're not doing any of that so in my test this function ends up never been called.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe this code was copied from another test where it was more useful?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. I copied them from flutter_gallery__back_button_memory test, and later found that the READY message is the only one that I need.

await recordStart();
await device.shellExec('input', <String>['swipe', '0 1500 0 0 50']);
await Future<void>.delayed(const Duration(milliseconds: 10000));
await Future<void>.delayed(const Duration(milliseconds: 15000));
Copy link
Contributor

Choose a reason for hiding this comment

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

rather than waiting an arbitrary time, which is super flaky, can we just wait until the test is known to have finished, somehow?

Copy link
Contributor

Choose a reason for hiding this comment

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

(e.g. watching the logs, like some of the other tests do?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree that waiting for some actual signal would be much better. Although this would rely on some (to-be-added) signals/logs being generated by the engine in the IO thread, so this would require some engine changes first. There's an additional difficulty that we should wait for the last cleanup signal, but it's unclear to me how to determine whether a signal is the final one as the engine could generate arbitrary number of such signals at arbitrary times. CC @dnfield and @chinmaygarde for more thoughts on how to provide a deterministic signal from the engine.

Copy link
Contributor

Choose a reason for hiding this comment

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

can't we just print from the dart code in the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When the Dart code released the image, the engine IO thread and Skia would still hold the graphics memory. The actually release won't happen until a Drain task is executed, which could be delayed by up to 3 seconds, or even more if there are some slow IO thread tasks. The test only makes sense to measure the memory when the last engine IO thread Drain task actually finishes. That's why printing something from the Dart code isn't an option here.

@liyuqian liyuqian deleted the memory_test2 branch December 10, 2019 21:16
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: tests "flutter test", flutter_test, or one of our tests c: contributor-productivity Team-specific productivity, code health, technical debt. c: performance Relates to speed or footprint issues (see "perf:" labels) perf: memory Performance issues related to memory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants