00:03 yewscion left 00:06 topnep left 00:07 topnep joined 00:17 lichtkind left 00:39 yewscion joined 00:43 yewscion left 00:59 yewscion joined 01:03 yewscion left 01:09 stanrifkin joined 01:15 yewscion joined 01:24 yewscion left 01:35 yewscion joined 01:40 oodani left 01:42 oodani joined 01:44 yewscion left 01:50 hulk joined 01:51 kylese left 02:00 yewscion joined 02:04 yewscion left 02:15 hulk left, kylese joined 02:20 yewscion joined 02:27 yewscion left 02:30 yewscion joined 02:35 yewscion left 03:37 stanrifkin_ joined 03:40 stanrifkin left 03:44 yewscion joined 03:45 kylese left 03:47 kylese joined 03:51 yewscion left 04:02 yewscion joined 04:07 yewscion left 04:16 topnep left 04:17 yewscion joined, topnep joined 04:22 Aedil joined, yewscion left, yewscion joined 04:27 yewscion left 04:34 yewscion joined 04:40 yewscion left 04:42 yewscion joined 04:47 yewscion left 05:01 yewscion joined 05:07 yewscion left 05:23 yewscion joined 05:28 yewscion left 05:39 yewscion joined 05:48 yewscion left 06:04 yewscion joined 06:09 yewscion left 07:06 yewscion joined 07:08 samebchase left 07:11 yewscion left 07:16 yewscion joined 07:21 yewscion left 07:32 apac joined 07:45 Guest98 joined 07:53 eseyman left 08:00 derpydoo joined 08:02 snonux left 08:08 yewscion joined 08:13 yewscion left 08:43 snonux joined 08:44 yewscion joined 08:49 yewscion left 09:17 manu_ joined, manu_ is now known as eseyman 09:48 lichtkind joined 10:02 leah2 left, yewscion joined 10:07 yewscion left 10:08 eseyman left 10:12 apac left, yewscion joined 10:16 leah2 joined 10:17 yewscion left 10:33 derpydoo left 10:34 yewscion joined 10:40 yewscion left 10:43 yewscion joined, Sgeo left 10:49 yewscion left 11:01 manu_ joined 11:05 yewscion joined 11:20 yewscion left 11:26 apac joined 11:35 yewscion joined 11:41 yewscion left 11:47 apac left 11:56 yewscion joined 12:01 yewscion left 12:17 yewscion joined 12:22 yewscion left 12:28 yewscion joined 12:33 yewscion left 12:44 yewscion joined 12:54 yewscion left 13:10 yewscion joined 13:18 yewscion left 13:27 yewscion joined 13:31 leah2 left 13:36 yewscion left 13:47 leah2 joined 14:21 oodani left
Voldenet Hm, is field assignment always thread-safe? 14:21
m: class A { has $.b is rw }; class B { has $.n }; my $a = A.new :b(B.new(:1n)); (my @t).push: start { $a.b = B.new(:2n) }; @t.push: start { say $a.b.n }; await @t
camelia 2
Voldenet more specifically my question is whether the above code can read some partial state through `$a.b` 14:22
14:25 oodani joined
Voldenet it works on x86_64, but I'm wondering whether this is guaranteed on every architecture 14:25
14:29 yewscion joined 14:39 yewscion left 14:41 yewscion joined 14:44 manu_ left 14:49 manu_ joined 15:00 yewscion left 15:03 leah2 left 15:16 leah2 joined
timo it's a little more nuanced than that, unfortunately 16:09
just recently i had a fun experience with cache coherency differences on ARM 16:10
it is indeed possible that one thread might see the updated $.b before the contents of the B.new(:2n) have actually made it across 16:12
i mean, the updated $.b pointer
so it might see the pointer point to the correct location where the new instance of B is going to be, but the memory contents of that might actually still be nulled out if you're lucky
i think we do always zero out the nurseries, so it should be either valid memory in there, or zeroes. i'm not actually sure if you can have a situation where like, the header portion of the object is up to date already but the body (if it's on a different cache line) is not up to date 16:14
but x86_64 at least guarantees that the order of changes in memory is consistent even when you're not using atomic operations
the issue i was confronted with was inside moarvm itself, where we were putting together a "program" that was essentially bytecode, so a linear array of instructions and their arguments, and then we were assigning the new address of the bytecode to the "use this program" pointer in a structure, and on arm the pointer update could be seen from other threads while the program itself was not yet fully 16:19
there, leading to "fun" behaviour
16:25 derpydoo joined 16:28 abraxxa-home joined 16:30 abraxxa-home left 16:32 abraxxa-home joined, derpydoo left 16:42 hvxgr left 16:47 yewscion joined 16:57 yewscion left 17:07 lucasb joined
Voldenet I see, so because of relaxed memory ordering on ARM the change is atomic, but order of operations (allocate, fill object, assign pointer) is actually unknown with only one dependency 17:23
Yes, that made me convinced to use lock(:shared)
17:24 yewscion joined
timo a call to the barrier sub could be good enough? 17:27
17:29 yewscion left
Voldenet could be, I'm not sure where I'd need to put it though 17:36
m: class A { has $.b is rw }; class B { has $.n }; my $a = A.new :b(B.new(:1n)); (my @t).push: start { my $b = B.new(:2n); full-barrier; $a.b = $b }; @t.push: start { say $a.b.n }; await @t # probably that would work 17:37
camelia 2
Voldenet it'd be a bit brittle, but definitely faster 17:38
17:45 yewscion joined 17:48 yewscion left 17:56 yewscion joined 18:01 yewscion left 18:12 Sgeo joined 18:15 yewscion joined 18:17 yewscion left, yewscion joined 18:21 yewscion left 18:28 yewscion joined 18:31 yewscion left 18:38 yewscion joined 18:44 yewscion left 18:54 topnep left 18:57 topnep joined 19:00 yewscion joined 19:03 yewscion left 19:11 yewscion joined 19:21 yewscion left 19:22 yewscion joined 19:27 yewscion left 19:33 yewscion joined 19:34 abraxxa-home left 19:38 yewscion left 19:44 yewscion joined 19:46 lucasb left 19:49 yewscion left 19:51 ACfromTX left 20:05 yewscion joined 20:09 yewscion left 20:16 yewscion joined 20:21 yewscion left 20:29 japhb left 20:38 yewscion joined 20:41 yewscion left 20:48 yewscion joined 20:51 japhb joined 20:53 yewscion left 20:54 stanrifkin_ left 21:00 topnep left 21:02 topnep joined 21:10 yewscion joined 21:15 yewscion left 21:17 yewscion joined 21:26 yewscion left 21:43 yewscion joined 21:47 yewscion left 22:04 yewscion joined 22:09 yewscion left 22:58 yewscion joined 23:01 Guest98 left, yewscion left 23:02 yewscion joined 23:06 topnep left 23:07 topnep joined, yewscion left 23:09 yewscion joined 23:14 yewscion left 23:19 yewscion joined 23:24 yewscion left 23:51 yewscion joined 23:57 yewscion left