perf(sqlx-cli): avoid rewriting the entire .sqlx cache on prepare#4237
perf(sqlx-cli): avoid rewriting the entire .sqlx cache on prepare#4237fhsgoncalves wants to merge 1 commit intolaunchbadge:mainfrom
Conversation
…nd add or update when needed
ba5071a to
eafb17c
Compare
jplatte
left a comment
There was a problem hiding this comment.
Why does the commit message say perf? This doesn't actually help performance in any way, right?
|
|
||
| let prepare_dir = ctx.prepare_dir()?; | ||
| run_prepare_step(ctx, &prepare_dir)?; | ||
| let cache_dir = ctx.metadata.target_directory().join("sqlx-prepare"); |
There was a problem hiding this comment.
I think this should probably be a subdirectory of .sqlx instead, to avoid any cross-filesystem copying in case target is a symlink to a different fs. Maybe .sqlx/staging? You could put a .gitignore in .sqlx automatically to not have it tracked by git (though maybe this would be annoying for people on other version control systems?).
There was a problem hiding this comment.
Hm, do we already have this kind of temporary folder somewhere here in sqlx?
Using .sqlx looks weird for me, since it is a folder to be versioned, and may impact people not using git indeed, or already having an own custom .gitignore inside .sqlx/ folder.
About using the target directory: why that would be an issue with cross-filesystem copying? It should work, right?
There was a problem hiding this comment.
Cross-fs copies are slower and more error-prone because they're not atomic. I could see things breaking if in parallel with sqlx prepare, rust-analyzer executes one of the macros or something.
It is because the dev-loop when using |
|
I'm not actually a maintainer, so I can't make any definitive statements about commit message style. Was just asking out of curiosity. |
Does your PR solve an issue?
N/A (no issue filed).
Is this a breaking change?
No.
Summary
query-*.jsonfiles in.sqlxon everycargo sqlx prepare.sqlxMotivation: I'm working on a large monorepo, with ~1500 sqlx cached query files, and every time I run
cargo sqlx prepare --workspace, it deletes all the cached files, the IDE/lsp shows lots of compilation errors, and I need to wait several seconds (sometimes minutes) to have all the files back. This PR fixes that