781 Commits

Author SHA1 Message Date
Matias Niemelä
f02213a661 build: restore functionality of the micro benchmarks profile_all.js script ()
The 4b81bb5c979382d5f698e0cd729763dd675c226c patch seemingly broke the
`profile_all.js` file due to the file renaming. This patch restores the
functionality of said script.

PR Close 
2019-11-01 17:47:49 +00:00
Pawel Kozlowski
df1bef31a4 perf(ivy): add new benchmark focused on template creation ()
PR Close 
2019-10-31 22:53:29 +00:00
crisbeto
c3e93564d0 perf(ivy): avoid generating selectors array for directives without a selector ()
Now that we've replaced `ngBaseDef` with an abstract directive definition, there are a lot more cases where we generate a directive definition without a selector. These changes make it so that we don't generate the `selectors` array if it's going to be empty.

PR Close 
2019-10-29 12:06:15 -07:00
Miško Hevery
7a280b1a21 test(ivy): clean up class_binding perf tests for readability ()
PR Close 
2019-10-25 15:18:07 -07:00
Igor Minar
4b81bb5c97 build: add ng_benchmark macro to run perf benchmarks ()
this makes running and profiling tests much easier. Example usage:

```
yarn bazel run --define=compile=aot //packages/core/test/render3/perf:noop_change_detection
```

See README.md update for more info.

PS: I considered moving the ng_rollup bundle into the macro but I didn't want to make
  too many changes in this PR. If we find running benchmarks in this way useful, we
  should refactor the build file more, and move the ng_rollup_bundle targets into the
  macro.

PR Close 
2019-10-25 13:13:32 -07:00
crisbeto
14c4b1b205 refactor(ivy): remove ngBaseDef ()
Removes `ngBaseDef` from the compiler and any runtime code that was still referring to it. In the cases where we'd previously generate a base def we now generate a definition for an abstract directive.

PR Close 
2019-10-25 13:11:34 -07:00
Misko Hevery
6323a35468 test(ivy): support className in micro benchmarks ()
The styling algorithm requires that the `RNode` has a `className`
property in order to execute the fast-path. This changes adds the
emulation of this property.

PR Close 
2019-10-25 09:17:52 -07:00
Matias Niemelä
dcdb433b7d perf(ivy): apply [style]/[class] bindings directly to style/className ()
This patch ensures that the `[style]` and `[class]` based bindings
are directly applied to an element's style and className attributes.

This patch optimizes the algorithm so that it...
- Doesn't construct an update an instance of `StylingMapArray` for
  `[style]` and `[class]` bindings
- Doesn't apply `[style]` and `[class]` based entries using
  `classList` and `style` (direct attributes are used instead)
- Doesn't split or iterate over all string-based tokens in a
  string value obtained from a `[class]` binding.

This patch speeds up the following cases:
- `<div [class]>` and `<div class="..." [class]>`
- `<div [style]>` and `<div style="..." [style]>`

The overall speec increase is by over 5x.

PR Close 
2019-10-24 17:42:46 -07:00
Miško Hevery
3f195fefa9 test(ivy): improve microbenchmark reporting progress ()
PR Close 
2019-10-24 17:00:45 -07:00
Miško Hevery
09a2bb839f refactor(ivy): Intruduce LFrame to store global instruction information ()
`LFrame` stores information specifice to the current `LView` As the code
enters and leaves `LView`s we use `enterView()` and `leaveView()`
respectively to build a a stack of `LFrame`s. This allows us to easily
restore the previous `LView` instruction state.

PR Close 
2019-10-24 14:42:15 -07:00
Misko Hevery
b00189bb9a test(core): support running performance benchmarks in browser ()
PR Close 
2019-10-24 14:07:25 -07:00
Misko Hevery
9a5e08f2a7 test(ivy): add styling [class] benchmarks ()
PR Close 
2019-10-24 11:13:32 -07:00
Misko Hevery
a1d7b6bb86 test(ivy): fined tune micro benchmark parameters ()
Decrease `MIN_SAMPLE_DURATION` to make it more likely that we cane fit into single time slice.
Increase `MIN_SAMPLE_COUNT_NO_IMPROVEMENT` to make it more likely to find the best

