-
Notifications
You must be signed in to change notification settings - Fork 6k
Started looking for the dart plugin registrant at runtime #31418
Conversation
|
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 on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
@blasten friendly ping |
| } | ||
|
|
||
| Dart_Handle FindDartPluginRegistrantLibrary() { | ||
| // TODO(): Instead of finding this, it could be passed down from the tool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you plan to work on this issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. I have no data to suggest it's worthwhile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you envision passing this from the tool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't thought about it. Maybe we could make it so the library has a unique name so we can look directly for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I'd suggest filing an issue, and including the general idea about how this should be solved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Dart_Handle libraries = Dart_GetLoadedLibraries(); | ||
| intptr_t length = 0; | ||
| Dart_ListLength(libraries, &length); | ||
| for (intptr_t i = 0; i < length; ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this grows with the number of packages, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right. I suspect the order of magnitude will never make this an issue. It depends on Dart's implementation of their API but linearly searching through a couple thousand strings shouldn't be significant. Most of the string comparisons will fail on the first char check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For an internal customer, this resulted in a >300ms regression on startup time on low end Android devices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it more like ~275ms? I might be looking at the wrong thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, it was just under 300ms - a mean change of about 291ms on low end Android. This represented a 17% regression from before this patch. I think we should revert this.
blasten
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
b9c41d2 to
3a28e84
Compare
|
@blasten can you give this another look. I decided to add an engine test. That will make the old code path easier to rip out once the engine PR lands. |
3a28e84 to
6b5c7fe
Compare
| bool didCallRegistrantBeforeEntrypoint = false; | ||
|
|
||
| // Test the Dart plugin registrant. | ||
| @pragma('vm:entry-point') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any difference between this file (or test) and
engine/runtime/fixtures/runtime_test.dart
Lines 164 to 185 in bfb5810
| @pragma('vm:entry-point') | |
| class _PluginRegistrant { | |
| @pragma('vm:entry-point') | |
| static void register() { | |
| if (didCallRegistrantBeforeEntrypoint) { | |
| throw '_registerPlugins is being called twice'; | |
| } | |
| didCallRegistrantBeforeEntrypoint = true; | |
| } | |
| } | |
| @pragma('vm:entry-point') | |
| void mainForPluginRegistrantTest() { | |
| if (didCallRegistrantBeforeEntrypoint) { | |
| passMessage('_PluginRegistrant.register() was called'); | |
| } else { | |
| passMessage('_PluginRegistrant.register() was not called'); | |
| } | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, the path of the file. The other one can be removed once we land the Framework PR.
longer is compiled in the root library.
21f8dbc to
87f0eaa
Compare
* e97c801 Started looking for the dart plugin registrant at runtime (flutter/engine#31418) * 9ebbc6e Standardize the embedder file name. (flutter/engine#31723) * e983ac8 Roll Skia from 1fc0c1c0f8af to 5deac304821b (2 revisions) (flutter/engine#31725) * afd334d added dart plugin registrant test executables to run_tests.py (flutter/engine#31726) * 0ff508b Standardize embedder archive name. (flutter/engine#31693) * 9c1daae Roll Fuchsia Mac SDK from qGsRXn7-D... to RIOZP5nXz... (flutter/engine#31730) * ceec638 Roll Fuchsia Linux SDK from _mwyhkd9H... to 7rB0Yrprs... (flutter/engine#31731) * 54050b4 Roll Skia from 5deac304821b to c3e7a2a00b0a (3 revisions) (flutter/engine#31732) * a5718ab Roll Dart SDK from c3e3126a598b to 34a5563af80d (6 revisions) (flutter/engine#31734)
* e97c801 Started looking for the dart plugin registrant at runtime (flutter/engine#31418) * 9ebbc6e Standardize the embedder file name. (flutter/engine#31723) * e983ac8 Roll Skia from 1fc0c1c0f8af to 5deac304821b (2 revisions) (flutter/engine#31725) * afd334d added dart plugin registrant test executables to run_tests.py (flutter/engine#31726) * 0ff508b Standardize embedder archive name. (flutter/engine#31693) * 9c1daae Roll Fuchsia Mac SDK from qGsRXn7-D... to RIOZP5nXz... (flutter/engine#31730) * ceec638 Roll Fuchsia Linux SDK from _mwyhkd9H... to 7rB0Yrprs... (flutter/engine#31731) * 54050b4 Roll Skia from 5deac304821b to c3e7a2a00b0a (3 revisions) (flutter/engine#31732) * a5718ab Roll Dart SDK from c3e3126a598b to 34a5563af80d (6 revisions) (flutter/engine#31734)
…utter#31418)" This reverts commit e97c801.
|
@alexmarkov we had to revert this because it caused a performance regression (300ms). This PR is related to the You said in dart-lang/sdk#48144 (comment) that we could potentially make this generated code a package instead. If we got a package uri instead of a file uri we could look for it directly. Would that be your recommendation here? It also seems unfortunate that this code take 300ms. It is essentially performing a couple thousand string comparisons. Maybe there is something we could do to speed that up. If we go down the package route, how does one edit the |
|
@gaaclarke I'm not sure what is the best way to deal with generated sources - so consider talking to someone more familiar with source code generation. FWIW here are a few options I can suggest:
|
|
@alexmarkov for option 1, could I compile the program with It appears that's how |
|
@gaaclarke Not sure you can use Dart environment defines for that. They are specified at compile time and used to evaluate |
…time (flutter#31418)" (flutter#32162)" This reverts commit ab6b671.
…1418)" (#32162) (#32267) This reverts commit e97c801. Co-authored-by: gaaclarke <[email protected]>
Previously we'd shadow the main entrypoint which didn't work in release builds. Now we look for the registrant's presence at runtime to execute.
Companion framework PR: flutter/flutter#98046
The test for this is an integration tests that happens in the framework PR.
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.