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

Investigate performance of exit_after approaches #35

Open
hintron opened this issue Mar 9, 2024 · 5 comments
Open

Investigate performance of exit_after approaches #35

hintron opened this issue Mar 9, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@hintron
Copy link
Owner

hintron commented Mar 9, 2024

There are a few approaches for checking exit_after - I'm curious which one is better.

One way is to match outside the loop first to see if it's set, then if it is, check it inside the loop.

Another way (the current method) is to match inside the loop for existence and do the check at the same time.

I've been trying to do this, but I can't seem to correlate the assembly created by cargo asm with the debugger assembly. The instructions and stack offsets are slightly different, and I'm not sure why.

@hintron hintron added the enhancement New feature or request label Mar 9, 2024
@pacak
Copy link

pacak commented Mar 13, 2024

The instructions and stack offsets are slightly different, and I'm not sure why.

If we are talking about cargo-show-asm - currently it compiles everything with a single codegen unit, if that's a problem - I can try looking into changing that. Recent rustc makes some things a bit easier.

@hintron
Copy link
Owner Author

hintron commented Mar 14, 2024

@pacak Ok, I see now that even though I have the same cargo build profile selected for both the LLDB debugger in VSCode and for cargo-show-asm, when I alternate between the two, they are being rebuilt every time.

E.g. my launch.json file specifies this for the VSCode LLDB plugin:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "RTOS simulator release-with-debug",
            "cargo": {
                "args": [
                    "build",
                    "--profile=release-with-debug",
                    "--bin=emu86rs",
                    "--package=emu86rs"
                ],
                "filter": {
                    "name": "emu86rs",
                    "kind": "bin"
                }
            },
...

and when I launch this debug run it does

Running `cargo build --profile=release-with-debug --bin=emu86rs --package=emu86rs --message-format=json`...
   Compiling emu86rs v0.1.0 (/home/hintron/code/computer-enhance/emu86rs)
    Finished release-with-debug [optimized + debuginfo] target(s) in 11.40s

Afterwards, when I run cargo asm, like so:

cargo asm \
-p emu86rs \
--profile=release-with-debug \
--color \
--rust \
--att \
--lib \
--simplify \
--everything \
> everything.lst

I get

cargo asm -p emu86rs --profile=release-with-debug --color --rust --att --lib --simplify --everything > everything.lst
   Compiling emu86rs v0.1.0 (/home/hintron/code/computer-enhance/emu86rs)
    Finished release-with-debug [optimized + debuginfo] target(s) in 22.74s

What I'm confused about is that they share the same cargo build profile - release-with-debug. Do you know why it forces a rebuild? Is this because of the single codegen unit? What can I do to make these two builds actually match, so that I have assembly with interleaved Rust code that matches what my debugger is running?

Hopefully that makes sense; Thanks for the great tool!

@pacak
Copy link

pacak commented Mar 14, 2024

Currently I pass -Ccodegen-units=1 to rustc to avoid solving the hard problem of figuring out what is the same,
Adding codegen-units = 1 to your profile in Cargo.toml might help for now. I'll take a look at fixing this.

@pacak
Copy link

pacak commented Mar 14, 2024

I'll take a look at fixing this.

That would be nope. Got as far as this pacak/cargo-show-asm#253 - it mostly works when job generates an rlib file and doesn't work with other files. Started this - https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477/1

@hintron
Copy link
Owner Author

hintron commented Mar 15, 2024

Btw setting codegen-units = 1 seems to work - the stack offsets and instructions appear to be 1:1 between the debugger asm and cargo asm. Thanks!

jieyouxu added a commit to jieyouxu/rust that referenced this issue Jun 3, 2024
Show files produced by `--emit foo` in json artifact notifications

Right now it is possible to ask `rustc` to save some intermediate representation into one or more files with `--emit=foo`, but figuring out what exactly was produced is difficult. This pull request adds information about `llvm_ir` and `asm` intermediate files into notifications produced by `--json=artifacts`.

Related discussion: https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477

Motivation - `cargo-show-asm` parses those intermediate files and presents them in a user friendly way, but right now I have to apply some dirty hacks. Hacks make behavior confusing: hintron/computer-enhance#35

This pull request introduces a new behavior: now `rustc` will emit a new artifact notification for every artifact type user asked to `--emit`, for example for `--emit asm` those will include all the `.s` files.

Most users won't notice this behavior, to be affected by it all of the following must hold:
- user must use `rustc` binary directly (when `cargo` invokes `rustc` - it consumes artifact notifications and doesn't emit anything)
- user must specify both `--emit xxx` and `--json artifacts`
- user must refuse to handle unknown artifact types
- user must disable incremental compilation (or deal with it better than cargo does, or use a workaround like `save-temps`) in order not to hit rust-lang#88829 / rust-lang#89149
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 3, 2024
Show files produced by `--emit foo` in json artifact notifications

Right now it is possible to ask `rustc` to save some intermediate representation into one or more files with `--emit=foo`, but figuring out what exactly was produced is difficult. This pull request adds information about `llvm_ir` and `asm` intermediate files into notifications produced by `--json=artifacts`.

Related discussion: https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477

Motivation - `cargo-show-asm` parses those intermediate files and presents them in a user friendly way, but right now I have to apply some dirty hacks. Hacks make behavior confusing: hintron/computer-enhance#35

This pull request introduces a new behavior: now `rustc` will emit a new artifact notification for every artifact type user asked to `--emit`, for example for `--emit asm` those will include all the `.s` files.

Most users won't notice this behavior, to be affected by it all of the following must hold:
- user must use `rustc` binary directly (when `cargo` invokes `rustc` - it consumes artifact notifications and doesn't emit anything)
- user must specify both `--emit xxx` and `--json artifacts`
- user must refuse to handle unknown artifact types
- user must disable incremental compilation (or deal with it better than cargo does, or use a workaround like `save-temps`) in order not to hit rust-lang#88829 / rust-lang#89149
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 3, 2024
Show files produced by `--emit foo` in json artifact notifications

Right now it is possible to ask `rustc` to save some intermediate representation into one or more files with `--emit=foo`, but figuring out what exactly was produced is difficult. This pull request adds information about `llvm_ir` and `asm` intermediate files into notifications produced by `--json=artifacts`.

Related discussion: https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477

Motivation - `cargo-show-asm` parses those intermediate files and presents them in a user friendly way, but right now I have to apply some dirty hacks. Hacks make behavior confusing: hintron/computer-enhance#35

This pull request introduces a new behavior: now `rustc` will emit a new artifact notification for every artifact type user asked to `--emit`, for example for `--emit asm` those will include all the `.s` files.

Most users won't notice this behavior, to be affected by it all of the following must hold:
- user must use `rustc` binary directly (when `cargo` invokes `rustc` - it consumes artifact notifications and doesn't emit anything)
- user must specify both `--emit xxx` and `--json artifacts`
- user must refuse to handle unknown artifact types
- user must disable incremental compilation (or deal with it better than cargo does, or use a workaround like `save-temps`) in order not to hit rust-lang#88829 / rust-lang#89149
bors added a commit to rust-lang-ci/rust that referenced this issue Jun 4, 2024
Show files produced by `--emit foo` in json artifact notifications

Right now it is possible to ask `rustc` to save some intermediate representation into one or more files with `--emit=foo`, but figuring out what exactly was produced is difficult. This pull request adds information about `llvm_ir` and `asm` intermediate files into notifications produced by `--json=artifacts`.

Related discussion: https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477

Motivation - `cargo-show-asm` parses those intermediate files and presents them in a user friendly way, but right now I have to apply some dirty hacks. Hacks make behavior confusing: hintron/computer-enhance#35

This pull request introduces a new behavior: now `rustc` will emit a new artifact notification for every artifact type user asked to `--emit`, for example for `--emit asm` those will include all the `.s` files.

Most users won't notice this behavior, to be affected by it all of the following must hold:
- user must use `rustc` binary directly (when `cargo` invokes `rustc` - it consumes artifact notifications and doesn't emit anything)
- user must specify both `--emit xxx` and `--json artifacts`
- user must refuse to handle unknown artifact types
- user must disable incremental compilation (or deal with it better than cargo does, or use a workaround like `save-temps`) in order not to hit rust-lang#88829 / rust-lang#89149
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Jun 5, 2024
Show files produced by `--emit foo` in json artifact notifications

Right now it is possible to ask `rustc` to save some intermediate representation into one or more files with `--emit=foo`, but figuring out what exactly was produced is difficult. This pull request adds information about `llvm_ir` and `asm` intermediate files into notifications produced by `--json=artifacts`.

Related discussion: https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477

Motivation - `cargo-show-asm` parses those intermediate files and presents them in a user friendly way, but right now I have to apply some dirty hacks. Hacks make behavior confusing: hintron/computer-enhance#35

This pull request introduces a new behavior: now `rustc` will emit a new artifact notification for every artifact type user asked to `--emit`, for example for `--emit asm` those will include all the `.s` files.

Most users won't notice this behavior, to be affected by it all of the following must hold:
- user must use `rustc` binary directly (when `cargo` invokes `rustc` - it consumes artifact notifications and doesn't emit anything)
- user must specify both `--emit xxx` and `--json artifacts`
- user must refuse to handle unknown artifact types
- user must disable incremental compilation (or deal with it better than cargo does, or use a workaround like `save-temps`) in order not to hit #88829 / #89149
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this issue Jun 11, 2024
Show files produced by `--emit foo` in json artifact notifications

Right now it is possible to ask `rustc` to save some intermediate representation into one or more files with `--emit=foo`, but figuring out what exactly was produced is difficult. This pull request adds information about `llvm_ir` and `asm` intermediate files into notifications produced by `--json=artifacts`.

Related discussion: https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477

Motivation - `cargo-show-asm` parses those intermediate files and presents them in a user friendly way, but right now I have to apply some dirty hacks. Hacks make behavior confusing: hintron/computer-enhance#35

This pull request introduces a new behavior: now `rustc` will emit a new artifact notification for every artifact type user asked to `--emit`, for example for `--emit asm` those will include all the `.s` files.

Most users won't notice this behavior, to be affected by it all of the following must hold:
- user must use `rustc` binary directly (when `cargo` invokes `rustc` - it consumes artifact notifications and doesn't emit anything)
- user must specify both `--emit xxx` and `--json artifacts`
- user must refuse to handle unknown artifact types
- user must disable incremental compilation (or deal with it better than cargo does, or use a workaround like `save-temps`) in order not to hit #88829 / #89149
bors added a commit to rust-lang/rust-analyzer that referenced this issue Jun 20, 2024
Show files produced by `--emit foo` in json artifact notifications

Right now it is possible to ask `rustc` to save some intermediate representation into one or more files with `--emit=foo`, but figuring out what exactly was produced is difficult. This pull request adds information about `llvm_ir` and `asm` intermediate files into notifications produced by `--json=artifacts`.

Related discussion: https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477

Motivation - `cargo-show-asm` parses those intermediate files and presents them in a user friendly way, but right now I have to apply some dirty hacks. Hacks make behavior confusing: hintron/computer-enhance#35

This pull request introduces a new behavior: now `rustc` will emit a new artifact notification for every artifact type user asked to `--emit`, for example for `--emit asm` those will include all the `.s` files.

Most users won't notice this behavior, to be affected by it all of the following must hold:
- user must use `rustc` binary directly (when `cargo` invokes `rustc` - it consumes artifact notifications and doesn't emit anything)
- user must specify both `--emit xxx` and `--json artifacts`
- user must refuse to handle unknown artifact types
- user must disable incremental compilation (or deal with it better than cargo does, or use a workaround like `save-temps`) in order not to hit #88829 / #89149
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Jun 28, 2024
Show files produced by `--emit foo` in json artifact notifications

Right now it is possible to ask `rustc` to save some intermediate representation into one or more files with `--emit=foo`, but figuring out what exactly was produced is difficult. This pull request adds information about `llvm_ir` and `asm` intermediate files into notifications produced by `--json=artifacts`.

Related discussion: https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477

Motivation - `cargo-show-asm` parses those intermediate files and presents them in a user friendly way, but right now I have to apply some dirty hacks. Hacks make behavior confusing: hintron/computer-enhance#35

This pull request introduces a new behavior: now `rustc` will emit a new artifact notification for every artifact type user asked to `--emit`, for example for `--emit asm` those will include all the `.s` files.

Most users won't notice this behavior, to be affected by it all of the following must hold:
- user must use `rustc` binary directly (when `cargo` invokes `rustc` - it consumes artifact notifications and doesn't emit anything)
- user must specify both `--emit xxx` and `--json artifacts`
- user must refuse to handle unknown artifact types
- user must disable incremental compilation (or deal with it better than cargo does, or use a workaround like `save-temps`) in order not to hit #88829 / #89149
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants