freenode/#clim - IRC Chatlog
Search
7:28:00
jackdaniel
I've pinpointed the second piece of race condition - with-drawing-options mutates medium temporarily, but gs-*-mixin read medium options during its initialization. I'll need to think how to handle this gracefully
7:29:29
jackdaniel
two things come to my mind: either provide lock on medium access (like I did in my wip for output-streams), or provide extra-slots in medium preserving original value (so with-drawing-options doesn't mutate slots which are read)
7:30:03
jackdaniel
most noticable example of such race condition is corrupted clipping-region for output-records
7:31:23
jackdaniel
taking lock may be cheap, but that halts other agents who wait for a lock. lock-free access may be a big win here
7:33:45
jackdaniel
I'll sit on it in a few days again, I'll try to avoid lock over medium access unless I can't
7:33:47
beach
Then don't hesitate using locks. The processor may be able to elide most of them anyway, at least in a future where our Common Lisp implementations take advantage of that.
7:34:40
jackdaniel
with-drawing-options is usually wrapped around drawing, which paints pixels and I don't think we can narrow it more
7:35:01
jackdaniel
so these locks will be expensive. If we can't avoid them, that won't be tragedy though to have them
7:35:37
beach
Like I said, as long as you don't lock around a single pixel being drawn, it should be fine.
7:38:32
jackdaniel
I think I don't get your argument here (wrt lock being cheap if you lock entire window): let's say 99% time is window drawing (after one or more output-records is added), and adding output-record is 1% (hypotetically). If the lock is shared between window-drawing and adding output-record, then you add output-record, window is redrawn and adding another output-record must wait 99x more time than it could
7:42:41
beach
My argument is that if locking is for drawing pixels, then drawing pixels will take way more time than the lock. Adding an output record is cheaper of course, so the lock will cost more, relatively speaking. But you get into some very complicated logic if you want to permit drawing and adding output records at the same time. You would have to keep track of what output records have been drawn and then not moved.
7:44:48
jackdaniel
yes, I consider locking free as is, I just don't want to synchronize too much. If logic gets to complicated I will simply add lock, yes
7:45:09
beach
Anyway, there is a simple way to determine the result. Do the simplest thing and profile.