Comments (2)
I'm working on that here
In contrast with a hash table I want to be able to read it without modifying, which requires borrows; but if a value is borrowed from a hash table and then deleted from it in another thread, the drop() call needs to be deferred until garbage collection.
It's only safe to read (and borrow) from a datastructure like the hashtable while you know the data can't be freed - in this case, that means while a Guard is active. Likewise, it's only safe to call drop during garbage collection since it invalidates the region of memory.
In my mind, this implies that references to values can't escape the hashtable - only copies can, while other read operations would be managed by the table. I'm not ultra-familiar with rust, but there's probably a way to tie the reference life to the life of the guard.
Currently crossbeam only supports freeing memory after the grace period. It seems like it could probably be modified to call destructors
This is pretty simple to do for anything that implements drop -
(if an object is holding on to 20MiB of memory, we want to free it ASAP, not after 64 epochs)
As it stands now, local garbage is freed whenever a pin call believes that it can and global garbage is freed whenever the epoch is advanced. Threads could be more forceful about advancing the epoch - GC thresholds could consider the garbage size so a large value doesn't sit waiting while no epochs advance and a similar method could pressure threads to advance the epoch and clear large data from the global cache.
However, any calls to free/drop must wait until it's safe (two epochs have advanced) and as of now epochs only advance when a call to pin decides to. In this branch, one of the functions I'm adding allows one to force attempts at GC and epoch advancement - if one knowingly unlinks a big object, this function could be called until enough epochs have advanced ( I'm working on the update that returns whether a GC actually ran or not).
I think that intelligent batching of drop/frees is too complicated for now - adding stuff to consider garbage size and allowing the programmer to force advancement is probably good enough for now.
from crossbeam.
One approach to handling such situations is to have the API take a closure as argument, and to pass a borrowed reference to the closure.
from crossbeam.
Related Issues (20)
- Can we avoid to call `try_advance` in some senarios? [crossbeam-epoch] HOT 2
- Epoch memory reclamation algorithm HOT 2
- consider adding `is_disconnected` method to Receiver type HOT 1
- Scaling receiver counter up/down based on demand
- Add the ability to send/recv to/from the OS using polling, `WouldBlock` sys-calls HOT 2
- How to use ArrayQueue with std::thead instead of crossbeam_utils:: thread ::scope ? HOT 1
- Segfault in `crossbeam_channel::flavors::list`
- recv_deadline with past instant is ambiguous HOT 1
- Is there any difference between SeqCst store and SeqCst fence after a Relaxed store? HOT 1
- Consider exposing different flavors of channels using different types. HOT 9
- Overflow evaluation with recursive types and Box HOT 1
- crossbeam-deque has no blocking pop: how do you use it?
- Semantic one-shot channel HOT 3
- Publish new `crossbeam-epoch` with updated `memoffset` HOT 2
- crossbeam_channel::tick delivery_time can support different flavor HOT 4
- what shuld used for AtomicCell or ShardedLock HOT 1
- Cirrus CI no longer supports 32-bit mode on ARM Linux runners
- Always use load(Acquire) for load_consume on Miri/TSan
- Question (epoch): How to avoid Miri to report data race on an `Atomic` pointer? HOT 6
- crossbeam::channel::Receiver::try_recv can block forever if sending thread is blocked HOT 5
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 crossbeam.