Skip to content

Dart_GetField is 2ms of each frame in the gallery weather demo #3808

Closed

Description

@Hixie

This trace: #3082 (comment)
...shows that about 2ms of each frame of the weather demo in the gallery consists of calls to Dart_GetField.

Activity

  1. added
    engineflutter/engine related. See also e: labels.
    c: performanceRelates to speed or footprint issues (see "perf:" labels)
    customer: galleryRelating to flutter/gallery repository. Please transfer non-framework issues there.
    on May 9, 2016
  2. added this to the milestone on May 9, 2016
  3. eseidelGoogle commented on May 9, 2016

    @eseidelGoogle
    Contributor

    Most of them are for Paint._value, although there are several other field names represented.

  4. abarth commented on May 9, 2016

    @abarth
    Contributor

    Yeah, I didn't do Paint._value in my previous pass. I can do that one too.

  5. self-assigned this
    on May 9, 2016
  6. eseidelGoogle commented on May 9, 2016

    @eseidelGoogle
    Contributor

    Counts of GetField calls under Paint phase in that trace:
    73 "Paint._value"
    6 "OffsetBase._dy"
    6 "OffsetBase._dx"
    4 "Color._value"
    2 "TransferMode.index"
    2 "Point.y"
    2 "Point.x"

  7. abarth commented on May 9, 2016

    @abarth
    Contributor

    I think the solution here is to record the canvas commands into a ByteData buffer in Dart and then move all the commands into C++ in one operation.

  8. modified the milestones: Gallery App, on May 10, 2016
  9. mraleph commented on May 16, 2016

    @mraleph
    Member

    BTW, I have been discussing with some folks that if Dart had an FFI-centric bindings instead of API-centric bindings then this kind of overhead (like Dart_GetField) would disappear.

    In FFI-centric bindings you will describe marshaling rules on the Dart side instead of having them on the C++-side. Having marshaling rules on Dart side allows us to generate specialized marshaling stubs dynamically leading to a very good performance.

    For example we could allow writing something like this:

    // This ffi.Signature is some sort of description of how arguments are marshaled.
    @ffi.Signature("void foo (struct { double offset._dx, double offset._dy })")
    void foo(OffsetBase offset) native "foo";
    // foo is a C++ method that is invoked directly with appropriate arguments. 
    // it does not need to use Dart API to marshall any data. 

    The hardest part is actually deciding on format for these signature descriptions.

  10. abarth commented on May 16, 2016

    @abarth
    Contributor

    Interesting. I've been experimenting with doing something like that manually by encoding the arguments into a typed array.

  11. abarth commented on May 16, 2016

    @abarth
    Contributor

    https://github.com/flutter/engine/compare/master...abarth:encoded_buffer?expand=1 is an example with encoding into typed arrays. Unfortunately, it didn't seem to be measurably faster.

  12. modified the milestones: , Gallery App on May 23, 2016
  13. abarth commented on Jun 20, 2016

    @abarth
    Contributor

    Canvas no longer calls Dart_GetField.

  14. github-actions commented on Aug 15, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  15. locked as resolved and limited conversation to collaborators on Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

c: performanceRelates to speed or footprint issues (see "perf:" labels)customer: galleryRelating to flutter/gallery repository. Please transfer non-framework issues there.engineflutter/engine related. See also e: labels.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions