Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style/gfx/metrics/script crates serialize build #19422

Closed
jdm opened this issue Nov 29, 2017 · 28 comments
Closed

style/gfx/metrics/script crates serialize build #19422

jdm opened this issue Nov 29, 2017 · 28 comments

Comments

@jdm
Copy link
Member

@jdm jdm commented Nov 29, 2017

script depends on metrics, and metrics depends on gfx, and gfx depends on style (script also depends on style). If we move the bits of style that gfx depends upon into style_traits, and possibly the bits of gfx that metrics depends upon into gfx_traits, this should allow more crates to build in parallel.

@nox nox changed the title style/gfx/metrics/script crates serialialize build style/gfx/metrics/script crates serialize build Nov 29, 2017
@tigercosmos
Copy link
Collaborator

@tigercosmos tigercosmos commented Dec 1, 2017

The one need to move it one by one or finish it in one time?

@jdm
Copy link
Member Author

@jdm jdm commented Dec 1, 2017

Moving one by one shouldn't hurt anything.

@tigercosmos
Copy link
Collaborator

@tigercosmos tigercosmos commented Dec 1, 2017

OK! I will work on this.

@tigercosmos
Copy link
Collaborator

@tigercosmos tigercosmos commented Dec 2, 2017

@jdm if some codes in style that gfx depends is also used by other crate(i.g. layout), shall I move it? Or just move codes only depended by gfx?

@tigercosmos
Copy link
Collaborator

@tigercosmos tigercosmos commented Dec 2, 2017

ummm... I think they should all be moved, otherwise gfx still need to wait for style

@jdm
Copy link
Member Author

@jdm jdm commented Dec 2, 2017

Exactly. If it's moved from gfx to gfx_traits, the other crates that depend on the move items should be updated to use gfx_traits.

@tigercosmos
Copy link
Collaborator

@tigercosmos tigercosmos commented Dec 2, 2017

This issue is much harder than I though before. Actually almost everything depend on each other.

For example, If I want to move gfx::display_list, which is used by metrics and also the only one gfx dependency in metrics, since gfx::display_list use gfx::text, I will also need to move gfx::text, and gfx::text use lot of gfx things, which mean if I want to move display_list, I will move almost everything in gfx.

So, in this case, we can make sure moving more something from gfx to gfx_traits is impossible.
In fact, I found style has the same problem. :(

@jdm
Copy link
Member Author

@jdm jdm commented Dec 2, 2017

Try creating a trait that can replace https://dxr.mozilla.org/servo/source/components/metrics/lib.rs#306-315. That trait can live in gfx_traits, and the implementation in gfx.

@tigercosmos
Copy link
Collaborator

@tigercosmos tigercosmos commented Dec 2, 2017

I don't understand. If we move that code to gfx_traits.
The relationship would be metrics -> gfx_traits -> gfx.
I thought crate_traits will be independent with crate. Do I misunderstand?

@jdm
Copy link
Member Author

@jdm jdm commented Dec 2, 2017

No, because metrics would depend on gfx_traits, and gfx would depend on gfx_traits.

@tigercosmos
Copy link
Collaborator

@tigercosmos tigercosmos commented Dec 2, 2017

That code use display_list. But display_list is under gfx? If we move that code to traits, it still need to call gfx?

@jdm
Copy link
Member Author

@jdm jdm commented Dec 2, 2017

The code in metrics is calculating a boolean value using the display list types from gfx. The types do not need to move - we can create a trait in gfx_traits that encapsulates the calculation in a method, and implement the trait on the types in gfx. The code in metrics only needs to refer to the trait.

@KiChjang
Copy link
Member

@KiChjang KiChjang commented Dec 18, 2017

@tigercosmos Is this still being worked on?

@tigercosmos
Copy link
Collaborator

@tigercosmos tigercosmos commented Dec 19, 2017

@KiChjang NO. I can't handle this. I didn't understand how to do.
If someone is interested in this, feel free to take it. :)

@streichgeorg
Copy link
Contributor

@streichgeorg streichgeorg commented Jan 12, 2018

I'd like to take a shot at this then.

@jdm
Copy link
Member Author

@jdm jdm commented Jan 12, 2018

Please do!

@jdm jdm added the C-assigned label Jan 12, 2018
@streichgeorg streichgeorg mentioned this issue Jan 12, 2018
4 of 5 tasks complete
@streichgeorg
Copy link
Contributor

@streichgeorg streichgeorg commented Jan 12, 2018

I opened a pull request for the gfx-metrics part. But style-gfx seems a lot harder because there is non zero amount of metaprogramming in the style crate and I would be really happy about some pointers what's going on there. gfx depends mainly on font_weight and some other font related structs, but I don't really get where they get declared.

@jdm
Copy link
Member Author

@jdm jdm commented Jan 12, 2018

The various mako.rs files under style/properties/ are Python Mako templates that generate Rust code. font_weight is defined in style/properties/longhand/font.mako.rs, and it invokes Python code from style/properties/helpers.mako.rs. However, it may be possible to modify the imports from gfx to directly import style::values::computed::font::FontWeight, for example. If that's the case, then it should be possible to extract those types into style_traits and use pub use style_traits::whatever::FontWeight; where they were originally defined.

bors-servo added a commit that referenced this issue Jan 17, 2018
Decouple metrics and gfx

Added gfx_traits::DisplayList so metrics doesn't depend on the gfx crate for gfx::display_list::DisplayList.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #19422 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because succesful compilation should be enough

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19755)
<!-- Reviewable:end -->
@streichgeorg
Copy link
Contributor

@streichgeorg streichgeorg commented Jan 22, 2018

I'm working on removing the style dependency from gfx, but am currently stuck fighting the rust compiler. The problem is that style::computed_values::font_weight::T has some static methods that gfx needs. But when I create a trait that has static methods it's no longer object safe and cannot be passed around anymore, not even in a Box, as I understand it. Is there a nice solution to this.

@jdm
Copy link
Member Author

@jdm jdm commented Jan 22, 2018

@streichgeorg Could you push your code to a branch so it's easier to understand the problems that you're facing?

@streichgeorg
Copy link
Contributor

@streichgeorg streichgeorg commented Jan 22, 2018

Sure

@streichgeorg
Copy link
Contributor

@streichgeorg streichgeorg commented Jan 22, 2018

The name of the branch is decoupling_style_gfx. I started by moving just font_weight::T.

@jdm
Copy link
Member Author

@jdm jdm commented Jan 23, 2018

Here is what I propose:

  • move the definition of FontWeight and its methods into style_traits
  • add a pub use style_traits::FontWeight; line in components/style/values/computed/font.rs

There should be no need to mess with traits for that change; the code in gfx can use the type defined in style_traits directly, and style will continue to use the same type implicitly by reexporting it with the same name in its old location.

@streichgeorg
Copy link
Contributor

@streichgeorg streichgeorg commented Jan 23, 2018

Oh I see, style_traits isn't really all about traits.
Thank you for the help.

@SimonSapin
Copy link
Member

@SimonSapin SimonSapin commented Jan 23, 2018

(Renaming those *_traits crates might be another easy issue, once we decide what to name them instead :))

@KiChjang
Copy link
Member

@KiChjang KiChjang commented Jan 25, 2018

Reopening since this seems to not have been solved yet.

@KiChjang KiChjang reopened this Jan 25, 2018
@streichgeorg streichgeorg mentioned this issue Feb 2, 2018
4 of 5 tasks complete
@jdm jdm added the C-has open PR label Feb 14, 2018
@jdm jdm removed the E-less easy label Apr 20, 2020
@atouchet
Copy link
Contributor

@atouchet atouchet commented Apr 20, 2020

#19934 was an unfinished PR to address this.

@SimonSapin
Copy link
Member

@SimonSapin SimonSapin commented Apr 21, 2020

the bits of gfx that metrics depends upon into gfx_traits

This was done at some point, meaning that the only intermediate dependency between style and script is now script_layout_interface, which only takes ~6 seconds to compile in release mode on our macOS CI (the slowest):

https://community-tc.services.mozilla.com/tasks/BCyqIQNdTNmcrj7kFW58Ww/runs/0/logs/https%3A%2F%2Fcommunity-tc.services.mozilla.com%2Fapi%2Fqueue%2Fv1%2Ftask%2FBCyqIQNdTNmcrj7kFW58Ww%2Fruns%2F0%2Fartifacts%2Fpublic%2Flogs%2Flive.log#L2006

image

The above is a screenshot of xdot with the mouse hovering style in order to color the edges connected to it. The graph is of script and its recursive path dependencies, generated with the script at #26241.

This feels good enough for me, so closing.

@SimonSapin SimonSapin closed this Apr 21, 2020
SimonSapin added a commit that referenced this issue Apr 21, 2020
I tried `cargo graph` and some of its successors,
but didn’t manage to make them produce what I wanted
(or in some cases make them work at all.)

This Python script reimplements similar functionality
based on parsing the (JSON) output of `cargo metadata`.

Graphviz graphs can become hard to read very quickly as the number of nodes grows.
Servo’s dependency graph is very large, so pruning as much as possible is important.
This only shows `path` dependencies (that have their source in this repo),
and can take a parameter to only show recursive dependencies of a given crate.

See #19422 (comment) for an example.

I find that `xdot` is best for visualization since it is interactive.

This script is not used by anything.
I am making this PR only so that we have it somewhere
in case it becomes useful again at some point.
bors-servo added a commit that referenced this issue Apr 21, 2020
Add a minimal alternative to `cargo graph`

I tried `cargo graph` and some of its successors, but didn’t manage to make them produce what I wanted (or in some cases make them work at all.)

This Python script reimplements similar functionality based on parsing the (JSON) output of `cargo metadata`.

Graphviz graphs can become hard to read very quickly as the number of nodes grows. Servo’s dependency graph is very large, so pruning as much as possible is important. This only shows `path` dependencies (that have their source in this repo), and can take a parameter to only show recursive dependencies of a given crate.

See #19422 (comment) for an example.

I find that `xdot` is best for visualization since it is interactive.

This script is not used by anything. I am making this PR only so that we have it somewhere in case it becomes useful again at some point.
bors-servo added a commit that referenced this issue Apr 21, 2020
Add a minimal alternative to `cargo graph`

I tried `cargo graph` and some of its successors, but didn’t manage to make them produce what I wanted (or in some cases make them work at all.)

This Python script reimplements similar functionality based on parsing the (JSON) output of `cargo metadata`.

Graphviz graphs can become hard to read very quickly as the number of nodes grows. Servo’s dependency graph is very large, so pruning as much as possible is important. This only shows `path` dependencies (that have their source in this repo), and can take a parameter to only show recursive dependencies of a given crate.

See #19422 (comment) for an example.

I find that `xdot` is best for visualization since it is interactive.

This script is not used by anything. I am making this PR only so that we have it somewhere in case it becomes useful again at some point.
nosark added a commit to nosark/servo that referenced this issue Jul 19, 2020
I tried `cargo graph` and some of its successors,
but didn’t manage to make them produce what I wanted
(or in some cases make them work at all.)

This Python script reimplements similar functionality
based on parsing the (JSON) output of `cargo metadata`.

Graphviz graphs can become hard to read very quickly as the number of nodes grows.
Servo’s dependency graph is very large, so pruning as much as possible is important.
This only shows `path` dependencies (that have their source in this repo),
and can take a parameter to only show recursive dependencies of a given crate.

See servo#19422 (comment) for an example.

I find that `xdot` is best for visualization since it is interactive.

This script is not used by anything.
I am making this PR only so that we have it somewhere
in case it becomes useful again at some point.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

6 participants
You can’t perform that action at this time.