Stream: t-compiler/wg-self-profile

Topic: Docs


Alice Ryhl (Apr 25 2019 at 15:09, on Zulip):

@Wesley Wiser here?

Wesley Wiser (Apr 25 2019 at 15:10, on Zulip):

Yep!

Wesley Wiser (Apr 25 2019 at 15:10, on Zulip):

I don't know if you saw @centril's latest post in the weekly meeting thread, but I think that's probably the first order of business

Wesley Wiser (Apr 25 2019 at 15:10, on Zulip):

1. Start with git clone for the measure me repo itself and progress to cargo install;
2. Tell the user how to setup a rustc toolchain and run summarize for that.
3. And also how to deal with diffs and such

Wesley Wiser (Apr 25 2019 at 15:11, on Zulip):

We currently have some of this scattered around the repo but having a consolidated "tutorial" would be great

Alice Ryhl (Apr 25 2019 at 15:12, on Zulip):

I'll take a look at it in an hour or so

Wesley Wiser (Apr 25 2019 at 15:12, on Zulip):

For example, there's a half baked tutorial here

Wesley Wiser (Apr 25 2019 at 15:12, on Zulip):

Sounds good!

Wesley Wiser (Apr 25 2019 at 15:12, on Zulip):

If you need more guidance or have any questions, feel free to ping me here

Alice Ryhl (Apr 25 2019 at 18:31, on Zulip):

So I've been reading parts of the source code to figure out how things fit together, and I think I have some overall idea. I then tried to follow the half baked tutorial you listed, but the rustc call only produced a regex.profile_events.json file, while summarize seems to expect three files with extensions events, string_data and string_index. @Wesley Wiser

Wesley Wiser (Apr 25 2019 at 18:31, on Zulip):

Hmmm

Wesley Wiser (Apr 25 2019 at 18:32, on Zulip):

Are you using a nightly, beta, or stable compiler?

Alice Ryhl (Apr 25 2019 at 18:32, on Zulip):

Well I compiled with cargo +nightly build

Wesley Wiser (Apr 25 2019 at 18:32, on Zulip):

Ok

Wesley Wiser (Apr 25 2019 at 18:32, on Zulip):

So that should be nightly

Alice Ryhl (Apr 25 2019 at 18:32, on Zulip):

