Skip to content

Make Stylist no longer an unsafe pointer once we have fast RWArcs #2604

Closed

Description

@pcwalton

Currently RWArcs use Sems and that is very slow. Once that is no longer the case, put Stylist in an RWArc.

Activity

  1. SimonSapin commented on Aug 12, 2014

    @SimonSapin
    Member

    RWArc<T> is gone, replaced by Arc<RWLock<T>>. Does RWLock still have the same perf problems?

  2. pcwalton commented on Mar 2, 2015

    @pcwalton
    ContributorAuthor

    @SimonSapin I believe RWLock is fast now, looking at Rust. We'll need to benchmark to make sure.

  3. added
    E-less-complex
    on May 12, 2015
  4. mt2d2 commented on Jul 3, 2015

    @mt2d2
    Contributor

    Took a look at this with help from @Ms2ger on IRC—an implementation moving the Stylist from LayoutTaskData to LayoutTask as an Arc<RwLock<Stylist>> panics with a deadlock. Similar deadlock seen when simply using a Mutex (albeit no panic). No luck, open to suggestions!

  5. added
    E-more-complex
    and removed
    E-less-complex
    on Jul 3, 2015
  6. Ms2ger commented on Jul 6, 2015

    @Ms2ger
    Contributor
  7. pcwalton commented on Jul 6, 2015

    @pcwalton
    ContributorAuthor

    Probably needs finer-grained locking inside the Stylist then?

  8. added 5 commits that reference this issue on Sep 3, 2015
    1c8114f
    1d17d86
    a467750
    6e881a1
    6d5244a
  9. 13 remaining items

  10. eefriedman commented on Nov 8, 2015

    @eefriedman
    Contributor

    If we intentionally want to dynamically check the borrowing of Stylist, I think we can just stuff it into an Arc, and use get_mut().unwrap() when we want to mutate it. Granted, it's stylistically terrible, but it's probably better than a raw pointer.

    I don't see how changing the ownership of the Stylist helps.

  11. SimonSapin commented on Nov 8, 2015

    @SimonSapin
    Member

    I don’t think we need dynamic checks at all if Stylist is in the DOM. Like the rest of DOM data, access is exclusive from the script task, and shared but read-only in the "early" phase (until flow tree construction) of layout.

  12. eefriedman commented on Nov 8, 2015

    @eefriedman
    Contributor

    Oh, right... if Stylist is in the DOM, we don't need to mutate it from layout. Makes sense.

  13. added
    C-assigned
    on Mar 2, 2016
  14. removed
    C-assigned
    E-more-complex
    on Mar 10, 2016
  15. jdm commented on Mar 10, 2016

    @jdm
    Member

    Latest attempt at #7524.

  16. emilio commented on Apr 23, 2016

    @emilio
    Member

    #10815 Should take care of this.

    It uses an Arc plus Arc::get_mut, and seems to work just fine. It should not have almost any performance overhead.

  17. SimonSapin commented on Apr 23, 2016

    @SimonSapin
    Member

    @emilio Arc::get_mut clones the contents if the refcount is above one. Is this really desired here? This issue originally mentions RWLock.

  18. emilio commented on Apr 23, 2016

    @emilio
    Member

    @SimonSapin: Stylist is not cloneable, Arc::get_mut returns None if the refcount is not one (unlike Arc::make_mut).

    I'm using Arc::get_mut(&mut rw_data.stylist).unwrap() and I haven't ever got a crash.

  19. SimonSapin commented on Apr 23, 2016

    @SimonSapin
    Member

    Oh yeah, sorry, I got confused with make_mut. But if the refcount really is always one, could this be a Box?

  20. emilio commented on Apr 23, 2016

    @emilio
    Member

    I think not since it has to be handed out to layout traversal (I mean to SharedLayoutContext).

    The refcount is always one when we update the stylist in the layout thread, but not always.

  21. emilio commented on May 2, 2016

    @emilio
    Member

    This is closed by #10815

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

I-refactorI-safety

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions