j4n bur53 schrieb:
> - Better Scalability:
> We could eleminate locking here and then completely (static
> predicates, predicate meta-information). In other cases we
> replaced simple mutex locks by read-write pair locks (dynamic
> predicates, multi-file predicates and source files). Not
> only multi-threaded code profits from these optimizations,
> but also single-threaded code.
Technical Note: In contrast to SWI-Prolog, we didn't
invest in concurrent data stuctures (which are good
for many read and many writes requests).
We only invested in read-write locks (which are good
for many reads and few write requests).
Strangely, although SWI-Prolog has some concurrent
data structures awailable, it still uses simple mutexes
here and then, for example erase/1 predicate.
In our case the erase/1 predicate now also uses a
read-write lock. But only if the predicate is dynamic
or (unfortunately)(*) multi-file.
No locks are used by erase/1 in case of a thread-local
predicate, this was already the case before this new
release. This new release only deals with the non-thread-
local predicates.
Bye
(*)
Since multi-file predicates can be loaded by multiple
threads, otherwise they wouldn't be multi-file predicates,
we were forced to apply some locking to them as if they were
dynamic predicates.
We were not able to handle multifile predicates, even the
static ones, as if they were static predicates. i.e. omit
the locking completely. (**)
This is very unfortunate, for example our CLP(FD) makes
heavy use of multi-file predicates, this approach is used
in the hypothetical reasoner, so that we don't see very
good scalability there yet.
(**)
Omitting the locking completely is a little bit tricky.
We us an inline cache, which is nearly a concurrent data
structure. Its a concurrent data structure which has some
redundant idempotent operations.
This also happens when a looking-up the clauses of a
predicate occurs, and some index is generated for the first
time, it can happend that accidentially two or more threads
will generate the same index concurrently.
Correctness is not affected by this, only performance
degrades a little bit. But other more complex solutions,
such as reevaluating locks, could avoid this
double work.
But I guess the more complicated solution is not needed,
since the occurence of double work is possibly very rare.
I have not yet hold of figures measuring this double
work effect and supporting my claim.