Comments (19)
Behold!
trait Expression {}
trait ValidGrouping {
type IsAggregate;
}
trait MixedAggregates<Other> {}
trait NonAggregate {}
impl<T> NonAggregate for T where T: ValidGrouping {}
impl<F, Predicate> FilterDsl<Predicate> for SelectStatement<F> where (): Expression + NonAggregate {}
struct SelectStatement<From> {}
trait FilterDsl<Predicate> {}
impl<A, B> ValidGrouping for (A, B)
where
(A, B): ValidGrouping,
(): MixedAggregates<<(A, B) as ValidGrouping>::IsAggregate>,
{
type IsAggregate = ();
}
from rust.
Managed to reduce down to a single 9Mb rs file with no external dependencies, chewing on that for a bit.
from rust.
that's really cool! what tools are you using?
treereduce-rust
to automatically reduce casescargo-expand
to flatten crates into a single file and expand macrosystemd-run
to run rustc on reduction attempts generated bytreereduce-rust
but limit memory usage to a certain amount.
Interestingness criteria for treereduce-rust
is that rustc
gets killed by the memory usage.
Tempted to make something like cargo-flatten
that would behave like cargo-expand
, but change expanded stdlib derives back to #[derive(Clone, Copy, ...)]
form they are usually not interesting and expanded versions require to enable a bunch of nightly features.
Under 20kb now, rerunning it again with "rustc uses over 5Gb" criteria, previous attempt lead to something that uses over 500Mb, but succeeds.
from rust.
and this issue, well,
timeout 1m cargo check
or such will do the trick. Or running this in a docker container with a low memory like 4 GB should make the offending rustc process exit due to a SIGKILL promptly.
from rust.
30ish seconds per check, 6 checks in parallel, 3Mb now. Was down to 700kb at one point but messed up the check so went back to slower/more reliable. My 🥔 PC needs more memory.
Making progress. Some result tomorrow hopefully.
from rust.
does it also reproduce on the latest nightly?
from rust.
Sorry for being unclear. Yes, this also happens in latest nightly rustc 1.80.0-nightly (84b40fc90 2024-05-27)
.
from rust.
This also happens in nightly (not sure how to check the version).
rustc +nightly --version --verbose
from rust.
This has a reproducer, it's just the entire .tar.gz
of a project with, yk, diesel and sqlx, which means it is not minimal by far.
from rust.
rustc +nightly --version --verbose
rustc 1.80.0-nightly (da159eb33 2024-05-28)
binary: rustc
commit-hash: da159eb331b27df528185c616b394bb0e1d2a4bd
commit-date: 2024-05-28
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6
This version still reproduces the issue.
I'm happy to help to try to find a more minimal reproducer, are there any tips on how to do that?
from rust.
the problem is that all the automated ways of doing so require a script that you can run to completion, and this issue, well,
from rust.
Taking a shot in the dark here, but would it be possible to make the script interrupt the compilation process if it ever uses more than some amount of ram?
from rust.
Update: This still happens with the following versions:
rustc 1.81.0-nightly (8337ba918 2024-06-12)
binary: rustc
commit-hash: 8337ba9189de188e2ed417018af2bf17a57d51ac
commit-date: 2024-06-12
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7
rustc 1.79.0 (129f3b996 2024-06-10)
binary: rustc
commit-hash: 129f3b9964af4d4a709d1383930ade12dfe7c081
commit-date: 2024-06-10
host: x86_64-unknown-linux-gnu
release: 1.79.0
LLVM version: 18.1.7
Is there any way I can help debug this issue?
from rust.
Is there any way I can help debug this issue?
Yes. Produce a smaller program that reproduces the rampant memory usage.
from rust.
I've minimized by hand to this Cargo.toml:
[package]
name = "ttrpgs"
version = "0.1.0"
edition = "2021"
[dependencies]
diesel = { version = "2.1.6", features = ["postgres", "chrono"] }
rocket_sync_db_pools = { version = "0.1.0", features = ["diesel_postgres_pool"] }
With this src/main.rs
:
diesel::table! {
language (id) {
id -> Int4,
name -> Varchar,
created_at -> Timestamp,
updated_at -> Timestamp,
}
}
pub struct GameEntry {
pub id: i32,
}
pub struct GameEntryCard {
pub game_entry: GameEntry,
pub languages: Vec<Language>,
}
pub type GameEntryCardDBValue = ();
impl GameEntryCard {
pub fn from_db_result(value: GameEntryCardDBValue) -> Vec<Self> {
loop {}
}
}
pub struct Language {
pub id: i32,
}
use diesel::PgExpressionMethods;
use diesel::QueryDsl;
use diesel::RunQueryDsl;
use rocket_sync_db_pools::{database, diesel};
#[database("ttrpgs")]
pub struct Connection(diesel::PgConnection);
pub async fn details(game: &GameEntryCard, conn: Connection) {
let language_ids = game.languages.iter().map(|x| x.id).collect();
let other_languages = conn
.run(|c| {
language::table
.filter(language::columns::id.is_distinct_from(language_ids))
.load(c)
})
.await.unwrap();
}
fn main() {}
Taking a break for now. This is still very far from minimal because all the type system complexity is in the diesel APIs being used here.
from rust.
A bit smaller - no macro and all traits are explicitly imported
This Cargo.toml
[package]
name = "ttrpgs"
version = "0.1.0"
edition = "2021"
[dependencies]
diesel = { version = "2.1.6", features = ["32-column-tables", "postgres_backend"], default-features = false }
with this body
use diesel::expression::Expression;
use diesel::expression::ValidGrouping;
use diesel::internal::table_macro::FromClause;
use diesel::internal::table_macro::SelectStatement;
use diesel::internal::table_macro::StaticQueryFragmentInstance;
use diesel::query_builder::AsQuery;
use diesel::sql_types::Int4;
use diesel::PgExpressionMethods;
use diesel::QueryDsl;
use diesel::QuerySource;
use diesel::Table;
pub struct table;
impl QuerySource for table {
type FromClause = StaticQueryFragmentInstance<()>;
type DefaultSelection = <Self as Table>::AllColumns;
}
impl AsQuery for table {
type Query = SelectStatement<FromClause<Self>>;
}
impl Table for table {
type AllColumns = (id,);
}
pub struct id;
impl Expression for id {
type SqlType = Int4;
}
impl ValidGrouping<()> for id {}
pub fn run<F, R>(__f: F) -> R {}
pub fn details(languages: &[i32]) {
let language_ids = languages.iter().map(|x| x + 1).collect();
run(|c| table.filter(id.is_distinct_from(language_ids)));
}
from rust.
Night was not very productive due to me messing up some arguments, but it's been running since morning and now is sitting at 900kb as of right now, going down by about 1.5kb every 30 seconds or so.
1000LOC, 40 traits and 24 structs. At this point it can be done by hand I guess but should be done tomorrow either way.
from rust.
that's really cool! what tools are you using?
from rust.
From what I can see it gets stuck inside rustc_trait_selection
going recursively deep and wide
from rust.
Related Issues (20)
- Wrong codegen for simd_select_bitmask on big-endian targets HOT 2
- Mutable reference prevents value from being moved to its current address HOT 2
- Tracking Issue for `XOP` target feature HOT 2
- ICE when type not specificed for static variable (Embassy) HOT 5
- Tracking Issue for AVX512_FP16 intrinsics
- `*x == *y` for trait objects produce move error, so it is not equivalent to `PartialEq::eq(&*x, &*y)` even though the reference says it is HOT 1
- Fix (?) dependency tracking for the metavar span table
- ICE: `Size != Size` HOT 1
- ICE: `associated_item_def_ids: not impl or trait` HOT 1
- Incorrect "closure bodies that contain statements must be surrounded by braces" error in unrelatedly invalid code HOT 1
- rustdoc: support for `async Fn*` trait bounds HOT 1
- rustdoc: support for precise capturing HOT 3
- Use of match ergonomics affect borrow checking HOT 2
- Blanket, recursive impls cause bad compiler suggestions
- Chains of checked_add could get better codegen
- Review of Reference change regarding receivers and object safety HOT 1
- `Hash` implementation for `Path` ignores path separators HOT 4
- rust panic HOT 1
- Decide on Rule 4 variant for match ergonomics HOT 1
- opt-dist: separate dist-build from profiling HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.