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

Made it so you can specify the old gen heap size. #15259

Merged
merged 6 commits into from Jan 8, 2020

Conversation

gaaclarke
Copy link
Member

@gaaclarke gaaclarke commented Jan 7, 2020

@auto-assign auto-assign bot requested a review from flar January 7, 2020 21:33
@gaaclarke gaaclarke added Work in progress (WIP) Not ready (yet) for review! and removed Work in progress (WIP) Not ready (yet) for review! labels Jan 7, 2020
@@ -111,6 +111,15 @@ static const char* kDartTraceStreamsArgs[] = {
"--timeline_streams=Compiler,Dart,Debugger,Embedder,GC,Isolate,VM,API",
};

static std::string DartOldGenHeapSizeArgs(uint64_t heap_size) {
static const int32_t buffer_size = 100;
Copy link
Member

Choose a reason for hiding this comment

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

Use constexpr (though I believe the compiler will promote this to constexpr anyway)

@cbracken
Copy link
Member

cbracken commented Jan 7, 2020

We'll want to expose this to embedders, but feel free to do that in a separate PR(s). The only requests we've had so far have been for Fuchsia (and likely a customer using the embedder API).

constexpr int32_t buffer_size = 100;
const char* flag = "--old_gen_heap_size=";
char buffer[buffer_size];
int result = snprintf(buffer, buffer_size, "%s%lld", flag, heap_size);
Copy link
Member

Choose a reason for hiding this comment

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

../../flutter/runtime/dart_vm.cc:118:62: error: format specifies type 'long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Werror,-Wformat]
  int result = snprintf(buffer, buffer_size, "%s%lld", flag, heap_size);
                                                ~~~~         ^~~~~~~~~
                                                %lu

Copy link
Member Author

Choose a reason for hiding this comment

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

done

constexpr int32_t buffer_size = 100;
const char* flag = "--old_gen_heap_size=";
char buffer[buffer_size];
int result = snprintf(buffer, buffer_size, "%s%" PRId64, flag, heap_size);
Copy link
Member

Choose a reason for hiding this comment

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

Use std::ostringstream here

Copy link
Member Author

Choose a reason for hiding this comment

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

I used snprintf because my concern was binary size. Is there a reason to use string streams?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really an issue here but snprintf is faster because it works on a fixed size buffer and doesn't have to juggle memory allocations: https://stackoverflow.com/a/445348

Copy link
Member

Choose a reason for hiding this comment

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

IMHO the code will be simpler with reduced risk of buffer overflows. We already use iostreams in many places throughout the engine, and any performance difference will be negligible given that this is a one time operation during startup of the runtime.

Copy link
Member Author

Choose a reason for hiding this comment

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

You can't get an overflow with snprintf and a buffer with the correct size, but switched to sstream to match other code.

@gaaclarke
Copy link
Member Author

We'll want to expose this to embedders, but feel free to do that in a separate PR(s). The only requests we've had so far have been for Fuchsia (and likely a customer using the embedder API).

Done.

@gaaclarke
Copy link
Member Author

Landing with Linux Fuchsia purple: https://ci.chromium.org/p/flutter/builders/try/Linux%20Fuchsia/1525

This is an infra problem.

settings.old_gen_heap_size = 1024;
auto vm = DartVMRef::Create(settings);
// There is no way to introspect on the heap size so we just assert the vm was
// created.
Copy link
Contributor

Choose a reason for hiding this comment

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

You might try to allocate an array larger than the max size and check it produces an OutOfMemory exception.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

LGTM

engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request Jan 8, 2020
flutter/engine@f001ea2...46adf73

git log f001ea2..46adf73 --first-parent --oneline
2020-01-08 30870216+gaaclarke@users.noreply.github.com Made it so you can specify the old gen heap size. (flutter/engine#15259)
2020-01-08 skia-flutter-autoroll@skia.org Roll fuchsia/sdk/core/mac-amd64 from gL-XG... to rTJJV... (flutter/engine#15308)
2020-01-08 xster@google.com Add a deprecation javadoc note to the old FlutterActivity (flutter/engine#15156)
2020-01-08 31859944+LongCatIsLooong@users.noreply.github.com Bump simulator version in IosUnitTests & scenario app in preparation for luci xcode 11 migration (flutter/engine#15154)
2020-01-08 skia-flutter-autoroll@skia.org Roll src/third_party/skia 91e0d7526944..f811fc331a14 (32 commits) (flutter/engine#15306)


If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC garyq@google.com on the revert to ensure that a human
is aware of the problem.

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
bkonyi pushed a commit to flutter/flutter that referenced this pull request Jan 9, 2020
flutter/engine@f001ea2...46adf73

git log f001ea2..46adf73 --first-parent --oneline
2020-01-08 30870216+gaaclarke@users.noreply.github.com Made it so you can specify the old gen heap size. (flutter/engine#15259)
2020-01-08 skia-flutter-autoroll@skia.org Roll fuchsia/sdk/core/mac-amd64 from gL-XG... to rTJJV... (flutter/engine#15308)
2020-01-08 xster@google.com Add a deprecation javadoc note to the old FlutterActivity (flutter/engine#15156)
2020-01-08 31859944+LongCatIsLooong@users.noreply.github.com Bump simulator version in IosUnitTests & scenario app in preparation for luci xcode 11 migration (flutter/engine#15154)
2020-01-08 skia-flutter-autoroll@skia.org Roll src/third_party/skia 91e0d7526944..f811fc331a14 (32 commits) (flutter/engine#15306)


If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC garyq@google.com on the revert to ensure that a human
is aware of the problem.

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 11, 2020
NoamDev pushed a commit to NoamDev/engine that referenced this pull request Feb 27, 2020
NoamDev added a commit to NoamDev/engine that referenced this pull request Feb 27, 2020
filmil pushed a commit to filmil/engine that referenced this pull request Mar 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants