Comments (6)
cc @lcnr
from rust.
Ofc, I will try to minimize this in the coming hours or days.
from rust.
Slightly smaller:
Reproducer (78 LOC)
use std::sync::{Mutex, Arc, Weak};
use std::collections::HashMap;
pub trait Api: Clone {
type Surface: Surface<A = Self>;
type Buffer: WasmNotSendSync + 'static;
type Texture: WasmNotSendSync + 'static;
type SurfaceTexture: WasmNotSendSync + std::borrow::Borrow<Self::Texture>;
type TextureView: WasmNotSendSync;
type Sampler: WasmNotSendSync;
type QuerySet: WasmNotSendSync;
}
pub trait Surface: WasmNotSendSync {
type A: Api;
}
pub trait WasmNotSendSync: WasmNotSend + WasmNotSync {}
impl<T: WasmNotSend + WasmNotSync> WasmNotSendSync for T {}
pub trait WasmNotSend: Send {}
impl<T: Send> WasmNotSend for T {}
pub trait WasmNotSync: Sync {}
impl<T: Sync> WasmNotSync for T {}
trait HalApi: Api + 'static {}
struct BindGroup<A: HalApi>(Box<Device<A>>);
struct Device<A: HalApi>(LifetimeTracker<A>);
struct LifetimeTracker<A: HalApi>(
Vec<Arc<Texture<A>>>,
ResourceMaps<A>,
Vec<ActiveSubmission<A>>,
);
struct Buffer<A: HalApi>(
A::Buffer,
Arc<Device<A>>,
std::marker::PhantomData<Buffer<A>>,
Mutex<Vec<Weak<BindGroup<A>>>>,
);
struct StagingBuffer<A: HalApi>(
Mutex<Option<A::Buffer>>,
Arc<Device<A>>,
std::marker::PhantomData<StagingBuffer<A>>,
);
struct Texture<A: HalApi>(
Arc<Device<A>>,
std::marker::PhantomData<Texture<A>>,
Mutex<Vec<Weak<TextureView<A>>>>,
Mutex<Vec<Weak<BindGroup<A>>>>,
);
struct TextureView<A: HalApi>(
A::TextureView,
Arc<Texture<A>>,
Arc<Device<A>>,
std::marker::PhantomData<TextureView<A>>,
);
struct Sampler<A: HalApi>(
Option<A::Sampler>,
Arc<Device<A>>,
std::marker::PhantomData<Self>,
);
struct ResourceMaps<A: HalApi>(
HashMap<i32, Arc<Buffer<A>>>,
HashMap<i32, Arc<StagingBuffer<A>>>,
HashMap<i32, Arc<Texture<A>>>,
HashMap<i32, Arc<TextureView<A>>>,
HashMap<i32, Arc<Sampler<A>>>,
HashMap<i32, Arc<BindGroup<A>>>,
HashMap<i32, Arc<A>>,
HashMap<i32, Arc<A>>,
HashMap<i32, Arc<A>>,
HashMap<i32, Arc<A>>,
HashMap<i32, Arc<A>>,
);
struct ActiveSubmission<A: HalApi>(
ResourceMaps<A>,
Vec<Arc<Buffer<A>>>,
Vec<std::marker::PhantomData<A>>,
);
fn main() {
check::<BindGroup<_>>();
fn check<T: WasmNotSync>() {}
}
Even smaller:
Reproducer (61 LOC)
use std::sync::{Mutex, Arc, Weak};
pub trait Api {
type Surface: Surface<A = Self>;
type Buffer: WasmNotSendSync + 'static;
type Texture: WasmNotSendSync + 'static;
type SurfaceTexture: WasmNotSendSync + std::borrow::Borrow<Self::Texture>;
type TextureView: WasmNotSendSync;
type Sampler: WasmNotSendSync;
type QuerySet: WasmNotSendSync;
}
pub trait Surface: WasmNotSendSync {
type A: Api;
}
pub trait WasmNotSendSync: WasmNotSend + WasmNotSync {}
impl<T: WasmNotSend + WasmNotSync> WasmNotSendSync for T {}
pub trait WasmNotSend: Send {}
impl<T: Send> WasmNotSend for T {}
pub trait WasmNotSync: Sync {}
impl<T: Sync> WasmNotSync for T {}
trait HalApi: Api {}
struct BindGroup<A: HalApi>(Box<Device<A>>);
struct Device<A: HalApi>(ResourceMaps<A>);
struct Buffer<A: HalApi>(
A::Buffer,
Arc<Device<A>>,
std::marker::PhantomData<Buffer<A>>,
Mutex<Vec<Weak<BindGroup<A>>>>,
);
struct StagingBuffer<A: HalApi>(
Mutex<Option<A::Buffer>>,
Arc<Device<A>>,
std::marker::PhantomData<StagingBuffer<A>>,
);
struct Texture<A: HalApi>(
Arc<Device<A>>,
std::marker::PhantomData<Texture<A>>,
Mutex<Vec<Weak<TextureView<A>>>>,
Mutex<Vec<Weak<BindGroup<A>>>>,
);
struct TextureView<A: HalApi>(
A::TextureView,
Arc<Texture<A>>,
Arc<Device<A>>,
std::marker::PhantomData<TextureView<A>>,
);
struct Sampler<A: HalApi>(
Option<A::Sampler>,
Arc<Device<A>>,
std::marker::PhantomData<Self>,
);
struct ResourceMaps<A: HalApi>(
Arc<Buffer<A>>,
Arc<StagingBuffer<A>>,
Arc<TextureView<A>>,
Arc<Sampler<A>>,
Arc<BindGroup<A>>,
);
fn main() {
check::<BindGroup<_>>();
fn check<T: WasmNotSync>() {}
}
from rust.
"Even smaller" (no longer I-hang but still I-compiletime (32.31s on my machine) + I-compilemem (9GB+)):
"Reproducer" (53 LOC)
use std::sync::{Mutex, Arc, Weak};
pub trait HalApi {
type Surface: Surface<A = Self>;
type Buffer: WasmNotSendSync;
type Texture: WasmNotSendSync ;
type SurfaceTexture: WasmNotSendSync;
type TextureView: WasmNotSendSync;
type Sampler: WasmNotSendSync;
}
pub trait Surface: WasmNotSendSync {
type A: HalApi;
}
pub trait WasmNotSendSync: WasmNotSend + WasmNotSync {}
impl<T: WasmNotSend + WasmNotSync> WasmNotSendSync for T {}
pub trait WasmNotSend: Send {}
impl<T: Send> WasmNotSend for T {}
pub trait WasmNotSync: Sync {}
impl<T: Sync> WasmNotSync for T {}
struct BindGroup<A: HalApi>(Box<Device<A>>);
struct Device<A: HalApi>(ResourceMaps<A>);
struct Buffer<A: HalApi>(
A::Buffer,
Arc<Device<A>>,
std::marker::PhantomData<Buffer<A>>,
Mutex<Vec<Weak<BindGroup<A>>>>,
);
struct Texture<A: HalApi>(
Arc<Device<A>>,
std::marker::PhantomData<Texture<A>>,
Mutex<Vec<Weak<TextureView<A>>>>,
Mutex<Vec<Weak<BindGroup<A>>>>,
);
struct TextureView<A: HalApi>(
A::TextureView,
Arc<Texture<A>>,
Arc<Device<A>>,
std::marker::PhantomData<TextureView<A>>,
);
struct Sampler<A: HalApi>(
Option<A::Sampler>,
Arc<Device<A>>,
std::marker::PhantomData<Self>,
);
struct ResourceMaps<A: HalApi>(
Arc<Buffer<A>>,
Arc<TextureView<A>>,
Arc<Sampler<A>>,
Arc<BindGroup<A>>,
);
fn main() {
check::<BindGroup<_>>();
fn check<T: WasmNotSync>() {}
}
Minimization is prone to distortion (at least with the way I was just pursuing). Stopping right now, will pick it up some other time and will try different approaches that are less aggressive.
from rust.
(Replacing
I-hang
from rust.
should be fixed by #125981
from rust.
Related Issues (20)
- recommending the wrong Arbitrary
- Complete tier 3 target information HOT 12
- Inappropriate `unused_parens` for inline `const` inside `vec!`/macros HOT 1
- Inline `const` expression inside `vec!`/macros should suggest adding parentheses under edition <2024 HOT 2
- ICE: layout: :evergreen_tree: : `Size != Size` HOT 5
- Running run-make tests performs unnecessary rebuilds HOT 7
- this function depends on never type fallback being `()` HOT 9
- please update src/stage0 for beta branch HOT 3
- An unused output of some macros in std (e.g., `format!()`) should produce a unused_must_use warning.
- Tracking Issue for async drop codegen HOT 1
- Error tainting in parallel compiler HOT 2
- Cargo check internal error (using UOM library) HOT 5
- document for E0502 insufficiently general
- "deny" lints are ignored in macro expansion HOT 1
- Trait bound order-dependent type errors using non_lifetime_binders HOT 1
- ICE: incr: `no entry found for key` HOT 4
- Compiler hangs on recursive HRTB HOT 2
- Regression between nightlies with `-Zpolonius` HOT 5
- ICE: `assertion failed: matches!(diagnostic.level, Error | Warning | Allow)` HOT 2
- "rustc-LLVM ERROR: underestimated function size" on thumbv6m-none-eabi HOT 7
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.