ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
<scientes>
the only reason it can't be in the set at the same time is because we are using EPOLLONESHOT
<scientes>
in which you have to re-arm the epollfd
<andrewrk>
that's necessary so that only one thread from the pool receives the coroutine handle
<andrewrk>
that's where the multiplexing happens
<scientes>
so co-routines introduce that limitation
<andrewrk>
what's the limitation? what alternative are you comparing it to?
<scientes>
you can only do one event at a time for one fd
<scientes>
oh, i guess that is the case anyways
<scientes>
because of the way fds work
<scientes>
yeah this co-routine stuff is really complicated
<scientes>
i can think about threads, but havn't quite wrapped my mind around co-routines
<andrewrk>
it gets complicated to implement, but once the pieces are in place, the API is easy to reason about
<andrewrk>
I want to make it more explicit where the coroutine frame memory goes though
<scientes>
I'm still more confortable with a go threading model, where everything feels like a thread
<andrewrk>
it's suboptimal
<scientes>
There is a leak where the `coroutine_handle` is never resumed, because it is no longer in the epoll set.
<andrewrk>
in order for it to leave the epoll set it would have to get resumed, or the code removing it will cancel the coroutine
<scientes>
I don't think you have it figured out either
<scientes>
but i won't understand it until i understand await fully
<andrewrk>
the docs on each functions tells if it is thread safe
noonien has quit [Quit: Connection closed for inactivity]
clownpriest has quit [Quit: clownpriest]
clownpriest has joined #zig
<andrewrk>
hmm should we remove @maxValue? since it can be implemented in userland
<MajorLag>
Makes sense to me.
<andrewrk>
MajorLag, I think your second test on 906 is a bug
<MajorLag>
And here I was pretty convinced it wouldn't be.
<MajorLag>
Because a lot of the things I blamed on 906 went away when I started tagging functions as `comptime` at the callsite.
<andrewrk>
yeah it fixes it if you put `comptime isSliceType(FieldType)`
<andrewrk>
but it should work without that
<MajorLag>
Interesting. I've taken to tagging all trait.zig calls comptime at the callsite due to issues like this. If this is a bug and it gets fixed maybe I can stop doing that. It'd make it a little nicer.
<MajorLag>
yeah, that'd probably help. Even when I wrap the entire function body in a comptime block it isn't enough.
<andrewrk>
I think I see the problem
<andrewrk>
this is a really good test case
<andrewrk>
ok so count is a comptime var right
<andrewrk>
this means that every store to count must be a comptime known value, and every load from count must be to a comptime value
<andrewrk>
however the expression `isSliceType(FieldType)` is a runtime known value
<andrewrk>
and so when we do `if (isSliceType(FieldType)) count += 1`, there's a load and store with a comptime value *inside a runtime branch*
<andrewrk>
this is unsound, so there should be a compile error for it, but there is not
<andrewrk>
in other words we need to do count += 1 at comptime, but we're actually doing it at runtime. that should be impossible
<andrewrk>
it actually fixes the test case if you remove `comptime` from `var count = usize(0)`
<MajorLag>
I didn't think type was ever a thing that actually existed at runtime.
<andrewrk>
it's not - FieldType is a comptime value
<andrewrk>
but isSliceType returns a bool
clownpriest has quit [Quit: clownpriest]
<MajorLag>
Which is effectively a constant. But if I understand what you're saying, then because optimization hasn't happend yet any code that is conditionally run based on that value still exists and is evaluated?
<MajorLag>
At least, that's the problem in the first test case?
<andrewrk>
correct
<andrewrk>
imagine that every block of code is colored red for comptime or blue for runtime. count += 1 must happen in a red block, but it's happening in a blue block
<andrewrk>
but if you remove `comptime` from `comptime var count ...` then it can happen in a red or blue block
<andrewrk>
`inline` on a `for` turns the `for` from blue to red
<MajorLag>
Ultimately it was the same issue then, which is my failure to understand that the return of an fn(type) is not necessarily red, even if `type` must be, which is why count is marked comptime. It just happened that I also stumbled on a legit bug.
<andrewrk>
here's a simple example of that kidn of function: var global: usize = 0; fn foo(comptime T: type) { global += @sizeOf(T); }
<andrewrk>
throw a correct return type and `return global` in there
clownpriest has joined #zig
clownpriest has quit [Quit: clownpriest]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
reductum has joined #zig
_whitelogger has joined #zig
clownpriest has quit [Quit: clownpriest]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
clownpriest has quit [Client Quit]
clownpriest has joined #zig
_whitelogger has joined #zig
<andrewrk>
MajorLag, I think I changed my mind about whether this is a bug
dbandstra has quit [Quit: Leaving]
ManDeJan has quit [Ping timeout: 244 seconds]
reductum has quit [Quit: WeeChat 2.2]
ManDeJan has joined #zig
scientes has quit [Ping timeout: 276 seconds]
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
bheads has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
noonien has joined #zig
davr0s has joined #zig
clownpriest has quit [Ping timeout: 272 seconds]
clownpriest has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<andrewrk>
zyzzy, looks like you need to add --library c to your build command
<andrewrk>
since you are depending on the c allocator
<zyzzy>
Ah, I missed that. Thanks, that works.
<andrewrk>
I think we can make that automatic in the future, or at least a direct error that tells you what you need to do
ManDeJan has quit [Remote host closed the connection]
jzelinskie has joined #zig
davr0s has joined #zig
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
wilsonk has quit [Read error: Connection reset by peer]
wilsonk has joined #zig
kristate has joined #zig
clownpri1 has joined #zig
clownpri2 has joined #zig
clownpriest has quit [Ping timeout: 252 seconds]
clownpri1 has quit [Ping timeout: 240 seconds]
davr0s has joined #zig
zyzzy has quit [Ping timeout: 252 seconds]
kristate has quit [Ping timeout: 245 seconds]
clownpri2 is now known as clownpriest
davr0s has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
davr0s has joined #zig
mahmudov has joined #zig
clownpri1 has joined #zig
clownpri1 has quit [Client Quit]
clownpriest has quit [Ping timeout: 252 seconds]
<MajorLag>
andrewrk, if I understand your reponse in #906 correctly, then the fact that isSliceType returns a runtime value causes both branches to be analyzed, and because `count` is a comptime var `count += 1` takes effect when it is analyzed. If I replace `isSliceType` with `false`, however, I get the expected result of 0 since `false` is known to be constant during the analysis. If I replace the guts of `isSliceType` with `return false` the origi
<MajorLag>
al behavior returns because the result of `isSliceType`, though known at compile time, is not known during the analysis of `countSliceMembers`. Is this a correct understanding?
<andrewrk>
MajorLag, the first part is correct
<andrewrk>
if you replace the guts of `isSliceType` with `return false` I don't think that changes anything
<MajorLag>
Right, it behaves identically to the original test.
<andrewrk>
because at the callsite of isSliceType, the result is a runtime value
<andrewrk>
I'm going to experiment with a new compile error that would take effect for 906 and see if it breaks anything in std