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

rustdoc: use smarter encoding for playground URL #107284

Merged
merged 1 commit into from
Jan 27, 2023

Conversation

notriddle
Copy link
Contributor

@notriddle notriddle commented Jan 25, 2023

The old way would compress okay with DEFLATE, but this version makes uncompressed docs smaller, which matters for memory usage and stuff like cargo doc.

Try it out: https://play.rust-lang.org/?code=fn+main()+{%0Alet+mut+v+=+Vec::new();%0Av.push(1+/+1);%0Aprintln!(%22{}%22,+v[0]);%0A}

In local testing, this change shrinks sample pages by anywhere between 4.0% and 0.031%

$ du -b after.dir/std/vec/struct.Vec.html before.dir/std/vec/struct.Vec.html
759235  after.dir/std/vec/struct.Vec.html
781842  before.dir/std/vec/struct.Vec.html

100*((759235-781842)/781842)=-2.8

$ du -b after.dir/std/num/struct.Wrapping.html before.dir/std/num/struct.Wrapping.html
3194173 after.dir/std/num/struct.Wrapping.html
3204351 before.dir/std/num/struct.Wrapping.html

100*((3194173-3204351)/3204351)=-0.031

$ du -b after.dir/std/keyword.match.html before.dir/std/keyword.match.html
8151    after.dir/std/keyword.match.html
8495    before.dir/std/keyword.match.html

100*((8151-8495)/8495)=-4.0

Gzipped tarball sizes seem shrunk, but not by much.

du -s before.tar.gz after.tar.gz
69600   before.tar.gz
69480   after.tar.gz

100*((69480-69600)/69600)=-0.17

@rustbot
Copy link
Collaborator

rustbot commented Jan 25, 2023

r? @jsha

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jan 25, 2023
src/librustdoc/html/markdown.rs Outdated Show resolved Hide resolved
@jsha
Copy link
Contributor

jsha commented Jan 25, 2023

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 25, 2023

📌 Commit 0db0419 has been approved by jsha

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 25, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 25, 2023
rustdoc: use smarter encoding for playground URL

The old way would compress okay with DEFLATE, but this version makes uncompressed docs smaller, which matters for memory usage and stuff like `cargo doc`.

Try it out: <https://play.rust-lang.org/?code=fn+main()+{%0Alet+mut+v+=+Vec::new();%0Av.push(1+/+1);%0Aprintln!(%22{}%22,+v[0]);%0A}>

In local testing, this change shrinks sample pages by anywhere between 5.0% and 0.044%

    $ du -b after.dir/std/vec/struct.Vec.html before.dir/std/vec/struct.Vec.html
    753023  after.dir/std/vec/struct.Vec.html
    781842  before.dir/std/vec/struct.Vec.html

100*((753023-781842)/781842)=-3.7

    $ du -b after.dir/std/num/struct.Wrapping.html before.dir/std/num/struct.Wrapping.html
    3189989 after.dir/std/num/struct.Wrapping.html
    3204351 before.dir/std/num/struct.Wrapping.html

100*((3189989-3204351)/3204351)=-0.044

    $ du -b after.dir/std/keyword.match.html before.dir/std/keyword.match.html
    8067    after.dir/std/keyword.match.html
    8495    before.dir/std/keyword.match.html

100*((8067-8495)/8495)=-5.0

Gzipped tarball sizes seem shrunk, but not by much.

    du -s before.tar.gz after.tar.gz
    69600   before.tar.gz
    69492   after.tar.gz

100*((69492-69600)/69600)=-0.16
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 25, 2023
rustdoc: use smarter encoding for playground URL

The old way would compress okay with DEFLATE, but this version makes uncompressed docs smaller, which matters for memory usage and stuff like `cargo doc`.

Try it out: <https://play.rust-lang.org/?code=fn+main()+{%0Alet+mut+v+=+Vec::new();%0Av.push(1+/+1);%0Aprintln!(%22{}%22,+v[0]);%0A}>

In local testing, this change shrinks sample pages by anywhere between 5.0% and 0.044%

    $ du -b after.dir/std/vec/struct.Vec.html before.dir/std/vec/struct.Vec.html
    753023  after.dir/std/vec/struct.Vec.html
    781842  before.dir/std/vec/struct.Vec.html

100*((753023-781842)/781842)=-3.7

    $ du -b after.dir/std/num/struct.Wrapping.html before.dir/std/num/struct.Wrapping.html
    3189989 after.dir/std/num/struct.Wrapping.html
    3204351 before.dir/std/num/struct.Wrapping.html

100*((3189989-3204351)/3204351)=-0.044

    $ du -b after.dir/std/keyword.match.html before.dir/std/keyword.match.html
    8067    after.dir/std/keyword.match.html
    8495    before.dir/std/keyword.match.html

100*((8067-8495)/8495)=-5.0

Gzipped tarball sizes seem shrunk, but not by much.

    du -s before.tar.gz after.tar.gz
    69600   before.tar.gz
    69492   after.tar.gz

100*((69492-69600)/69600)=-0.16
@notriddle
Copy link
Contributor Author

CC @matthiaskrgr

Failed in rollup.

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 25, 2023
@notriddle

This comment was marked as duplicate.

@bors

This comment was marked as duplicate.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 26, 2023
The old way would compress okay with DEFLATE, but this version makes
uncompressed docs smaller, which matters for memory usage and stuff
like `cargo doc`.

Try it out: <https://play.rust-lang.org/?code=fn+main()+{%0Alet+mut+v+=+Vec::new();%0Av.push(1+/+1);%0Aprintln!(%22{}%22,+v[0]);%0A}>

In local testing, this change shrinks sample pages by anywhere between
4.0% and 0.031%

    $ du -b after.dir/std/vec/struct.Vec.html before.dir/std/vec/struct.Vec.html
    759235  after.dir/std/vec/struct.Vec.html
    781842  before.dir/std/vec/struct.Vec.html

100*((759235-781842)/781842)=-2.8

    $ du -b after.dir/std/num/struct.Wrapping.html before.dir/std/num/struct.Wrapping.html
    3194173 after.dir/std/num/struct.Wrapping.html
    3204351 before.dir/std/num/struct.Wrapping.html

100*((3194173-3204351)/3204351)=-0.031

    $ du -b after.dir/std/keyword.match.html before.dir/std/keyword.match.html
    8151    after.dir/std/keyword.match.html
    8495    before.dir/std/keyword.match.html

100*((8151-8495)/8495)=-4.0

Gzipped tarball sizes seem shrunk, but not by much.

    du -s before.tar.gz after.tar.gz
    69600   before.tar.gz
    69480   after.tar.gz

100*((69480-69600)/69600)=-0.17
@notriddle
Copy link
Contributor Author

It looks like html5-tidy rejects any url that has things outside the url code points set. I've run it locally, and validated that the fix worked.

@bors r=jsha

@bors
Copy link
Contributor

bors commented Jan 26, 2023

📌 Commit 51df99f has been approved by jsha

It is now in the queue for this repository.

JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jan 27, 2023
rustdoc: use smarter encoding for playground URL

The old way would compress okay with DEFLATE, but this version makes uncompressed docs smaller, which matters for memory usage and stuff like `cargo doc`.

Try it out: <https://play.rust-lang.org/?code=fn+main()+{%0Alet+mut+v+=+Vec::new();%0Av.push(1+/+1);%0Aprintln!(%22{}%22,+v[0]);%0A}>

In local testing, this change shrinks sample pages by anywhere between 4.0% and 0.031%

    $ du -b after.dir/std/vec/struct.Vec.html before.dir/std/vec/struct.Vec.html
    759235  after.dir/std/vec/struct.Vec.html
    781842  before.dir/std/vec/struct.Vec.html

100*((759235-781842)/781842)=-2.8

    $ du -b after.dir/std/num/struct.Wrapping.html before.dir/std/num/struct.Wrapping.html
    3194173 after.dir/std/num/struct.Wrapping.html
    3204351 before.dir/std/num/struct.Wrapping.html

100*((3194173-3204351)/3204351)=-0.031

    $ du -b after.dir/std/keyword.match.html before.dir/std/keyword.match.html
    8151    after.dir/std/keyword.match.html
    8495    before.dir/std/keyword.match.html

100*((8151-8495)/8495)=-4.0

Gzipped tarball sizes seem shrunk, but not by much.

    du -s before.tar.gz after.tar.gz
    69600   before.tar.gz
    69480   after.tar.gz

100*((69480-69600)/69600)=-0.17
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 27, 2023
Rollup of 8 pull requests

Successful merges:

 - rust-lang#105784 (update stdarch)
 - rust-lang#106856 (core: Support variety of atomic widths in width-agnostic functions)
 - rust-lang#107171 (rustc_metadata: Fix `encode_attrs`)
 - rust-lang#107242 (rustdoc: make item links consistently use `title="{shortty} {path}"`)
 - rust-lang#107279 (Use new solver during selection)
 - rust-lang#107284 (rustdoc: use smarter encoding for playground URL)
 - rust-lang#107325 (rustdoc: Stop using `HirId`s)
 - rust-lang#107336 (rustdoc: remove mostly-unused CSS classes `import-item` and `module-item`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d68b5a4 into rust-lang:master Jan 27, 2023
@rustbot rustbot added this to the 1.69.0 milestone Jan 27, 2023
@notriddle notriddle deleted the notriddle/plus branch January 27, 2023 13:40
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Feb 9, 2023
…de, r=GuillaumeGomez

rustdoc: use the same URL escape rules for fragments as for examples

Carries over improvements from rust-lang#107284
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants