Skip to content

Separate interning text run #3369

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

Merged
merged 10 commits into from
Dec 6, 2018
Merged

Conversation

djg
Copy link
Contributor

@djg djg commented Nov 29, 2018

First part of separating Primitives into separate interned data.


This change is Reviewable

@djg djg force-pushed the separate_interning_text_run branch from 6b3c530 to 823a663 Compare November 29, 2018 05:07
@gw3583
Copy link
Contributor

gw3583 commented Nov 29, 2018

Looks like there is a reftest failure on CI:

REFTEST TEST-UNEXPECTED-FAIL | reftests\text\shadow.yaml == reftests\text\shadow-ref.yaml | image comparison, max difference: 131, number of differing pixels: 6425

Any chance you could do a talos run before review, just to give an idea what effect it has on dl_mutate (even just to make sure it doesn't regress, for now, since we probably won't get big wins from this initial work)?

@djg
Copy link
Contributor Author

djg commented Nov 29, 2018

Here is the try run with talos results. I see some small improvement and regression which is curious. https://treeherder.mozilla.org/#/jobs?repo=try&revision=752295ab260070f973c22dcb167cd2bef18e48bd

Copy link
Contributor

@gw3583 gw3583 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 6 of 12 files at r1.
Reviewable status: 6 of 12 files reviewed, 2 unresolved discussions (waiting on @djg)


webrender/src/clip.rs, line 101 at r1 (raw file):

#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct ClipUidMarker;
pub type ClipUid = intern::ItemUid<ClipUidMarker>;

This would become simpler if we use a global uid type (mentioned below).


webrender/src/intern.rs, line 76 at r1 (raw file):

/// Implement for a marker struct to associate the type of Uid marker to use
/// with `intern::Handle<..>`
pub trait UidMarker: Copy + Clone {

Having the item uids require this trait and phantom marker feels a bit overengineered to me. How about we just share one uid concrete type among all interners, and don't make them generic. That might aid in debugging too, since a uid is globally unique and would never overlap with a uid from a different interner type.

@gw3583
Copy link
Contributor

gw3583 commented Nov 29, 2018

(partial review only so far, will work through this today).

@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #3368) made this pull request unmergeable. Please resolve the merge conflicts.

@djg
Copy link
Contributor Author

djg commented Nov 30, 2018

(partial review only so far, will work through this today).

Thanks @gw3583

@djg djg force-pushed the separate_interning_text_run branch from 823a663 to 6497007 Compare November 30, 2018 03:08
Copy link
Contributor Author

@djg djg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 2 of 12 files reviewed, 2 unresolved discussions (waiting on @gw3583)


webrender/src/clip.rs, line 101 at r1 (raw file):

Previously, gw3583 (Glenn Watson) wrote…

This would become simpler if we use a global uid type (mentioned below).

Done.


webrender/src/intern.rs, line 76 at r1 (raw file):

Previously, gw3583 (Glenn Watson) wrote…

Having the item uids require this trait and phantom marker feels a bit overengineered to me. How about we just share one uid concrete type among all interners, and don't make them generic. That might aid in debugging too, since a uid is globally unique and would never overlap with a uid from a different interner type.

Done.

Copy link
Contributor

@gw3583 gw3583 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 4 of 8 files at r2.
Reviewable status: 6 of 12 files reviewed, 2 unresolved discussions (waiting on @gw3583)

Copy link
Contributor

@gw3583 gw3583 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 12 files at r1, 1 of 8 files at r2.
Reviewable status: 8 of 12 files reviewed, 8 unresolved discussions (waiting on @gw3583 and @djg)


webrender/src/display_list_flattener.rs, line 1233 at r2 (raw file):

            );

            //cur_instance.kind = PrimitiveInstanceKind::Picture { pic_index: current_pic_index };

Why is this change needed?


webrender/src/display_list_flattener.rs, line 1264 at r2 (raw file):

            current_pic_index = filter_pic_index;
            //cur_instance.kind = PrimitiveInstanceKind::Picture { pic_index: current_pic_index };

same


webrender/src/display_list_flattener.rs, line 1302 at r2 (raw file):

            current_pic_index = blend_pic_index;
            // cur_instance.kind = PrimitiveInstanceKind::Picture { pic_index: blend_pic_index };
            match cur_instance.kind {

same


webrender/src/picture.rs, line 573 at r2 (raw file):

        );

        let prim_rect = match prim_instance.kind {

This is not quite right for Pictures (their rect is built dynamically), but this wasn't handled correctly previously anyway - I've got a fix for it in my local branch.


webrender/src/picture.rs, line 1253 at r2 (raw file):

            };

            let prim_data = match prim_instance.kind {

Maybe make this a helper method on FrameResources? Seems like it'll be used in a few places.


webrender/src/scene_builder.rs, line 173 at r2 (raw file):

}

// Access to `DocumentResources` interners by `Internable`

What is this trait needed for?

Copy link
Contributor

@gw3583 gw3583 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 12 files at r1, 3 of 8 files at r2.
Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @gw3583 and @djg)


webrender/src/display_list_flattener.rs, line 2236 at r2 (raw file):

}

pub trait AsInstanceKind<H> {

Is there a reason to have these as separate traits rather than a "Primitive" trait or similar?


webrender/src/prim_store/text_run.rs, line 29 at r2 (raw file):

#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub struct TextRunKey {
    pub is_backface_visible: bool,

It's probably worth having a set of "common" structs that are embedded within each key / template etc for the data that is shared between all the different types?


webrender/src/prim_store/text_run.rs, line 80 at r2 (raw file):

#[cfg_attr(feature = "replay", derive(Deserialize))]
pub struct TextRunTemplate {
    pub is_backface_visible: bool,

Same here for common data.

Copy link
Contributor Author

@djg djg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @gw3583 and @djg)


webrender/src/display_list_flattener.rs, line 1233 at r2 (raw file):

Previously, gw3583 (Glenn Watson) wrote…

Why is this change needed?

Because PrimitiveInstanceKind:Picture now contains a data_handle. data_handle is Copy so I might try adding it the Picture { ... } here, instead of updating pic_index in-place.

Copy link
Contributor Author

@djg djg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 11 unresolved discussions (waiting on @gw3583)


webrender/src/display_list_flattener.rs, line 2236 at r2 (raw file):

Previously, gw3583 (Glenn Watson) wrote…

Is there a reason to have these as separate traits rather than a "Primitive" trait or similar?

Because there implemented on different types. I can move BuildKey into the the Internable trait as is it related to generating the key for interning. AsInstanceKind is used for getting a PrimitiveInstanceKind and is implemented on the key that's the source, eg TextRunKey. CreateShadow and IsVisible are properties of the primitive and can be combined into a Primitive trait.


webrender/src/picture.rs, line 573 at r2 (raw file):

Previously, gw3583 (Glenn Watson) wrote…

This is not quite right for Pictures (their rect is built dynamically), but this wasn't handled correctly previously anyway - I've got a fix for it in my local branch.

Do you need to post me the fix to incorporate?


webrender/src/picture.rs, line 1253 at r2 (raw file):

Previously, gw3583 (Glenn Watson) wrote…

Maybe make this a helper method on FrameResources? Seems like it'll be used in a few places.

Done.


webrender/src/scene_builder.rs, line 173 at r2 (raw file):

Previously, gw3583 (Glenn Watson) wrote…

What is this trait needed for?

It's used by the generic version of DisplayListFlattener::create_primitive to obtain the correct interner for primitive.

        let interner = self.resources.interner_mut(); // Uses type deduction to work out the which store +
        let prim_data_handle =                        //                                                 |
            interner                                  //                                                 |
            .intern(&prim_key, || { ... });           // << From the types required here ----------------+

webrender/src/prim_store/text_run.rs, line 29 at r2 (raw file):

Previously, gw3583 (Glenn Watson) wrote…

It's probably worth having a set of "common" structs that are embedded within each key / template etc for the data that is shared between all the different types?

OK, I had that in a version but on IRC you advised against it. I think having common structs can help clean up some pattern matching mess.


webrender/src/prim_store/text_run.rs, line 80 at r2 (raw file):

Previously, gw3583 (Glenn Watson) wrote…

Same here for common data.

Done.

@djg djg force-pushed the separate_interning_text_run branch from 6497007 to 6c697ab Compare December 3, 2018 05:04
Copy link
Contributor Author

@djg djg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 3 of 12 files reviewed, 11 unresolved discussions (waiting on @gw3583)


webrender/src/display_list_flattener.rs, line 2236 at r2 (raw file):

Previously, djg (Dan Glastonbury) wrote…

Because there implemented on different types. I can move BuildKey into the the Internable trait as is it related to generating the key for interning. AsInstanceKind is used for getting a PrimitiveInstanceKind and is implemented on the key that's the source, eg TextRunKey. CreateShadow and IsVisible are properties of the primitive and can be combined into a Primitive trait.

One thing I found that is having CreateShadow being a separate trait means that we can use the compiled to help us. ie.

impl CreateShadow for LinearGradient {
    fn create_shadow(&self, shadow: &Shadow) -> Self {
        PrimitiveKeyKind::LinearGradient { .. } |
        panic!("bug: this prim is not supported in shadow contexts");
    }
}

We don't need the panic! implementation and can have the compiler error when trying to create a shadow for LinearGradient because the CreateShadow trait doesn't exists for LinearGradient.

@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #3381) made this pull request unmergeable. Please resolve the merge conflicts.

@djg
Copy link
Contributor Author

djg commented Dec 5, 2018

@gw3583 Ping

@gw3583
Copy link
Contributor

gw3583 commented Dec 5, 2018

Sorry, all-hands jetlag and that - I was going to take a more detailed look in the morning, but I think it probably looks good in general now, or the remaining bits could be done as follow ups. Did we work out what effect this has on talos?

@gw3583
Copy link
Contributor

gw3583 commented Dec 5, 2018

Probably worth getting @kvark to take a quick look too, if he has time.

@djg
Copy link
Contributor Author

djg commented Dec 5, 2018

I'm currently working through removing the conflict with servo/master. Update shortly.

@gw3583 It had a slight improvement on talos, but I wasn't expecting much of a change yet.

@gw3583
Copy link
Contributor

gw3583 commented Dec 5, 2018

@djg Yea, I wouldn't expect a large improvement until we separate solid rects. As long as it doesn't regress, we're good for now 👍

@djg djg force-pushed the separate_interning_text_run branch from 6c697ab to 3f368dc Compare December 5, 2018 01:51
@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #3384) made this pull request unmergeable. Please resolve the merge conflicts.

@gw3583
Copy link
Contributor

gw3583 commented Dec 5, 2018

Sorry, this got conflicts again - I think it should be good to go once those conflicts are resolved?

@djg djg force-pushed the separate_interning_text_run branch from 3f368dc to e3ccda7 Compare December 5, 2018 23:38
@djg
Copy link
Contributor Author

djg commented Dec 5, 2018

@djg
Copy link
Contributor Author

djg commented Dec 6, 2018

@gw3583 Apparently there is one comment to resolve?

@gw3583
Copy link
Contributor

gw3583 commented Dec 6, 2018

I think it's fine to get this merged now, to avoid any more rebase issues. We should be able to fix up any remaining changes as follow ups.

@gw3583
Copy link
Contributor

gw3583 commented Dec 6, 2018

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit e3ccda7 has been approved by gw3583

@bors-servo
Copy link
Contributor

⌛ Testing commit e3ccda7 with merge 6db2d6c...

bors-servo pushed a commit that referenced this pull request Dec 6, 2018
Separate interning text run

First part of separating Primitives into separate interned data.

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

☀️ Test successful - status-appveyor, status-taskcluster
Approved by: gw3583
Pushing 6db2d6c to master...

@bors-servo bors-servo merged commit e3ccda7 into servo:master Dec 6, 2018
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Dec 6, 2018
…449ec591527a (WR PR #3369). r=kats

servo/webrender#3369

Differential Revision: https://phabricator.services.mozilla.com/D13936

--HG--
extra : moz-landing-system : lando
mykmelez pushed a commit to mykmelez/gecko that referenced this pull request Dec 7, 2018
@djg djg deleted the separate_interning_text_run branch December 7, 2018 05:45
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…449ec591527a (WR PR #3369). r=kats

servo/webrender#3369

Differential Revision: https://phabricator.services.mozilla.com/D13936

UltraBlame original commit: 690bea1cb27f8288c479bcea354474a17268ad96
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
…449ec591527a (WR PR #3369). r=kats

servo/webrender#3369

Differential Revision: https://phabricator.services.mozilla.com/D13936

UltraBlame original commit: 690bea1cb27f8288c479bcea354474a17268ad96
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
…449ec591527a (WR PR #3369). r=kats

servo/webrender#3369

Differential Revision: https://phabricator.services.mozilla.com/D13936

UltraBlame original commit: 690bea1cb27f8288c479bcea354474a17268ad96
bhearsum pushed a commit to mozilla-releng/staging-firefox that referenced this pull request May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants