这是indexloc提供的服务,不要输入任何密码
Skip to content

Slow performance with deep hierachies #243

@nicoburns

Description

@nicoburns

taffy version

Tested with latest main (e5b721cd225a306635ec3133ef154ea60ac37a39), but I believe this affects all versions of taffy.

Platform

Rust/macOS

What you did

I was interested to see how realistic the benchmarks were. In particular, the "big tree (100_000 nodes)/deep hierarchy" benchmark seemed unacceptably slow clocking in at around 2 seconds relatively fast M1 MacBook. However, 100,000 nodes seemed quite extreme I therefore decided to try a more realistic node count.

In order to determine what a realistic node count might be, I surveyed a few different web apps for both the total number of nodes and the maximum depth. The results were:

  • Total number of nodes was generally between 3000 and 8000
  • Max depth was generally between 14 and 34

I therefore updated the above benchmark to use a lower total node count of 10,000, but a branch factor (number of children per node) of 2 rather than 7. This leads to a depth of 14

What went wrong

In this configuration, taffy took 17.306s to run. Which is of course much slower than the shallower benchmark with 10x more nodes.

Additional information

I suspect this still isn't an entirely realistic benchmark, as it was not possible to set the branching factor low enough to match both the number of nodes and the depths I observed on websites (for example this github page I'm writing in now has a depth of 25 with only ~1300 total nodes), and it's possible that styles such as "width: 100%" are reducing the impact of depth in some cases. Nevertheless, I would expect most real-life layouts to have a depth of greater than 6.

Uses benchmarks from #165

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions