32 Commits

Author SHA1 Message Date
liyuqian faa11214c0 Run benchmarks in Cirrus (#13950) 2019-12-02 16:38:03 -08:00
Jason Simmons da0fcf8284 Updates to the engine test runner script (#9934)
* Use separate filters for engine executables and Dart test scripts
* Do not run the benchmarks on Cirrus
2019-07-19 17:00:18 -07:00
Chinmay Garde a59b6a6e38 Convert run_tests to python, allow running on Mac/Windows and allow filters for tests. (#9818)
Sample usage:

To run only the embedder_unittests in the engine with the profile variant, the command would be
```
./flutter/testing/run_tests.py --variant host_profile_unopt --type engine --filter embedder_unittests
``

To run only the geometry in Dart with the debug variant, the command would be
```
./flutter/testing/run_tests.py --variant host_debug_unopt --type dart --filter geometry_test
``

Without any argument, the behavior is identical to `run_tests.sh`.

In a subsequent patch, I will enable running unit-tests on Windows in the tryjobs. The lack of compatibility of the shell script on Windows made it so that we never ran any Windows unit-tests in the tryjobs.
2019-07-15 17:46:36 -07:00
Chinmay Garde ad582b5089 Rework image & texture management to use concurrent message queues. (#9486)
This patch reworks image decompression and collection in the following ways
because of misbehavior in the described edge cases.

The current flow for realizing a texture on the GPU from a blob of compressed
bytes is to first pass it to the IO thread for image decompression and then
upload to the GPU. The handle to the texture on the GPU is then passed back to
the UI thread so that it can be included in subsequent layer trees for
rendering. The GPU contexts on the Render & IO threads are in the same
sharegroup so the texture ends up being visible to the Render Thread context
during rendering. This works fine and does not block the UI thread. All
references to the image are owned on UI thread by Dart objects. When the final
reference to the image is dropped, the texture cannot be collected on the UI
thread (because it has not GPU context). Instead, it must be passed to either
the GPU or IO threads. The GPU thread is usually in the middle of a frame
workload so we redirect the same to the IO thread for eventual collection. While
texture collections are usually (comparatively) fast, texture decompression and
upload are slow (order of magnitude of frame intervals).

For application that end up creating (by not necessarily using) numerous large
textures in straight-line execution, it could be the case that texture
collection tasks are pending on the IO task runner after all the image
decompressions (and upload) are done. Put simply, the collection of the first
image could be waiting for the decompression and upload of the last image in the
queue.

This is exacerbated by two other hacks added to workaround unrelated issues.
* First, creating a codec with a single image frame immediately kicks of
  decompression and upload of that frame image (even if the frame was never
  request from the codec). This hack was added because we wanted to get rid of
  the compressed image allocation ASAP. The expectation was codecs would only be
  created with the sole purpose of getting the decompressed image bytes.
  However, for applications that only create codecs to get image sizes (but
  never actually decompress the same), we would end up replacing the compressed
  image allocation with a larger allocation (device resident no less) for no
  obvious use. This issue is particularly insidious when you consider that the
  codec is usually asked for the native image size first before the frame is
  requested at a smaller size (usually using a new codec with same data but new
  targetsize). This would cause the creation of a whole extra texture (at 1:1)
  when the caller was trying to “optimize” for memory use by requesting a
  texture of a smaller size.
* Second, all image collections we delayed in by the unref queue by 250ms
  because of observations that the calling thread (the UI thread) was being
  descheduled unnecessarily when a task with a timeout of zero was posted from
  the same (recall that a task has to be posted to the IO thread for the
  collection of that texture). 250ms is multiple frame intervals worth of
  potentially unnecessary textures.

The net result of these issues is that we may end up creating textures when all
that the application needs is to ask it’s codec for details about the same (but
not necessarily access its bytes). Texture collection could also be delayed
behind other jobs to decompress the textures on the IO thread. Also, all texture
collections are delayed for an arbitrary amount of time.

These issues cause applications to be susceptible to OOM situations. These
situations manifest in various ways. Host memory exhaustion causes the usual OOM
issues. Device memory exhaustion seems to manifest in different ways on iOS and
Android. On Android, allocation of a new texture seems to be causing an
assertion (in the driver). On iOS, the call hangs (presumably waiting for
another thread to release textures which we won’t do because those tasks are
blocked behind the current task completing).

To address peak memory usage, the following changes have been made:
* Image decompression and upload/collection no longer happen on the same thread.
  All image decompression will now be handled on a workqueue. The number of
  worker threads in this workqueue is equal to the number of processors on the
  device. These threads have a lower priority that either the UI or Render
  threads. These workers are shared between all Flutter applications in the
  process.
* Both the images and their codec now report the correct allocation size to Dart
  for GC purposes. The Dart VM uses this to pick objects for collection. Earlier
  the image allocation was assumed to 32bpp with no mipmapping overhead
  reported. Now, the correct image size is reported and the mipmapping overhead
  is accounted for. Image codec sizes were not reported to the VM earlier and
  now are. Expect “External” VM allocations to be higher than previously
  reported and the numbers in Observatory to line up more closely with actual
  memory usage (device and host).
* Decoding images to a specific size used to decode to 1:1 before performing a
  resize to the correct dimensions before texture upload. This has now been
  reworked so that images are first decompressed to a smaller size supported
  natively by the codec before final resizing to the requested target size. The
  intermediate copy is now smaller and more promptly collected. Resizing also
  happens on the workqueue worker.
* The drain interval of the unref queue is now sub-frame-interval. I am hesitant
  to remove the delay entirely because I have not been able to instrument the
  performance overhead of the same. That is next on my list. But now, multiple
  frame intervals worth of textures no longer stick around.

The following issues have been addressed:
* https://github.com/flutter/flutter/issues/34070 Since this was the first usage
  of the concurrent message loops, the number of idle wakes were determined to
  be too high and this component has been rewritten to be simpler and not use
  the existing task runner and MessageLoopImpl interface.
* Image decoding had no tests. The new `ui_unittests` harness has been added
  that sets up a GPU test harness on the host using SwiftShader. Tests have been
  added for image decompression, upload and resizing.
* The device memory exhaustion in this benchmark has been addressed. That
  benchmark is still not viable for inclusion in any harness however because it
  creates 9 million codecs in straight-line execution. Because these codecs are
  destroyed in the microtask callbacks, these are referenced till those
  callbacks are executed. So now, instead of device memory exhaustion, this will
  lead to (slower) exhaustion of host memory. This is expected and working as
  intended.

This patch only addresses peak memory use and makes collection of unused images
and textures more prompt. It does NOT address memory use by images referenced
strongly by the application or framework.
2019-07-09 14:59:34 -07:00
Chinmay Garde 7483665e6c Re-enable embedder_unittests. (#9482)
This was disabled in https://github.com/flutter/engine/pull/6798 waiting for
a Dart SDK patch to land https://github.com/dart-lang/sdk/commit/e6d3a45b6a98ea36581ac375ec5cdd63dd829004
which has long since been addressed.
2019-06-27 16:49:22 -07:00
Chinmay Garde 7b9f59efd6 Run benchmarks on try jobs. (#9493)
Fixes https://github.com/flutter/flutter/issues/35089.

These runs only ensure that the benchmark harnesses are valid. No information should be collected on the trybots because the environments are not consistent and the builds are not optimized.
2019-06-27 14:11:02 -07:00
Dan Field 2b1f9925e4 new lints (#8849)
Dart lints added:
* Avoid optional new
* Avoid optional const
* Prefer single quotes
* Prefer default assignment `=`
2019-05-07 16:10:21 -07:00
Chinmay Garde c6400e2c25 Merge runtime lifecycle unittests into the base test target. (#8634)
`//flutter/runtime: runtime_lifecycle_unittests` was added because the these assumed that there was no VM already running in the process. Running other tests in the base target would mess up that assumption. Now that all test targets have been updated to make sure the VM instance does not leak, the tests in this target can be merged.

LUCI bots don’t need to be patched as these tests were only ever run on the trybots.
2019-04-18 12:15:45 -07:00
Chinmay Garde f017fe74aa Avoid manually shutting down engine managed isolates. (#8621)
These are now shutdown by the VM and cleanup waits for their shutdown.
2019-04-17 16:11:47 -07:00
stuartmorgan 4266f8583f Add desktop shell unittests to test script (#8600)
Builds the unit test on all platforms, and adds them to the aggregate test script.
2019-04-16 22:37:39 -07:00
Chinmay Garde e356dbca2c Merge flutter/synchronization contents into fml. (#8525)
When flutter/synchronization was first authored, we did not own fml (it was called fxl then). Now we do, so use a single spot for such utilities. The pipeline was meant to be a general purpose utility that was only ever used by the animator (it even has animator specific tracing), so move that to shell instead (where the animator resides).
2019-04-09 19:18:51 -07:00
Chris Bracken 2098398e10 Cleanups to run_tests.sh script (#8337)
Bugfix:
* Use the `pub` from within the built Dart SDK (not whatever's on
  `$PATH`, if anything).

A few minor improvements:
* Allow running from below the src/ buildroot dir, as it's often
  convenient to work from within the flutter/engine git dir.
* Echo test name before running, for slightly better debuggability.
* Minor line-wrapping for readability.
2019-03-27 18:09:08 -07:00
Dan Field 39f7066b69 Test profile and release build and unit tests (#7880)
* Test profile build and unit tests

* update googletest, skip JIT tests on non-debug builds
2019-02-20 20:13:02 -08:00
Dan Field 6179ac6377 fix up analysis for Dart in Engine (#7404)
* fix up analysis for Dart in Engine, particularly for tests
2019-01-11 13:50:58 -08:00
Dan Field 86d34e02dd disable embedder_unittests (#6798) 2018-11-08 11:18:21 -08:00
Chinmay Garde 607c05c93d Run all supported host unit tests on Cirrus. (#6575) 2018-10-17 17:44:11 -07:00
Michael Klimushyn 7ecc879ffd Fix failing test on Cirrus (#6469)
Updates the tests to use the `--use-test-fonts` argument.

Fixes flutter/flutter#22682
2018-10-08 15:47:53 -07:00
Michael Klimushyn ba9b90766b Add run_tests.sh to cirrus (#6441)
This replaces `ci/test.sh` with `run_tests.sh`. `run_tests.sh` includes
`ci/test.sh` and multiple other tests.

Partially addresses flutter/flutter#22682. Temporarily skipped tests
should be fixed and re-enabled in a follow-up commit.
2018-10-05 11:56:13 -07:00
Jason Simmons 1b2a2075a9 Update engine tests for Dart 2 compilation and language changes (#6262) 2018-09-17 09:28:11 -07:00
Jason Simmons a0dff815e1 Update test and license scripts for Dart SDK 2.1.0 (#6254) 2018-09-14 11:29:51 -07:00
liyuqian 5f04e00d7a Remove travis directory (#5935)
This reflects that we no longer uses travis. Scripts are moved to ci folder.
2018-08-06 15:06:49 -07:00
Ben Konyi 8d8d91bfc3 IsolateNameServer reland (#5519)
* Reland "Added IsolateNameServer functionality (#5410)"

This reverts commit c3976b3c71.

* Fixed issue with isolate_name_server_test which caused test to timeout

* Disabled thread_annotations on Android as they aren't supported in the
NDK headers for std::mutex. Readded thread annotations to
IsolateNameServer.
2018-06-13 11:57:10 -07:00
Ben Konyi c3976b3c71 Revert "Added IsolateNameServer functionality (#5410)" (#5516)
This reverts commit 61a2d129cf.
2018-06-12 17:03:13 -07:00
Ben Konyi 61a2d129cf Added IsolateNameServer functionality (#5410)
* Added IsolateNameServer functionality, which allows for the association
of string names with isolate SendPort ids that can be used to establish
inter-isolate communications.
2018-06-12 15:50:48 -07:00
Chinmay Garde 570231b7ab Specify the packages file path when running engine dart tests. (#5005) 2018-04-13 16:17:38 -07:00