-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
Compilation speed #1835
Comments
Hey! Ya know, I've noticed this exact thing now that I've upgraded a project to 0.12. It's on my list to look at first thing next week. Off the top of my head, I am unsure what's going on. |
I'm guessing it's because we kiiinda "modify" the source in a way that cargo interprets as having diffed it...? |
It hangs if LTO is enabled. I usually build an optimized artifact with LTO disabled. I enable LTO only when I really need to release a new version. |
I'm taking a look at it now |
One quick experiment that looks good is for cargo-pgrx to not pass the Immediately after a Thoughts? |
setting LTO to fat will still be overkill, even for release binaries. |
Not passing the --release flag is a good solution. |
@workingjubilee looking at this in some detail this morning brought up the memories of the 4 other ways pgrx has historically solved the schema generation problem. I almost wonder if there's one more iteration here where we don't need the pg_embed.exe at all? Why wouldn't it be possible to From the manpage:
Maybe the "references to variables are always immediately bound" would be a blocker? I know you've put a lot of thought into this stuff too, so just wondering if you went down this path and threw it out? |
This addresses issue #1835 by always compiling the `pgrx_embed_xxx` binary in debug mode. Essentially, `cargo pgrx` now ignores the `--release` or `--profile XXX` arguments when compiling the `pgrx_embed_xxx` binary.
it ultimately results in arbitrary amounts of schema generation code being compiled into the shared object, like debuginfo you can't remove by applying |
we also wouldn't be able to compile these functions without release opts, so LLVM would spend arbitrary amounts of time on each function optimizing a function we don't actually care about optimizing. |
like, I can't see how that's not just reverting #1468 ? |
yeah, those are legit points. #hmm I wonder if we could stash the PGRX_EMBED file into |
this would probably be solved if cargo used content-addressable caching instead of file access times, and cargo is much better-positioned to solve this for us. |
Yeah, it probably effectively be that. Which is definitely not what we want. |
I've always wondered why they do it based on timestamps. Oh well. |
it seems mostly because these two haven't landed: |
The other downside to us compiling the extension code twice is if there's compilation warnings, the user seems them twice. (That's actually part of my normal workflow -- letting the compiler keep up with warnings I want to address later.) We could just redirect the output to /dev/null since we'd have never gotten to the pgrx_embed build if the actual extension compile failed. Thoughts on that? |
which kinds of warnings are you thinking of? I have been wondering if we should be replacing the insides of the non-schema functions with |
Ya know, just compiler warnings like "unused variable" and the like. The general garbage that comes up while writing new code that compiles/runs but ain't finished yet. |
??? As in... all the rest of the code? How on earth would we do that? |
oh, easy. I mean, it wouldn't have 100% coverage, but most of the code is annotated with |
I guess I don't see what that would accomplish? there's more code in an extension crate that our |
sometimes half of something is better than none of it? and: faster compile times? /shrug haven't evaluated it numerically. |
might be simpler to emit |
Oh. That’s a goood idea. I’ll try that now… |
I would have expected this to work, in the extension's
but it does not. Still emits warnings: Using PgConfig("pg16") and `pg_config` from /home/pg/16/bin/pg_config
Building extension with features pg16
Running command "/home/zombodb/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo" "build" "--lib" "--profile" "prof" "--features" "pg16" "--no-default-features" "--message-format=json-render-diagnostics"
warning: constant `foo` is never used
--> xxx/src/lib.rs:184:7
|
184 | const foo: i32 = 42;
| ^^^
|
= note: `#[warn(dead_code)]` on by default
warning: constant `foo` should have an upper case name
--> xxx/src/lib.rs:184:7
|
184 | const foo: i32 = 42;
| ^^^ help: convert the identifier to upper case (notice the capitalization): `FOO`
|
= note: `#[warn(non_upper_case_globals)]` on by default
warning: `xxx` (lib) generated 2 warnings
Finished `prof` profile [optimized + debuginfo] target(s) in 0.14s
Installing extension
Copying control file to /home/pg/16/share/postgresql/extension/xxx.control
Copying shared library to /home/pg/16/lib/postgresql/xxx.so
Discovered 77 SQL entities: 0 schemas (0 unique), 73 functions, 2 types, 0 enums, 2 sqls, 0 ords, 0 hashes, 0 aggregates, 0 triggers
Rebuilding pgrx_embed, in debug mode, for SQL generation with features pg16
warning: constant `foo` is never used
--> xxx/src/lib.rs:184:7
|
184 | const foo: i32 = 42;
| ^^^
|
= note: `#[warn(dead_code)]` on by default
warning: constant `foo` should have an upper case name
--> xxx/src/lib.rs:184:7
|
184 | const foo: i32 = 42;
| ^^^ help: convert the identifier to upper case (notice the capitalization): `FOO`
|
= note: `#[warn(non_upper_case_globals)]` on by default
warning: `xxx` (lib) generated 2 warnings
Compiling xxx v0.9.3 (/home/zombodb/_work/xxx/xxx)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.50s
Writing SQL entities to /home/pg/16/share/postgresql/extension/xxx--0.9.3.sql
Finished installing xxx I also experimented with changing cargo-pgrx to add I'm starting to believe that directive doesn't actually do anything. |
I guess the directive isn't being pushed down to dependencies? Like, I suppose the Oh well. I can live with it. |
Hmm, probably so. |
Closed by #1838. |
If you run "
cargo pgrx run --release
", it takes a long time to compile (as it should).If you run it again, immediately, without making any code changes, it takes a long time. It hangs on this line:
Building [=======================> ] 231/232: pgrx_embed_relevantdb(bin)
I don't think it used to do that prior to 0.12.
I'm using 0.12.1.
The text was updated successfully, but these errors were encountered: