Commit Graph

13 Commits

Author SHA1 Message Date
Andres Suarez
5050226cb0 Ignore project node_modules
Reviewed By: pvdz

Differential Revision: D9196154

fbshipit-source-id: f285824d1ca4d825ae9808a6757b82b96debf849
2018-08-07 18:25:02 -07:00
Caleb Meredith
37d692480b Optimize ReactEquivalenceSet (#2243)
Summary:
I generated the following program (now added to test cases) and while I would expect its evaluation in Prepack to terminate reasonably quickly, I did not see the program terminate after five minutes of execution:

https://gist.github.com/calebmer/2bf1d84a5b7849fa732bce69811df10b

After this change that same program’s Prepack evaluation terminates in about two seconds. This change also saves about 2.8s on the evaluation of our internal bundle which is about 3% of the total time.

What was happening? Why did my program fail to terminate execution in five minutes? Why was the internal bundle relatively ok compared to my extreme case?

In my program, I would [expect the component `Mu`](https://gist.github.com/calebmer/2bf1d84a5b7849fa732bce69811df10b#file-program-js-L289-L291) to be inlined about 60 times. Which means there should only be about 60 calls to `ReactElementSet#add` for each of `Mu`’s `div`s. However, after some basic instrumentation I observed way over ten thousand visits to these React elements.

This pair of method calls happens a couple times in `ReactEquivalenceSet` and friends.

5f7256f17e/src/react/ReactEquivalenceSet.js (L233-L234)

Both `getEquivalentPropertyValue`…

5f7256f17e/src/react/ReactEquivalenceSet.js (L255)

…and `getValue`…

5f7256f17e/src/react/ReactEquivalenceSet.js (L104)

…end up calling `ReactElementSet#add` with the same React element. Then `ReactElementSet#add` ends up recursing into children. So the root element is added 2 times, so the root’s children are added 4 times each, so each child of those elements are added 8 times each, and so on. So if a leaf element is `n` deep in the tree it will be added `2^n` times. The most nested `Mu` child was 9 elements deep. `Mu` appeared 60 times at many levels of nesting.

I’m not entirely sure why my generated case was so much worse then our internal bundle. My two best guesses are: lots of repeated components or deeper nesting?

My fix was to move the `getValue` call into `getEquivalentPropertyValue`. This way if `getEquivalentPropertyValue` already finds an equivalent value we can short-circuit and not run `getValue` which will perform the same operation.
Pull Request resolved: https://github.com/facebook/prepack/pull/2243

Reviewed By: trueadm

Differential Revision: D8811463

Pulled By: calebmer

fbshipit-source-id: 4f30a75e96c6592456f5b21ee9c2ee3e40b56d81
2018-07-13 13:40:00 -07:00
Sapan Bhatia
2b9cd062fb Ignore .idea folder used by IntelliJ IDE
Summary:
Resolves #2046
Closes https://github.com/facebook/prepack/pull/2047

Differential Revision: D8180576

Pulled By: sb98052

fbshipit-source-id: d52fff4e4c43cbd5c86bb1ab650588cbf09e33ec
2018-05-28 15:22:30 -07:00
Dan Abramov
ce6b55916c Add React-related internal regression test to Prepack
Summary:
This adds a React-specific internal test for Prepack to fbsource. It's meant to be land-blocking.

I checked in a manually edited bundle that has no dependencies except `react` and `react-dom` (so it's not too difficult to maintain). I also checked in a snapshot test for what it should render.

The test step consists of running the Jest test (to verify it works *before* Prepack), then using the existing `debug-fb-www` command to produce a bundle, and finally running the same Jest test again.

Currently this only checks the initialization path. When render path serializer bugs are fixed, we can run the same bundle in the render mode as well (and catch further regressions).

Reviewed By: NTillmann

Differential Revision: D7675812

fbshipit-source-id: 99fe3bd700ae3557ee6245f1e8e1e835399625b5
2018-04-23 09:09:00 -07:00
Dominic Gannaway
e122a9f613 Correctly ignore fb-www directory
Summary:
Release notes: none
Closes https://github.com/facebook/prepack/pull/1494

Differential Revision: D7067115

Pulled By: trueadm

fbshipit-source-id: 2f345df6c89e0c33921516c6de00d36e6646808f
2018-02-23 06:46:41 -08:00
Dominic Gannaway
4cd40e4099 Add the react fb-www testing script
Summary:
Release notes: none

Internal testing script for FB www.
Closes https://github.com/facebook/prepack/pull/1492

Differential Revision: D7063756

Pulled By: trueadm

fbshipit-source-id: ef9b36b36f48095ce1a521b0c1cfb617f6702c22
2018-02-22 18:01:53 -08:00
James Nolan
d9dc4d2fd1 Website publication script should remove its temporary directories
Summary:
The [website publication script](https://github.com/facebook/prepack/blob/master/scripts/publish-gh-pages.sh) creates a temporary directory (`build`) to fetch fresh copies of the `master` and `gh-pages` branches.

This temporary directory is not removed and causes `flow` to check it when running `yarn flow`, causing many errors.

To address this issue, this PR:
- Changes the publication script to clean up temporary directories at the end of its execution
- Renames the temporary directory name from `build` to `tmp_website_build` to make it clearer that it can be safely removed, should the script fail to remove it
- Changes `.gitignore` and `.flowconfig` to ignore the temporary directory, should the script fail to remove it

Thanks to hermanventer for reporting the issue
Closes https://github.com/facebook/prepack/pull/1302

Differential Revision: D6648852

Pulled By: j-nolan

fbshipit-source-id: 099963bf6907ff7e69301acafcfb3aeedfbb5b20
2018-01-01 14:27:47 -08:00
Herman Venter
db79b830ca Simplify path conditions
Summary:
Break up, simplify and refine path conditions. Also special case the property values obtained from joined objects to use the object's join condition, which is more likely to match the a path condition than the artificial "ob === ob1 ? ob1.prop : ob2.prop" that arises from the general case.

Finally, beef up the implementation of implies, to handle more complicated path conditions by breaking up && and || conditions.
Closes https://github.com/facebook/prepack/pull/970

Differential Revision: D5857033

Pulled By: hermanventer

fbshipit-source-id: 5436d251378decf6de549a3d70e9605664d569e5
2017-09-20 15:18:49 -07:00
Herman Venter
d182dcda70 Allow more than one input file for Prepack
Summary:
We usually need at least two files: 1) the environmental model and 2) the bundle to be Prepacked.
In general, there is no good reason to not allow as many files as the caller wants.

To make this not be a breaking chance, I've added a new API for this: prepackSources.

Further complications result from working around a bug in Babel and not increasing the module cycle length for Flow.
Closes https://github.com/facebook/prepack/pull/776

Differential Revision: D5366190

Pulled By: hermanventer

fbshipit-source-id: 74595b1b60e8e8a6d24cb974b5be10210d745266
2017-07-03 15:08:01 -07:00
Herman Venter
5ab094db60 More error messages for binary ops
Summary:
Add message for < > >= <= != ==

Also run more tests with code coverage.
Closes https://github.com/facebook/prepack/pull/728

Differential Revision: D5280091

Pulled By: hermanventer

fbshipit-source-id: b6e96451940cecde4bd8e494b4fe55a93c78e984
2017-06-19 17:09:05 -07:00
Sebastian Markbåge
db10fc86f1 Extract scripts from npm package (#463)
This moves things around in a more common idiomatic folder structure / naming convention. This extracts the scripts that are only used to test the library from the source of the library itself.

/src/scripts -> /scripts

This is no longer part of the build process. Therefore we use babel-node to run the files as needed. The exception is test-runner that is just ran in plain node so that it works with the coverage reports.

The lib folder now includes only and all the library files required to use the package and no longer test runners.

Because of that I moved all the dependencies that were related only to our test scripts and website build to devDependencies. That way we minimize the required dependencies to use Prepack downstream as an npm package.

Then I configured the package.json to only list lib/ and bin/ folders as part of the package. This lets `npm publish` ignore all other files so that people installing the package don't need to include all our testing code.

I added files to bin/ and package.json which is a convention to make this package installable and usable as a command-line tool.

Renamed run_util -> prepack-cli and repl -> repl-cli to separate these from library variants.

The coverage reports now get created in the root instead of lib folder so that they don't get included in the build.

I bumped the version number to one minor above what is already on npm since we can't publish earlier than that.
2017-04-26 12:26:18 -07:00
Eli White
6a30cdb992 Create a webpack bundle entry point (#364) 2017-04-06 18:52:15 -07:00
Sebastian Markbage
8a1d196255 Initial commit 2017-03-28 20:52:41 -07:00