(it doesn't compile on stable)

Wesley Wiser (Apr 25 2019 at 18:32, on Zulip):

Is it an old nightly?

Wesley Wiser (Apr 25 2019 at 18:32, on Zulip):

Yeah, -Z options shouldn't be allowed on stable/beta

Alice Ryhl (Apr 25 2019 at 18:33, on Zulip):

uhh, probably, considering I haven't done rustup today

Alice Ryhl (Apr 25 2019 at 18:33, on Zulip):

Will update

Wesley Wiser (Apr 25 2019 at 18:33, on Zulip):

cargo +nightly rustc -- --version I think will give you a date

Wesley Wiser (Apr 25 2019 at 18:34, on Zulip):

The PR which changes that behavior got merged ~12 days ago so any semi-recent nightly should work

Alice Ryhl (Apr 25 2019 at 18:34, on Zulip):

Okay that helped!

Alice Ryhl (Apr 25 2019 at 18:35, on Zulip):

Whoops, it panics if piped into head.

Alice Ryhl (Apr 25 2019 at 18:36, on Zulip):

Anyways it works now

Wesley Wiser (Apr 25 2019 at 18:36, on Zulip):

Yay

Wesley Wiser (Apr 25 2019 at 18:36, on Zulip):

So now you should have the .events, .string_data, and .string_index files

Wesley Wiser (Apr 25 2019 at 18:37, on Zulip):

If you git clone https://github.com/rust-lang/measureme.git and then cargo build, you should have two tools available

Wesley Wiser (Apr 25 2019 at 18:38, on Zulip):

cargo run --bin summarize which produces a table on stdout with interesting metrics about the profile

Wesley Wiser (Apr 25 2019 at 18:38, on Zulip):

and
cargo run --bin stack-collapse which produces a collapsed stacks files from the profile data

Alice Ryhl (Apr 25 2019 at 18:38, on Zulip):

https://github.com/rust-lang/measureme/issues/31

Wesley Wiser (Apr 25 2019 at 18:39, on Zulip):

(Thanks)

Alice Ryhl (Apr 25 2019 at 18:39, on Zulip):

although maybe that issue should go on prettytable
oh well

Wesley Wiser (Apr 25 2019 at 18:39, on Zulip):

I guess we should probably have some labels set up for the different tools

Wesley Wiser (Apr 25 2019 at 18:40, on Zulip):

That's fair. Having an issue in our repo to point them to is probably also useful

Alice Ryhl (Apr 25 2019 at 18:42, on Zulip):

It seems like it would be a good idea to have an option to only print stuff with runtime > some_value, considering the table seems like it should be read by humans

Wesley Wiser (Apr 25 2019 at 18:43, on Zulip):

That's a good idea. We should also default it to something reasonable. Perhaps show nothing < 1% of the total time by default?

Alice Ryhl (Apr 25 2019 at 18:44, on Zulip):

yeah

Alice Ryhl (Apr 25 2019 at 18:45, on Zulip):

Although I can't quite tell how far down the list is a reasonable default

Alice Ryhl (Apr 25 2019 at 18:45, on Zulip):

with 1% it currently prints these

LLVM_emit_obj
LLVM_module_passes
LLVM_make_bitcode
typeck_tables_of
mir_borrowck
optimized_mir
mir_built
LLVM_compress_bitcode
evaluate_obligation
codegen
Wesley Wiser (Apr 25 2019 at 18:46, on Zulip):

I guess the question is "what's the long tail?"

Wesley Wiser (Apr 25 2019 at 18:46, on Zulip):

If that's ~90% of the total compilation time, that's almost certainly good enough for a default output

Wesley Wiser (Apr 25 2019 at 18:46, on Zulip):

But if it's only ~50%, then that might not be sufficient

Alice Ryhl (Apr 25 2019 at 18:48, on Zulip):

For the regex crate on my machine it is 76% of the total compilation time.

Wesley Wiser (Apr 25 2019 at 18:49, on Zulip):

Hmm. Not quite the clear cut result I was hoping for lol

Wesley Wiser (Apr 25 2019 at 18:49, on Zulip):

We should gather more data from other crates before picking a default anyway

Wesley Wiser (Apr 25 2019 at 18:50, on Zulip):

I'd say just file an issue and we'll get to it at some point

Alice Ryhl (Apr 25 2019 at 18:50, on Zulip):

you could also just print the top 80% of the running time :p

Wesley Wiser (Apr 25 2019 at 18:50, on Zulip):

That's true

Wesley Wiser (Apr 25 2019 at 18:50, on Zulip):

I think the first step is probably just allowing the user to pick an option on the cli

Wesley Wiser (Apr 25 2019 at 18:50, on Zulip):

From there, we can experiment easier before deciding on a default

Alice Ryhl (Apr 25 2019 at 19:01, on Zulip):

#32

Alice Ryhl (Apr 25 2019 at 20:49, on Zulip):

@Wesley Wiser What are Blocked time and Incremental load time?

Alice Ryhl (Apr 25 2019 at 20:49, on Zulip):

And Item count?

Wesley Wiser (Apr 25 2019 at 20:49, on Zulip):

Incremental load time is time spent loading a result from the incremental result cache instead of recomputing it from scratch

Wesley Wiser (Apr 25 2019 at 20:50, on Zulip):

Blocked time is time spent waiting for the query to finish executing in a different thread. This only happens when you have a compiler built with parallel queries turned on. (I think)

Wesley Wiser (Apr 25 2019 at 20:50, on Zulip):

Item count is how many times the query/activity appeared in the profile

Alice Ryhl (Apr 25 2019 at 20:51, on Zulip):

Also, which nightly was the first with the feature? You said it was 12 days-ish ago I think?

Wesley Wiser (Apr 25 2019 at 20:53, on Zulip):

This was the PR so I assume April 13th's nightly would have had that change

Alice Ryhl (Apr 25 2019 at 21:05, on Zulip):

So I tried to write some documentation. What do you think of this so far?

Alice Ryhl (Apr 25 2019 at 21:08, on Zulip):

I need a better way of previewing the result than committing to github :/

Wesley Wiser (Apr 25 2019 at 21:09, on Zulip):

Are you using a local editor or the GitHub editor?

Wesley Wiser (Apr 25 2019 at 21:09, on Zulip):

VSCode has a nice markdown preview mode

Alice Ryhl (Apr 25 2019 at 21:10, on Zulip):

I just edit the file in vim.

Wesley Wiser (Apr 25 2019 at 21:10, on Zulip):

Ah ok

Wesley Wiser (Apr 25 2019 at 21:10, on Zulip):

I usually use VSCode & the vim extension

Wesley Wiser (Apr 25 2019 at 21:11, on Zulip):

It works really nicely https://code.visualstudio.com/docs/languages/markdown

Wesley Wiser (Apr 25 2019 at 21:12, on Zulip):

The docs look awesome!!

Wesley Wiser (Apr 25 2019 at 21:12, on Zulip):

I'm a little unsure about recommending that people install the tool because we are purposely not making the binary format stable at this time.

Wesley Wiser (Apr 25 2019 at 21:13, on Zulip):

Using a different version of the tool than rustc is using will cause all kinds of weird things to happen

Alice Ryhl (Apr 25 2019 at 21:13, on Zulip):

Well I did that because of the quote 'Start with git clone for the measure me repo itself and progress to cargo install' from earlier

Alice Ryhl (Apr 25 2019 at 21:13, on Zulip):

but I can recommend using the binary directly instead

Wesley Wiser (Apr 25 2019 at 21:14, on Zulip):

Oh, sorry. That's my fault

Wesley Wiser (Apr 25 2019 at 21:14, on Zulip):

I should have edited those instructions more carefully

Alice Ryhl (Apr 25 2019 at 21:16, on Zulip):

So I should also tell people to recompile summarize if they update/change the compiler?

Wesley Wiser (Apr 25 2019 at 21:16, on Zulip):

So rereading over it, I think this is what we need to start with:

1. Start with git clone for the measure me repo itself and progress to running a simple profile;
2. Tell the user how to setup a rustc toolchain and run summarize for that.

Wesley Wiser (Apr 25 2019 at 21:17, on Zulip):

Yes? I guess? It's a little complicated in that the version they use needs to match the version used by rustc which is not necessarily going to be the latest version.

Wesley Wiser (Apr 25 2019 at 21:17, on Zulip):

Maybe it's best not to get into that too much at this point since we haven't made any breaking changes yet.

Alice Ryhl (Apr 25 2019 at 21:18, on Zulip):

I thought I'd start with showing it for the nightly compiler, since that's easier getting started with, then adding a section where one sets up a rustc toolchain by compiling the compiler yourself and doing it on that?

Wesley Wiser (Apr 25 2019 at 21:18, on Zulip):

Yeah, that sounds great

Wesley Wiser (Apr 25 2019 at 21:18, on Zulip):

There's some existing documentation on rustc workflows over in the rustc-guide

Alice Ryhl (Apr 25 2019 at 21:19, on Zulip):

Oh, could you send a link to the part you're thinking of?

Wesley Wiser (Apr 25 2019 at 21:19, on Zulip):

We should just point to that as the authoritative source on building rustc

Wesley Wiser (Apr 25 2019 at 21:19, on Zulip):

one sec

Wesley Wiser (Apr 25 2019 at 21:20, on Zulip):

This is the "definitive" source: https://rust-lang.github.io/rustc-guide/how-to-build-and-run.html

Wesley Wiser (Apr 25 2019 at 21:20, on Zulip):

But we should make a general recommendation like, "If you've never build rustc before, we suggest starting with ./x.py build"

Alice Ryhl (Apr 25 2019 at 21:21, on Zulip):

sure

Wesley Wiser (Apr 25 2019 at 21:21, on Zulip):

Given how many crates rely on proc macros, you'll probably need a stage 2 compiler anway

Wesley Wiser (Apr 25 2019 at 21:22, on Zulip):

Anyway, the docs you've written look great and exactly the kind of step-by-step guide I think we need

Alice Ryhl (Apr 25 2019 at 21:23, on Zulip):

cool

Alice Ryhl (Apr 25 2019 at 21:23, on Zulip):

I'm glad I found somewhere to start out contributing. It's been sorta difficult to find one on my own.

Wesley Wiser (Apr 25 2019 at 21:23, on Zulip):

Once you're ready to submit a PR, I'd love to get somebody else who hasn't used this tool before to try them out and see if they can get it to work.

@Amanjeev Sethi perhaps? :slight_smile:

Wesley Wiser (Apr 25 2019 at 21:26, on Zulip):

Yeah, I remember when I started contributing. It took months of watching the repo before I found something I thought I could tackle.

Alice Ryhl (Apr 25 2019 at 21:29, on Zulip):

Okay so, what is the equivalent of cargo +nightly rustc -- -Z self-profile for a compiler I've built myself?

Wesley Wiser (Apr 25 2019 at 21:29, on Zulip):

The easiest thing I've found is to set up a custom toolchain in rustup

Wesley Wiser (Apr 25 2019 at 21:33, on Zulip):

https://wesleywiser.github.io/post/custom-rust-toolchain/

Wesley Wiser (Apr 25 2019 at 21:33, on Zulip):

Once you've done that, you can do the same +toolchain cargo command

Alice Ryhl (Apr 25 2019 at 21:36, on Zulip):

Okay this is what I'll get done for tonight. same link as before

Wesley Wiser (Apr 25 2019 at 21:38, on Zulip):

Yeah, that looks good!

Wesley Wiser (Apr 25 2019 at 21:38, on Zulip):

My only feedback would be to include instructions for creating the custom toolchain inline

Wesley Wiser (Apr 25 2019 at 21:39, on Zulip):

rustup toolchain link foo bar ...

Alice Ryhl (Apr 25 2019 at 21:39, on Zulip):

Sure, but I'll try doing it myself before writing those instructions. :smile:

Wesley Wiser (Apr 25 2019 at 21:39, on Zulip):

Absolutely :thumbs_up:

Alice Ryhl (Apr 25 2019 at 21:39, on Zulip):

Okay I'm going to bed.
Which timezone are you in? (I'm in copenhagen)

Wesley Wiser (Apr 25 2019 at 21:40, on Zulip):

EDT (UTC - 4)

Wesley Wiser (Apr 25 2019 at 21:40, on Zulip):

(East Coast, United States)

Wesley Wiser (Apr 25 2019 at 21:41, on Zulip):

Have a good evening! :wave:

Alice Ryhl (Apr 25 2019 at 21:41, on Zulip):

Thanks, good night :wave:

Amanjeev Sethi (Apr 25 2019 at 22:53, on Zulip):

Once you're ready to submit a PR, I'd love to get somebody else who hasn't used this tool before to try them out and see if they can get it to work.

Amanjeev Sethi perhaps? :slight_smile:

absolutely! I would love to try it out. I have been trying to follow your discussion but have not been able to repeat anything. Lots of missing pieces for me. but I would love to be the person to try out

Amanjeev Sethi (Apr 25 2019 at 23:17, on Zulip):

I am on east coast in the US as well (at least for now).

Wesley Wiser (Apr 26 2019 at 01:08, on Zulip):

Once you're ready to submit a PR, I'd love to get somebody else who hasn't used this tool before to try them out and see if they can get it to work.

Amanjeev Sethi perhaps? :slight_smile:

absolutely! I would love to try it out. I have been trying to follow your discussion but have not been able to repeat anything. Lots of missing pieces for me. but I would love to be the person to try out

Great! @Alice Ryhl is making short work of the guide so I imagine it will be ready to test within a few days or so.

centril (Apr 26 2019 at 02:30, on Zulip):

@Wesley Wiser It would be really nice if ./x.py could make a new custom toolchain for you and have it do the cp -R ... as well; ./x.py toolchain --stage 1 $name $path_to_copy_toolchain_to

centril (Apr 26 2019 at 02:30, on Zulip):

another thing that would be nice to show is how this works when just invoking rustc on a specific file, e.g. a.rs

centril (Apr 26 2019 at 02:34, on Zulip):

(filed in https://github.com/rust-lang/measureme/issues/33) non-docs related, it would be great to enable summarize pid-$baseline pid-$change to see a diff

mw (Apr 26 2019 at 07:04, on Zulip):

Nice, thanks for all your work, @Alice Ryhl!

mw (Apr 26 2019 at 07:06, on Zulip):

I think we don't have a final vision of how these tools should be used in the future, so there's an opportunity here not only to document but also to come up with and shape the workflows around self-profiling.

Alice Ryhl (Apr 26 2019 at 07:12, on Zulip):

Making a document explaining how we hope it should work in the future sounds like a good idea. I can look at writing something about that after I finish this guide

mw (Apr 26 2019 at 07:28, on Zulip):

sure, no rush :)

Wesley Wiser (Apr 26 2019 at 08:43, on Zulip):

Wesley Wiser It would be really nice if ./x.py could make a new custom toolchain for you and have it do the cp -R ... as well; ./x.py toolchain --stage 1 $name $path_to_copy_toolchain_to

@centril I'm not sure what you mean by this bit cp -R .... When I set up my dev environment, I just did this:

git clone https://github.com/rust-lang/rust.git
cd rust
./x.py build
rustup toolchain link stage0 ./build/x86_64-unknown-linux-gnu/stage0
rustup toolchain link stage1 ./build/x86_64-unknown-linux-gnu/stage1
rustup toolchain link stage0 ./build/x86_64-unknown-linux-gnu/stage0

at which point, I can now do

[cargo | rustc] +[stage0 | stage1 | stage2] {args}...

for any other project or file etc.

centril (Apr 26 2019 at 08:43, on Zulip):

@Wesley Wiser but what happens if you switch branches and then want to build again?

centril (Apr 26 2019 at 08:44, on Zulip):

does rustup toolchain link copy the files in the directory?

Wesley Wiser (Apr 26 2019 at 08:44, on Zulip):

ah well I use git workspaces for that

centril (Apr 26 2019 at 08:44, on Zulip):

@Wesley Wiser what sorta voodoo is that? :D

Wesley Wiser (Apr 26 2019 at 08:45, on Zulip):

So ~/code/rust/rust is my "canonical" repo

Wesley Wiser (Apr 26 2019 at 08:45, on Zulip):

ie git lives in ~/code/rust/rust/.git

Wesley Wiser (Apr 26 2019 at 08:45, on Zulip):

but from that folder I ran git workspace add ../rust2

Wesley Wiser (Apr 26 2019 at 08:46, on Zulip):

which creates a checkout at ~/code/rust/rust2 with all of my current HEAD's files

Wesley Wiser (Apr 26 2019 at 08:46, on Zulip):

and that folder shares its git data with ~/code/rust/rust

Wesley Wiser (Apr 26 2019 at 08:46, on Zulip):

So now, I can go into either folder, checkout any commit I want, do a build and make changes in the other folder without destroying the build

centril (Apr 26 2019 at 08:47, on Zulip):

@Wesley Wiser ah, that's nice

Wesley Wiser (Apr 26 2019 at 08:47, on Zulip):

and then I did

rustup toolchain link stage0-2 ~/code/rust/rust2/build/x86_64-unknown-linux-gnu/stage0
rustup toolchain link stage1-2 ~/code/rust/rust2/build/x86_64-unknown-linux-gnu/stage1
rustup toolchain link stage0-2 ~/code/rust/rust2/build/x86_64-unknown-linux-gnu/stage0
Wesley Wiser (Apr 26 2019 at 08:47, on Zulip):

so now rustup knows about them

centril (Apr 26 2019 at 08:48, on Zulip):

@Wesley Wiser I think this is the sort of tribal knowledge that needs to be documented, especially for summarize

Wesley Wiser (Apr 26 2019 at 08:48, on Zulip):

@centril It's super easy to setup and it's really nice because I don't have to push commits anywhere to share them across folders

Wesley Wiser (Apr 26 2019 at 08:49, on Zulip):

That probably belongs more in the rustc-guide. I don't think it's that useful for summarize.

Alice Ryhl (Apr 26 2019 at 08:49, on Zulip):

Huh, I've never heard of that before. And I agree the rustc-guide is the place for that

centril (Apr 26 2019 at 08:49, on Zulip):

@Wesley Wiser the only place I've needed this is for summarize tho :slight_smile:

Wesley Wiser (Apr 26 2019 at 08:49, on Zulip):

Why do you need it?

centril (Apr 26 2019 at 08:50, on Zulip):

but... document in rustc guide and link to it from summarize

Wesley Wiser (Apr 26 2019 at 08:50, on Zulip):

(I've not needed so I'm confused)

centril (Apr 26 2019 at 08:50, on Zulip):

@Wesley Wiser to profile differences between master and my-branch

Wesley Wiser (Apr 26 2019 at 08:50, on Zulip):

Oh I see

Alice Ryhl (Apr 26 2019 at 08:51, on Zulip):

Ah so you've needed it in the rust repo, but only when using summarize.

centril (Apr 26 2019 at 08:51, on Zulip):

right

centril (Apr 26 2019 at 08:52, on Zulip):

(also, for the same PR I really wanted to have summarizegive me a diff between two different self-profile outputs)

Wesley Wiser (Apr 26 2019 at 08:53, on Zulip):

Having thought about it for 0.2 seconds, here's how I'd expect that to work:

1. You make a build of master and run summarize --json and copy the resulting file somewhere safe
2. You rebase your branch on master, build, and then run summarize --json again and copy that file somewhere safe
3. You run (a currently hypothetical) summarize diff file1 file2 which then displays the diff

Alice Ryhl (Apr 26 2019 at 08:53, on Zulip):

Why would --json be needed?

Wesley Wiser (Apr 26 2019 at 08:54, on Zulip):

I don't think we want the tool to parse the cli output

Wesley Wiser (Apr 26 2019 at 08:54, on Zulip):

That's intended for humans and not machines

Alice Ryhl (Apr 26 2019 at 08:54, on Zulip):

oh so you have three invocations of summarize here?

Wesley Wiser (Apr 26 2019 at 08:54, on Zulip):

--json is what perf.rlo will use once this is integrated with it

Wesley Wiser (Apr 26 2019 at 08:55, on Zulip):

Yeah

Alice Ryhl (Apr 26 2019 at 08:55, on Zulip):

I imagined you'd diff the pid-{pid} stuff directly

Wesley Wiser (Apr 26 2019 at 08:55, on Zulip):

That's certainly possible

centril (Apr 26 2019 at 08:55, on Zulip):

@Wesley Wiser I just expect to be able to use rustc +master -Z self-profile file.rs + rustc +change -Z self-profile file.rs and then summarize pid-$master pid-$change

Wesley Wiser (Apr 26 2019 at 08:55, on Zulip):

The .json files are much more compact

Wesley Wiser (Apr 26 2019 at 08:56, on Zulip):

So perf.rlo will probably need the json diff because we don't want to be storing hundreds of megs of performance related outputs per build

Alice Ryhl (Apr 26 2019 at 08:56, on Zulip):

Then perhaps the compiler should convert them immediately after profiling then, re. conversation in binary format versioning

centril (Apr 26 2019 at 08:57, on Zulip):

perf.rlo can always use a different UX than you use manually

Wesley Wiser (Apr 26 2019 at 08:57, on Zulip):

That would be pretty cool locally

Wesley Wiser (Apr 26 2019 at 08:57, on Zulip):

We're also building a number of other tools and the common format is the .events, .string_data and .string_index files

centril (Apr 26 2019 at 08:58, on Zulip):

@Wesley Wiser stretch goal: summarize foo.rs +master +change

Wesley Wiser (Apr 26 2019 at 08:58, on Zulip):

So sometimes you might be interested in summarize or other times you might be interested in stack-collapse etc

Alice Ryhl (Apr 26 2019 at 08:59, on Zulip):

I really think we should consider bundling the three files in one as a post-processing step

Wesley Wiser (Apr 26 2019 at 08:59, on Zulip):

They also gzip well so perhaps just zipping them up would be sufficient

centril (Apr 26 2019 at 09:00, on Zulip):

Having one file would be convenient in terms of moving things around so I don't have to make separate folders

Wesley Wiser (Apr 26 2019 at 09:00, on Zulip):

Part of the design constraint here is that we're trying to keep the additional work rustc does to an absolute minimum because it will massively skew the instructions count that perf.rlo relies on.

Alice Ryhl (Apr 26 2019 at 09:01, on Zulip):

I mean the idea is to post-process after you finish profiling, so the post-processing isn't included in that instruction count

centril (Apr 26 2019 at 09:01, on Zulip):

@Wesley Wiser can't you use a separate flag for the manual stuff?

centril (Apr 26 2019 at 09:01, on Zulip):

-Z self-profile-bundle

Wesley Wiser (Apr 26 2019 at 09:01, on Zulip):

I suppose that's a possibility

Wesley Wiser (Apr 26 2019 at 09:02, on Zulip):

:slight_smile:

centril (Apr 26 2019 at 09:02, on Zulip):

(or make it -Z self-profile-perf-lo for the perf-lo version to improve ergonomics ;)

Alice Ryhl (Apr 26 2019 at 09:03, on Zulip):

I mean I'd also want a single file when using it locally

centril (Apr 26 2019 at 09:04, on Zulip):

@Alice Ryhl that's what I thought also

centril (Apr 26 2019 at 09:04, on Zulip):

if perf.rl.o wants multiple files then it can do that in a different flag

Alice Ryhl (Apr 26 2019 at 09:04, on Zulip):

I thought perf.rl.o specifically didn't want the three files because they were large

centril (Apr 26 2019 at 09:05, on Zulip):

no idea... :D my main point is that a single file for manual is nice

Wesley Wiser (Apr 26 2019 at 09:05, on Zulip):

I guess my feeling right now is that rustc should just have the bare minimum support for this. We can provide a nice wrapper script that optimizes the workflow outside of rustc until we figure out and test that workflow before potentially pushing those changes back into rustc.

centril (Apr 26 2019 at 09:06, on Zulip):

@Wesley Wiser that sgtm; the end result in terms of UX seems to be the same so I can't say I care about impl details ^^

Wesley Wiser (Apr 26 2019 at 09:06, on Zulip):

Ok cool :slight_smile:

Alice Ryhl (Apr 26 2019 at 09:07, on Zulip):

I mean I agree rustc should do as little as possible too. To get one file you might even just concat the files with some length bytes so you can split it again. I just think it seems a bit silly for rustc not to output in the format you'd use manually with the tools

Alice Ryhl (Apr 26 2019 at 09:07, on Zulip):

Although I guess a wrapper is fine too

Amanjeev Sethi (Apr 26 2019 at 13:44, on Zulip):

<realizes that i need to read about these stages of compiler>

lokalmatador (Apr 26 2019 at 14:47, on Zulip):

sorry for the late reply, jsut came home from work: as of planing to work on profiling polonius, I guess I'll also draw back on measureme - @Wesley Wiser recently suggested me to use that. could also provide feedback if wanted

Alice Ryhl (Apr 26 2019 at 15:31, on Zulip):

I'm trying to explain the columns. Can you check if this is correct and help with my TODOs?

Wesley Wiser (Apr 26 2019 at 15:40, on Zulip):

Cache hits

Once a query is executed, it's value is stored in memory in a cache so that if the same query is issued again, the result is simply copied from memory instead of recomputed. This is the number of times that happened.

Blocked time

Yes, this only happens when parallel queries are enabled in the compiler. They are currently disabled by default at build time but this might be changing in the near future. Since you probably have a compiler that has them disabled, these numbers are always 0.

Incremental load time

Not every query's results are persisted to disk. There is a whitelist of queries in the compiler for "important" queries where the cost of loading them from disk (the incremental artifacts in /target/incremental) is less than the cost of recomputing them from scratch. This number is 0 if we don't load anything from the incremental cache for that query. That can happen because the query isn't in the whitelist, the query's arguments have changed and the result in the cache is no longer valid, or because incremental isn't turned on.

Wesley Wiser (Apr 26 2019 at 15:40, on Zulip):

Your descriptions look correct :slight_smile:

Alice Ryhl (Apr 26 2019 at 15:41, on Zulip):

Ahhhh, so Incremental load time is for incremental builds!

Alice Ryhl (Apr 26 2019 at 15:41, on Zulip):

That makes sense

Wesley Wiser (Apr 26 2019 at 15:41, on Zulip):

here is a whitelist of queries in the compiler

That code is here FYI https://github.com/rust-lang/rust/blob/597f432489f12a3f33419daa039ccef11a12c4fd/src/librustc/ty/query/plumbing.rs#L1278-L1293

Alice Ryhl (Apr 26 2019 at 15:44, on Zulip):

When you say 'query', is this some specific terminology specific to rust, such as type inference or something like that?

Wesley Wiser (Apr 26 2019 at 15:45, on Zulip):

Oh sorry

Wesley Wiser (Apr 26 2019 at 15:45, on Zulip):

Yeah, there's a lot of rustc lingo

Alice Ryhl (Apr 26 2019 at 15:45, on Zulip):

So it's a type inference query?

Wesley Wiser (Apr 26 2019 at 15:46, on Zulip):

It's a bit more general than that

Wesley Wiser (Apr 26 2019 at 15:46, on Zulip):

The compiler used to be pass based like many classically architected compilers. There was a parse phase and then the results of that would be type checked and then the results of that would feed into codegen.

Wesley Wiser (Apr 26 2019 at 15:47, on Zulip):

Now, it's "on-demand" driven. So when a part of the compiler needs some piece of data, it creates a query for that. If the result of the query is already known, then that result is reused. Otherwise, that query is executed. Executing that query might trigger other queries and so on.

Wesley Wiser (Apr 26 2019 at 15:47, on Zulip):

There's a lot more info in the rustc-guide about this https://rust-lang.github.io/rustc-guide/query.html

Alice Ryhl (Apr 26 2019 at 15:48, on Zulip):

Well okay, take a look at what we have so far: https://github.com/Darksonn/measureme/tree/master/summarize

Wesley Wiser (Apr 26 2019 at 15:48, on Zulip):

The query system is what makes incremental compilation work.

Alice Ryhl (Apr 26 2019 at 15:49, on Zulip):

So I assume 'Incremental load time' can be thought of as 'Cache hits' but from disk

Wesley Wiser (Apr 26 2019 at 15:49, on Zulip):

Yes, exactly!

Alice Ryhl (Apr 26 2019 at 15:52, on Zulip):

Well okay, since the filtering flag isn't provided yet, I'll delete that section for now

Alice Ryhl (Apr 26 2019 at 15:52, on Zulip):

Any other sections we would want?

Wesley Wiser (Apr 26 2019 at 15:54, on Zulip):

The filtering flag merged last week I believe so it should be available. I don't think we need to mention in this guide though.

Wesley Wiser (Apr 26 2019 at 15:55, on Zulip):

(still reading)

Wesley Wiser (Apr 26 2019 at 15:56, on Zulip):

Oh sorry, you mean the percent filtering

Wesley Wiser (Apr 26 2019 at 15:56, on Zulip):

nvm

Wesley Wiser (Apr 26 2019 at 15:58, on Zulip):

I left a few review comments but this looks awesome!

Alice Ryhl (Apr 26 2019 at 15:58, on Zulip):

Yeah I'll incorporate them shortly

Wesley Wiser (Apr 26 2019 at 15:59, on Zulip):

This looks ready for a PR to me

Alice Ryhl (Apr 26 2019 at 15:59, on Zulip):

Sure

Alice Ryhl (Apr 26 2019 at 16:00, on Zulip):

I'll delete the Using summarize section and PR it?

Alice Ryhl (Apr 26 2019 at 16:00, on Zulip):

I mean there's the --json flag, but maybe just wait with that for other flags to be added

Alice Ryhl (Apr 26 2019 at 16:03, on Zulip):

Should i PR it in a single commit, or add an extra commit so your comments stay in the history?

Alice Ryhl (Apr 26 2019 at 16:16, on Zulip):

@Wesley Wiser

Alice Ryhl (Apr 26 2019 at 16:22, on Zulip):

I'm going to badminton. I'll just make a PR with a single commit.

Alice Ryhl (Apr 26 2019 at 16:23, on Zulip):

https://github.com/rust-lang/measureme/pull/35

Wesley Wiser (Apr 26 2019 at 17:05, on Zulip):

Sorry, was afk

Wesley Wiser (Apr 26 2019 at 17:05, on Zulip):

Single commit is fine. Whatever is easier for you

Wesley Wiser (Apr 26 2019 at 17:05, on Zulip):

Yeah, I'd just remove the Using section for now

Wesley Wiser (Apr 26 2019 at 17:20, on Zulip):

cc @Amanjeev Sethi @Alice Ryhl's PR is ready to try out.

https://github.com/rust-lang/measureme/pull/35

Amanjeev Sethi (Apr 26 2019 at 17:23, on Zulip):

Great will try to get to it asap.

Wesley Wiser (Apr 26 2019 at 17:25, on Zulip):

Thanks! :slight_smile:

Amanjeev Sethi (Apr 26 2019 at 17:38, on Zulip):

Sorry I should have asked here, is it ok to comment on the PR? Or would you rather have me ask things here? @Wesley Wiser @Alice Ryhl

Wesley Wiser (Apr 26 2019 at 17:39, on Zulip):

It will probably be easier to process feedback if you put it on the PR

Wesley Wiser (Apr 26 2019 at 17:39, on Zulip):

But no strong preference

Amanjeev Sethi (Apr 26 2019 at 17:45, on Zulip):

Thanks! I am currently building rustc. I went through the doc for this exercise and it was easy read so thank you @Alice Ryhl :slight_smile:

Just for my clarity -- this is about profiling the compiler itself by compiling a crate (any crate). Right?

Wesley Wiser (Apr 26 2019 at 17:47, on Zulip):

Correct!

Amanjeev Sethi (Apr 26 2019 at 17:49, on Zulip):

lol this stream is called "self-profile". Sorry I think I am having Zulip overload. It is hard to navigate this for me for some reason.

Amanjeev Sethi (Apr 26 2019 at 18:13, on Zulip):

Still compiling. :speechless:

Wesley Wiser (Apr 26 2019 at 18:14, on Zulip):

Yeah, it takes a long time especially the first time when you have to build llvm

Amanjeev Sethi (Apr 26 2019 at 19:00, on Zulip):

Is stage0 toolchain ok? apparently stage0 failed with error error: the option Z is only accepted on the nightly compiler. stage1 works.

Amanjeev Sethi (Apr 26 2019 at 19:07, on Zulip):

ok I was able to do this easily. I have a couple of questions I have added to https://github.com/rust-lang/measureme/pull/35#pullrequestreview-231277668. cc/ @Alice Ryhl

Amanjeev Sethi (Apr 26 2019 at 19:08, on Zulip):

I approved it. :slight_smile:

Wesley Wiser (Apr 26 2019 at 19:09, on Zulip):

FYI, the stage0 compiler is the current stable Rust compiler

Wesley Wiser (Apr 26 2019 at 19:09, on Zulip):

So it doesn't accept -Z options

Wesley Wiser (Apr 26 2019 at 19:10, on Zulip):

stage1 is the first compiler that gets built which has any local changes you've made

Alice Ryhl (Apr 26 2019 at 19:40, on Zulip):

Hey I'm back

Amanjeev Sethi (Apr 26 2019 at 19:44, on Zulip):

:hi:

Amanjeev Sethi (Apr 26 2019 at 19:45, on Zulip):

Let's merge the PR! ? :D

Alice Ryhl (Apr 26 2019 at 19:45, on Zulip):

We're still waiting for michaelwoerister to review it too

Amanjeev Sethi (Apr 26 2019 at 19:46, on Zulip):

Oh sorry

Alice Ryhl (Apr 26 2019 at 19:46, on Zulip):

There's also the other tool stack_collapse

Alice Ryhl (Apr 26 2019 at 19:47, on Zulip):

Does it also need docs? Or perhaps you want to wait for a bit more progress to be made on flame graphs

Wesley Wiser (Apr 26 2019 at 19:48, on Zulip):

@mw doesn't usually review on the weekends so I think they'll probably get to it on Monday.

Alice Ryhl (Apr 26 2019 at 19:48, on Zulip):

Sure

Alice Ryhl (Apr 26 2019 at 19:48, on Zulip):

Perhaps the top-level readme could use some love too

Wesley Wiser (Apr 26 2019 at 19:48, on Zulip):

If you want to write docs for it, go for it!

Wesley Wiser (Apr 26 2019 at 19:49, on Zulip):

That's an idea too

Wesley Wiser (Apr 26 2019 at 19:49, on Zulip):

I'd love to have a section with "here's what this crate does" and "here's the tools we have you can use"

Wesley Wiser (Apr 26 2019 at 19:49, on Zulip):

With links to the tool's readme's

Alice Ryhl (Apr 26 2019 at 19:49, on Zulip):

Sure

Wesley Wiser (Apr 26 2019 at 19:49, on Zulip):

And maybe some pretty pictures or a gif

Alice Ryhl (Apr 26 2019 at 19:50, on Zulip):

Well pretty pictures sounds like the job of flame graphs!

Wesley Wiser (Apr 26 2019 at 19:50, on Zulip):

There's this too https://github.com/rust-lang/measureme/pull/34 :p

Alice Ryhl (Apr 26 2019 at 19:50, on Zulip):

Yeah that's why I commented we might want to wait a bit

Alice Ryhl (Apr 26 2019 at 19:51, on Zulip):

or maybe it wont change much, I dunno

Wesley Wiser (Apr 26 2019 at 19:51, on Zulip):

Probably what we want to do is evolve the docs you've written to be a bit more general: here's how to do a profile of rustc, now here's all the tools you can play with

Alice Ryhl (Apr 26 2019 at 19:52, on Zulip):

Yeah

Alice Ryhl (Apr 26 2019 at 19:52, on Zulip):

I also remember someone mentioning profiling compilation of single files

Wesley Wiser (Apr 26 2019 at 19:52, on Zulip):

Oh, yes

Wesley Wiser (Apr 26 2019 at 19:53, on Zulip):

That's very simple. Instead of doing cargo +toolchain rustc -- -Z self-profile, you just do rustc +toolchain -Z self-profile file.rs

Alice Ryhl (Apr 26 2019 at 19:53, on Zulip):

what about cargo +toolchain rustc -- -Z self-profile file.rs

Wesley Wiser (Apr 26 2019 at 19:53, on Zulip):

If you want something to work on other than docs, there's also issues #31, #32, and #33 that could be worked on.

Alice Ryhl (Apr 26 2019 at 19:54, on Zulip):

I'm not super familiar with the cargo rustc invocation

Wesley Wiser (Apr 26 2019 at 19:54, on Zulip):

Cargo assumes you have a project basically

Wesley Wiser (Apr 26 2019 at 19:54, on Zulip):

cargo build and cargo rustc do the same thing

Alice Ryhl (Apr 26 2019 at 19:54, on Zulip):

fair

Wesley Wiser (Apr 26 2019 at 19:54, on Zulip):

but cargo rustc lets you also pass additional flags to the compiler

Alice Ryhl (Apr 26 2019 at 19:54, on Zulip):

I think your links went to the wrong repo

Wesley Wiser (Apr 26 2019 at 19:55, on Zulip):

You can't do cargo rustc -- file.rs because the compiler will get an invocation that says to build your project and also that file. Which doesn't make any sense

Wesley Wiser (Apr 26 2019 at 19:55, on Zulip):

Oh, hmm. Looks like they all go to rust-lang/rust by default. I wonder if that can be changed

Alice Ryhl (Apr 26 2019 at 19:55, on Zulip):

Well you can manually fix it with a markdown link

Wesley Wiser (Apr 26 2019 at 19:55, on Zulip):
Wesley Wiser (Apr 26 2019 at 19:57, on Zulip):

I guess 31 is not really our issue but it does affect us.

Wesley Wiser (Apr 26 2019 at 19:58, on Zulip):

I have a number of other tasks in my head that could potentially also be worked on as well. If there's interest, I'll take some time this weekend and write them out.

Alice Ryhl (Apr 26 2019 at 19:59, on Zulip):

I'm happy to do some coding too :)

Wesley Wiser (Apr 26 2019 at 19:59, on Zulip):

It's totally up to you. It's your time after all :slight_smile:

Alice Ryhl (Apr 26 2019 at 20:01, on Zulip):

heh, well I've been wanting to do something on rust for a long time, so it's nice to find a nice isolated-ish piece of code that's easy to start with

Wesley Wiser (Apr 26 2019 at 20:01, on Zulip):

Ok cool!

Wesley Wiser (Apr 26 2019 at 20:01, on Zulip):

Do any of those tasks interest you? Or do you have something else in mind?

Alice Ryhl (Apr 26 2019 at 20:02, on Zulip):

Well I think I could do the diff one

Wesley Wiser (Apr 26 2019 at 20:03, on Zulip):

Ok. Let me know if you have any questions or need help.

Wesley Wiser (Apr 26 2019 at 20:03, on Zulip):

You can ping me here or leave github comments on the issue

Wesley Wiser (Apr 26 2019 at 20:04, on Zulip):

I'd also recommend commenting on that issue to say that you're working on it.

Alice Ryhl (Apr 26 2019 at 20:04, on Zulip):

Sure, but it seems relatively straight forward

Alice Ryhl (Apr 26 2019 at 20:04, on Zulip):

I'll do that

Wesley Wiser (Apr 26 2019 at 20:04, on Zulip):

Great!

Wesley Wiser (Apr 26 2019 at 20:04, on Zulip):

Have fun

Alice Ryhl (Apr 26 2019 at 20:14, on Zulip):

I also posted the panic when piped issue to the prettytable repo

Wesley Wiser (Apr 26 2019 at 20:15, on Zulip):

Thanks

Amanjeev Sethi (Apr 27 2019 at 00:49, on Zulip):

Can I try #32? It seems to me that it is about adding an optional cli argument to the summarize so it prunes the table. @Alice Ryhl you can say no given it was opened by you so I am not sure if you are going to work on it yourself). :smile:

Alice Ryhl (Apr 27 2019 at 06:56, on Zulip):

@Amanjeev Sethi go ahead!

Amanjeev Sethi (Apr 27 2019 at 21:36, on Zulip):

So I tried https://github.com/rust-lang/measureme/pull/36. Please review.

Wesley Wiser (Apr 28 2019 at 15:25, on Zulip):

Reviewed. Thanks!

Last update: Nov 17 2019 at 07:00UTC