PR Close 
2019-10-23 16:40:51 -07:00
Misko Hevery
d40ee6a259 perf(ivy): improve styling performance ()
change the existing implementation from using

```
string.split(/\s+/);
```

to a char scan which performers the same thing.

The reason why `split(/\s+/)` is slow is that:
- `/\s+/` allocates new `RegExp` every time this code executes.
- `RegExp` scans are a lot more expensive because they are more powerful.

PR Close 
2019-10-23 16:40:12 -07:00
Miško Hevery
bd89626e2e test(ivy): add instructions for deoptigate ()
PR Close 
2019-10-23 09:56:42 -07:00
Matias Niemelä
f45c43188f fix(ivy): ensure errors are thrown during checkNoChanges for style/class bindings ()
Prior to this fix, all style/class bindings (e.g. `[style]` and
`[class.foo]`) would quietly update a binding value if and when the
current binding value changes during checkNoChanges.

With this patch, all styling instructions will properly check to see
if the value has changed during the second pass of detectChanges()
if checkNoChanges is active.

PR Close 
2019-10-17 16:46:49 -04:00
crisbeto
9d54679e66 test: clean up explicit dynamic query usages ()
Cleans up all the places where we explicitly set `static: false` on queries.

PR Close 
2019-10-17 16:10:10 -04:00
Miško Hevery
4800fa1c08 refactor(core): tweek micro-benchmarks to make them more consistent ()
```
┌────────────────────────────────────┬─────────┬──────┬───────────┬───────────┬───────┐
│              (index)               │  time   │ unit │ base_time │ base_unit │   %   │
├────────────────────────────────────┼─────────┼──────┼───────────┼───────────┼───────┤
│       directive_instantiate        │  2.474  │ 'us' │   2.507   │   'us'    │ -1.32 │
│        element_text_create         │  1.313  │ 'us' │   1.319   │   'us'    │ -0.45 │
│           interpolation            │ 220.17  │ 'us' │  224.217  │   'us'    │ -1.8  │
│             listeners              │  1.988  │ 'us' │   2.021   │   'us'    │ -1.63 │
│ map_based_style_and_class_bindings │ 17.908  │ 'ms' │  18.523   │   'ms'    │ -3.32 │
│       noop_change_detection        │ 24.851  │ 'us' │  24.874   │   'us'    │ -0.09 │
│          property_binding          │ 218.76  │ 'us' │  216.736  │   'us'    │ 0.93  │
│      property_binding_update       │ 443.175 │ 'us' │  447.686  │   'us'    │ -1.01 │
│      style_and_class_bindings      │  1.053  │ 'ms' │   1.069   │   'ms'    │ -1.5  │
│           style_binding            │ 488.154 │ 'us' │  484.092  │   'us'    │ 0.84  │
└────────────────────────────────────┴─────────┴──────┴───────────┴───────────┴───────┘
```

PR Close 
2019-10-17 14:13:16 -04:00
Matias Niemelä
724707c6e4 feat(ivy): improve debugging experience for styles/classes ()
This patch introduces the `printTable()` and `printSources()`
methods to `DebugStylingContext` which can be used via the
`window.ng.getDebugNode` helpers when debugging an application.

PR Close 
2019-10-17 00:35:17 -04:00
Kara Erickson
86104b82b8 refactor(core): rename ngInjectableDef to ɵprov ()
Injectable defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngInjectableDef to "prov" (for "provider", since injector defs
are known as "inj"). This is because property names cannot
be minified by Uglify without turning on property mangling
(which most apps have turned off) and are thus size-sensitive.

PR Close 
2019-10-16 16:36:19 -04:00
Kara Erickson
cda9248b33 refactor(core): rename ngInjectorDef to ɵinj ()
Injector defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngInjectorDef to inj. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

PR Close 
2019-10-16 16:36:19 -04:00
Miško Hevery
d3f3d9b4cb test: Add script which allows running all of the profiling tests and compare results ()
PR Close 
2019-10-16 10:22:30 -04:00
Kara Erickson
fc93dafab1 refactor(core): rename ngModuleDef to ɵmod ()
Module defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngModuleDef to mod. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

PR Close 
2019-10-14 23:08:10 +00:00
Kara Erickson
d62eff7316 refactor(core): rename ngPipeDef to ɵpipe ()
Pipe defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngPipeDef to pipe. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

PR Close 
2019-10-14 23:08:10 +00:00
Kara Erickson
0de2a5e408 refactor(core): rename ngFactoryDef to ɵfac ()
Factory defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngFactoryDef to fac. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

Note that the other "defs" (ngPipeDef, etc) will be
prefixed and shortened in follow-up PRs, in an attempt to
limit how large and conflict-y this change is.

PR Close 
2019-10-14 20:27:25 +00:00
Kara Erickson
1a67d70bf8 refactor(core): rename ngDirectiveDef to ɵdir ()
Directive defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
ngDirectiveDef to dir. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

Note that the other "defs" (ngFactoryDef, etc) will be
prefixed and shortened in follow-up PRs, in an attempt to
limit how large and conflict-y this change is.

PR Close 
2019-10-14 16:20:11 +00:00
Kara Erickson
64fd0d6db9 refactor(core): rename ngComponentDef to ɵcmp ()
Component defs are not considered public API, so the property
that contains them should be prefixed with Angular's marker
for "private" ('ɵ') to discourage apps from relying on def
APIs directly.

This commit adds the prefix and shortens the name from
`ngComponentDef` to `cmp`. This is because property names
cannot be minified by Uglify without turning on property
mangling (which most apps have turned off) and are thus
size-sensitive.

Note that the other "defs" (ngDirectiveDef, etc) will be
prefixed and shortened in follow-up PRs, in an attempt to
limit how large and conflict-y this change is.

PR Close 
2019-10-11 15:45:22 -07:00
Matias Niemelä
b2decf0266 perf(ivy): speed up bindings when no directives are present ()
Prior to this fix, whenever a style or class binding is present, the
binding application process would require an instance of `TStylingContext`
to be built regardless of whether or not any binding resolution is needed
(just so that it knows whether or not there are any collisions).
This check is, however, unnecessary because if (and only if) there
are directives present on the element then are collisions possible.

This patch removes the need for style/class bindings to register
themselves on to a `TStylingContext` if there are no directives and
present on an element. This means that all map and prop-based
style/class bindings are applied as soon as bindings are updated on
an element.

PR Close 
2019-10-10 13:57:24 -07:00
Pawel Kozlowski
22d4efbed1 perf(ivy): introduce micro-benchmark for directive instantiation ()
PR Close 
2019-10-10 13:56:52 -07:00
crisbeto
305f3686c3 build: fix compilation error in benchmark ()
A PR that updates one of the benchmarks and another one that changes the signature for `elementStart` got in around the same time which is causing a compilation error. These changes fix the error.

PR Close 
2019-10-09 13:40:10 -07:00
crisbeto
d5b87d32b0 perf(ivy): move attributes array into component def ()
Currently Ivy stores the element attributes into an array above the component def and passes it into the relevant instructions, however the problem is that upon minification the array will get a unique name which won't compress very well. These changes move the attributes array into the component def and pass in the index into the instructions instead.

Before:
```
const _c0 = ['foo', 'bar'];

SomeComp.ngComponentDef = defineComponent({
  template: function() {
    element(0, 'div', _c0);
  }
});
```

After:
```
SomeComp.ngComponentDef = defineComponent({
  consts: [['foo', 'bar']],
  template: function() {
    element(0, 'div', 0);
  }
});
```

A couple of cases that this PR doesn't handle:
* Template references are still in a separate array.
* i18n attributes are still in a separate array.

PR Close 
2019-10-09 13:16:55 -07:00
Pawel Kozlowski
affae99b22 perf(ivy): add static attributes to the element_text_create benchmark ()
PR Close 
2019-10-08 13:02:11 -07:00
Pawel Kozlowski
8593d0d52e perf(ivy): increase number of created views in the element_text_create benchmark ()
PR Close 
2019-10-04 11:44:57 -07:00
Matias Niemelä
e668d7971d revert: feat(ivy): improve debugging experience for styles/classes () ()
This reverts commit 32f4544f34594e16a17c24e7f3eba3dbec734900.

PR Close 
2019-09-24 16:57:58 -07:00
Matias Niemelä
32f4544f34 feat(ivy): improve debugging experience for styles/classes ()
This patch introduces the `printTable()` and `printSources()`
methods to `DebugStylingContext` which can be used via the
`window.ng.getDebugNode` helpers when debugging an application.

PR Close 
2019-09-24 10:37:42 -07:00
Matias Niemelä
0450f39625 refactor(ivy): move all styling util code into utils/styling_utils.ts ()
PR Close 
2019-09-18 15:06:39 -07:00
Matias Niemelä
ec0aa88f4e refactor(ivy): move styling/instructions.ts to instructions/styling.ts ()
PR Close 
2019-09-18 15:06:39 -07:00
Matias Niemelä
f88f717094 refactor(ivy): remame styling_next directory to styling ()
PR Close 
2019-09-18 15:06:39 -07:00
Matias Niemelä
4f41473048 refactor(ivy): remove styling state storage and introduce direct style writing ()
This patch is a final major refactor in styling Angular.

This PR includes three main fixes:

All temporary state taht is persisted between template style/class application
and style/class application in host bindings is now removed.
Removes the styling() and stylingApply() instructions.
Introduces a "direct apply" mode that is used apply prop-based
style/class in the event that there are no map-based bindings as
well as property collisions.

PR Close 

PR Close 
2019-09-16 14:12:48 -07:00
Pawel Kozlowski
1748aeb9c8 perf(ivy): convert all node-based benchmark to use a testing harness ()
PR Close 
2019-09-16 09:31:15 -07:00
Misko Hevery
5a830c49cf refactor(ivy): improve micro-benchmark profiling ()
PR Close 
2019-09-12 13:06:38 -07:00
cexbrayat
88c28ce208 refactor(ivy): migrate debug spec from render3 ()
Migrate the remaining `render3/debug_spec.ts` to `acceptance`

PR Close 
2019-09-12 11:35:49 -07:00
cexbrayat
e013aee636 refactor(ivy): migrate export spec from render3 ()
The remaining test was using JS blocks and was already tested with `ngIf` in the existing acceptance test.

PR Close 
2019-09-12 11:33:03 -07:00
Pawel Kozlowski
024765b86a perf(ivy): introduce benchmark for listeners registration ()
PR Close 
2019-09-12 10:27:44 -07:00
Pawel Kozlowski
ea378a993a perf(ivy): binding update benchmark ()
PR Close 
2019-09-12 06:30:08 -04:00
Matias Niemelä
53dbff66d7 revert: refactor(ivy): remove styling state storage and introduce direct style writing ()
This reverts commit 15aeab16207fd6491e296db02501a14f92ff8e97.
2019-09-11 15:24:10 -07:00
Matias Niemelä
15aeab1620 refactor(ivy): remove styling state storage and introduce direct style writing () ()
This patch is a final major refactor in styling Angular.

This PR includes three main fixes:

All temporary state taht is persisted between template style/class application
and style/class application in host bindings is now removed.
Removes the styling() and stylingApply() instructions.
Introduces a "direct apply" mode that is used apply prop-based
style/class in the event that there are no map-based bindings as
well as property collisions.

PR Close 

PR Close 
2019-09-11 16:27:10 -04:00
Matias Niemelä
c84c27f7f4 revert: refactor(ivy): remove styling state storage and introduce direct style writing () 2019-09-10 18:08:05 -04:00
Matias Niemelä
3b37469735 refactor(ivy): remove styling state storage and introduce direct style writing ()
This patch is a final major refactor in styling Angular.

This PR includes three main fixes:

All temporary state taht is persisted between template style/class application
and style/class application in host bindings is now removed.
Removes the styling() and stylingApply() instructions.
Introduces a "direct apply" mode that is used apply prop-based
style/class in the event that there are no map-based bindings as
well as property collisions.

PR Close 
2019-09-10 15:54:58 -04:00
cexbrayat
f00bb85b58 refactor(ivy): migrate content spec from render3 ()
Migrate the remaining `render3/content_spec.ts` to `acceptance` (some JS block ones were already migrated with `ngIf`).

PR Close 
2019-09-10 13:03:16 -04:00