Comments (3)
Turns out this was an issue in event-listener
: smol-rs/event-listener@3142ee7
Event
has a built-in mechanism for delayed construction. However, when Sender
or Receiver
is dropped, the channel becomes closed. Closing notifies all Event
s and their listeners. The problem here is that notifying would initialize Event
s, which is pretty expensive. But there's no point in initializing when notifying! If Event
is uninitialized when notified, that means there are no EventListener
s to notify. :)
Updating to event-listener
v2.3.1 brings construction of a channel from ~1000ns to ~250ns on my 2020 macbook pro.
from async-channel.
That is certainly a little steep, I would expect 5x smaller numbers... If you're never actually using channels that's a big price to pay just for channel construction + destruction. Anyways, regarding channel construction:
bounded::<T>(n)
allocates something like[(T, usize); n]
on the heapunbounded::<T>()
allocates something like[(T, usize; 32]
on the heap
I think those allocations could certainly be delayed, it'd just be a bit of work :)
from async-channel.
For comparison, a ConcurrentQueue is ~200ns to create and destroy on the same box, so I was a bit surprised by this. I'll take a look at some point, but it's pretty low priority right now.
from async-channel.
Related Issues (20)
- Overflow mode HOT 3
- Bounded channel fully deadlocked when sender is forgotten HOT 4
- depends needlessly on `blocking`
- Published async-channel 1.7.0 failed to compile on MSRV HOT 1
- Release with concurrent-queue 2.0.0 support HOT 3
- awaited receiver is not awoken when messaged send into channel HOT 6
- Cancel safety for channels HOT 1
- Document why we notify all streams when sending a single message
- Add zero capacity bounded channel HOT 3
- This crate works with WebAssembly (WASM) 🚀 HOT 1
- `no_std` support HOT 1
- async_channel::Receiver::poll_next can not be used because Receiver is unpinnable HOT 2
- Add force_send method to bounded channel HOT 1
- Allow blocking channels in wasm HOT 5
- mpmc and mpmc_stream tests fail once and then never again
- `Recv` can lock on dropping HOT 4
- Add MIRI to CI HOT 1
- Sending cancel safety HOT 1
- Async-channel 2.3.0 fails to compile with concurrent-queue below 2.5.0
- async channel does not compile for me. HOT 1
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 async-channel.