Skip to content

Measure the heap usage of Url #6912

Closed
Closed

Description

@jdm

There are a lot of them, and they're stubbed out as 0 in mem.rs right now.

Activity

  1. added
    I-perf-bloat
    on Aug 3, 2015
  2. SimonSapin commented on Aug 3, 2015

    @SimonSapin
    Member

    rust-url being an external crate makes it hard to derive HeapSizeOf, but implementing manually in mem.rs should be doable as all Url fields are public. To make sure this impl is and stays correct, use struct patterns rather than foo.bar field access:

    let &Url { ref scheme, ref scheme_data, ref query, ref fragment } = url;
    scheme.heap_size_of_children() +
        scheme_data.heap_size_of_children() +
        query.heap_size_of_children() +
        fragment.heap_size_of_children()
  3. metajack commented on Aug 3, 2015

    @metajack
    Collaborator

    Why do struct patterns ensure forward compatability here? Also what if more public fields are added? Won't the struct pattern then fail but direct field access have been fine?

  4. SimonSapin commented on Aug 3, 2015

    @SimonSapin
    Member

    That’s the point: if a future rust-url version adds a new field, an exhaustive struct pattern (without ..) will fail to build rather then silently fail to measure some data. This build failure will force us to update the measuring code to make it correct again.

  5. nnethercote commented on Aug 3, 2015

    @nnethercote
    Contributor

    use struct patterns rather than foo.bar field access

    That's a neat trick.

  6. nnethercote commented on Aug 3, 2015

    @nnethercote
    Contributor

    ...and a trick that arguably deserves a comment so some eager beaver doesn't rewrite the code in the future?

  7. added a commit that references this issue on Aug 4, 2015
    c2497fc
  8. added a commit that references this issue on Aug 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-perf-bloat

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions