wanted: nicer hash-table thread safety policy
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Won't Fix
|
Medium
|
Unassigned |
Bug Description
While our current policy is not unreasonable, it makes doing something elementary -- eliminating strictly unsafe hash-table accesses from a codebase far harder than it should be.
I propose the following:
1. Hash-tables should be synchronized by default, so that portable library code has a prayer of doing the right thing. Code that cannot pay the overhead of synchronization can still request unsychronized tables explicitly.
2. Synchronized hash-tables need to be safe to modify while iteration is happening in another thread.
WITH-LOCKED-
(with-
(or (gethash key table)
(setf (gethash key table) value)))
but that is a user code correctness issue, not a "will this break horribly"-issue as the above points.
description: | updated |
if concurrent access can cause heap corruption and remote (in time) crashes (as opposed to lost/duplicate entires), then ignore the rest.
but i'd say that if the overhead is some +50% or more then please don't make hashtables threadsafe by default.
my reasoning: there are zillions of thread safety issues and concurrent access to hashtables is just one of them. making them fail-safe will not help much, while it gives a performance penalty to all the other code that was written with threads in mind.
there already is a compile time :sb-hash- table-debug to get an sbcl that catches concurrent access for some performance penalty on each access in return.