Conversation
|
#18 is linked to this PR, as if it fixes the issue. But if I understand correctly, the issue is not fixed, right? |
Ah, I thought I had fixed that but now I did for real. |
|
Performance compared to mut-treelist before: After: |
|
This is ready to merge, right? |
|
From my perspective yes although I was hoping for a review from @rmculpepper |
rmculpepper
left a comment
There was a problem hiding this comment.
Gvectors were previously unsynchronized and so not thread-safe. The introduction of unsafe operations makes them potentially memory-unsafe, and we need to make sure gvector operations, even used concurrently, are still memory-safe.
The gv-ensure-space! pattern helps: it means that writes to the vector have enough space, whether or not that vector is actually installed as the gvector's vec field at the end of the operation (eg, because of two racing add operations). I'm worried about the write to n afterwards; in a race, it might point past the end of vec.
I've pointed out a problem in gvector-ref if there is a concurrent call that shrinks the gvector. It also occurs if n is greater than the length of the vector. Other read operations (iteration, for example) might have similar problems, but I haven't checked them all.
If unsafe operations are used, we need to figure out and document invariants and patterns of field updates that actually preserve memory-safety.
Based on the benchmark from PR racket#34, compares gvector operations against mutable treelists across varying vector counts and lengths.
Replace contracts with inline checks and unsafe operations for gvector-ref, gvector-set!, gvector-add!, and in-gvector iteration. Use vec-before-n read ordering for memory safety under concurrent access. Add parallel/concurrent stress tests.
|
@rmculpepper, can you re-review this? |
single-value performance (see Optimizations and benchmarks for gvectors racket#4942).
(taken from Rust's Vector implementation).
vector-extendfrom Addvector-extend. racket#4943.