News for hackers. Stuff that matters.
Re:Dashmap: Fast concurrent HashMap for Rust by BubRoss on Thursday March 26, 2020 @10:11PM (#22699948)
> This is around safe parallel access

I'm not sold that this semantic game is usually worth playing, but here it is pointless. Concurrent access on the same threads or different threads isn't going to break.

> It forces all data that has to be consistent across thread boundaries to be in this one map

Why would it force that? There is no single technique for concurrency or parallelism and that silver bullet line of thinking is a dead end.

Concurrent data structures are an important part of the puzzle, especially maps and queues. Fork join, data flow, message passing, copying, swapping buffers, read only data, etc. the list goes on. If it was simple it wouldn't be a problem.

Re:Dashmap: Fast concurrent HashMap for Rust by jupp0r on Friday March 27, 2020 @12:59AM (#22700530)
> Why would it force that?

Because you don’t get atomic writes across multiple data structures that are each thread safe unless you perform all writes while holding a mutex. If you do that, you don't need data structures to be thread safe on their own.

Re:Dashmap: Fast concurrent HashMap for Rust by mirekrusin on Friday March 27, 2020 @03:28AM (#22700983)
You don't even need to say "atomic across multiple data structures", "atomic across multiple keys" in is enough as it's likely next level of atomicity you'll require after atomics over single keys.

But if you require that you're in this higher level of transactional semantics that hashmaps don't try to solve (you can still use them as building blocks of course).

I think the furthest hashmap api could go is to do: 1. CaS - simple compare-and-swap on single key 2. CaSS - compare-and-swap on one key and set other key + read two keys tuple

Having 2. would be quite powerful already and you could solve a lot of tasks with it.

Fancy locking over key ranges/key expressions would also be interesting but that starts to be more like database, not hashmap anymore.

Re:Dashmap: Fast concurrent HashMap for Rust by viraptor on Friday March 27, 2020 @02:13AM (#22700749)
It depends how you structure your data. It's possible to have one "last pointer" log for example which is updated synchronously and points at new values in multiple structures which are updated independently/optimistically. This has different timing/properties than using a single mutex.
Re:Dashmap: Fast concurrent HashMap for Rust by lcy on Friday March 27, 2020 @02:05AM (#22700724)
> unless you perform all writes while holding a mutex

No. Maybe you are not familiar with the concurrency data structures community. Many techniques are invented and used in concurrency data structures, e.g., intrinsic CPU atomic instructions, like CAS, that make the data structures "lock-free".

CAS: https://en.wikipedia.org/wiki/Compare-and-swap.

Re:Dashmap: Fast concurrent HashMap for Rust by ahupp on Friday March 27, 2020 @02:23AM (#22700777)
From the comment:

> you don’t get atomic writes across multiple data structures

They're saying that lock-free approaches don't help when you have to ensure consistency across multiple datastructures.