ChanServ changed the topic of #zig to: zig programming language | https://ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
<scientes> *locks between processes
<daurnimator> the downside (which you already figured out I think) is that you can only have a single robust mutex handler per *process*
<daurnimator> and usually libc takes it
<scientes> daurnimator, no, per thread
<scientes> you are wrong
<daurnimator> ah yes
<daurnimator> but yes; prefer eventfd over futexes where possible.
<daurnimator> it does wonders for the more-common-than-anyone-thinks use case of "wait on mutex or stdin or socket"
<wrl> i did tests some time ago to see if eventfd was any slower than non-composable signalling primitives (basically, futex and anything on top of it)
<wrl> but i tested in the blocking case
<wrl> i'm sure in the case where the futex is elided completely they're faster
<wrl> but in the blocking case eventfd is no faster or slower than anything else
<wrl> pipes are the slowest
<wrl> everything else is pretty much... couple hundred nanoseconds for wakeup
<wrl> i forget what the speed tests were but i think it was to test how fast the write side was
<wrl> actually, hah, looks like andrewrk wrote the futex test code :)
<wrl> i thought i remembered that
jjido_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<daurnimator> wrl: got results published anywhere?
<wrl> daurnimator: nothing handy on this computer
<wrl> run it yourself and let me know :)
<wrl> the latency test is more generally interesting
<wrl> it spins up a bunch of thread pairs, one sender and one receiver
<wrl> the sender sleeps for an interval, gets the current system time (clock_gettime(CLOCK_MONOTONIC)), and sends that time to the receiver
<wrl> the receiver, waiting on a sync primitive, wakes up, gets the current system time (again, CLOCK_MONOTONIC) and logs the difference
<wrl> each sender has a static wait time, configured in test_params.h
<daurnimator> wrl: okay ran them
<daurnimator> yep eventfd won
<wrl> daurnimator: yeah makes sense
<wrl> i mean honestly i wasn't even interested in seeing if there was a winner
<wrl> eventfd being composable is a huge advantage over the futex-based primitives
<wrl> so i just wanted to see if it were any slower as a result
<wrl> as it turns out, no
<daurnimator> wrl: as much as I prefer eventfd; they both have things the other doesn't
<daurnimator> wrl: e.g. futexes can do priority inheritence to avoid priority inversion
<daurnimator> my preference is eventfd by default; futexes where you need specific functionality that is unavailable otherwise
<wrl> ah, good point yeah
<wrl> daurnimator: i like structuring things in a loose actor pattern, where actors listen on both a mailbox from other actors and also whatever else they need to (sockets, inotify, window system events, etc)
nore has quit [Ping timeout: 252 seconds]
nore has joined #zig
knebulae has quit [Quit: Leaving]
slipyx has joined #zig
marmotini_ has joined #zig
THFKA4 has quit [Quit: WeeChat 2.3]
scientes has quit [Ping timeout: 246 seconds]
xtreak has joined #zig
xtreak has quit [Remote host closed the connection]
xtreak has joined #zig
marmotini_ has quit [Ping timeout: 245 seconds]
marmotini has joined #zig
Hejsil has joined #zig
<Hejsil> andrewrk, so if all string literals will be `*const [N]null u8`, then I'd assume that all `var a = "abc"` should be turned into `var a = "abc".*` correct?
jjido_ has joined #zig
marmotini_ has joined #zig
marmotini has quit [Ping timeout: 250 seconds]
jjido_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
marmotini has joined #zig
marmotini_ has quit [Ping timeout: 268 seconds]
marmotini_ has joined #zig
marmotini has quit [Ping timeout: 246 seconds]
marmotini has joined #zig
marmotini_ has quit [Ping timeout: 245 seconds]
xtreak has quit [Remote host closed the connection]
marmotini has quit [Ping timeout: 245 seconds]
marmotini_ has joined #zig
marmotini has joined #zig
marmotini_ has quit [Ping timeout: 250 seconds]
marmotini_ has joined #zig
marmotini has quit [Ping timeout: 255 seconds]
xtreak has joined #zig
neceve has joined #zig
marmotini_ has quit [Ping timeout: 244 seconds]
marmotini_ has joined #zig
marmotini_ has quit [Ping timeout: 246 seconds]
marmotini has joined #zig
forgot-password has joined #zig
<forgot-password> Hey guys, I just updated to the latest zig build, but when trying to build a recent project I now get an error about std.build.Builder.addCommand. Has the API changed?
shritesh has quit []
<Hejsil> forgot-password, seems there was two changes. addCommand was replaced with addSystemCommand, and LibExeObjStep got a `run` function
<forgot-password> Hejsil: Thanks, it seems like addSystemCommand now only takes 2 arguments instead of 4
<forgot-password> Got it, I just generated a new project via init-exe and did some copying ;)
<forgot-password> Thank you
marmotini has quit [Ping timeout: 255 seconds]
marmotini has joined #zig
marmotini_ has joined #zig
marmotini has quit [Ping timeout: 268 seconds]
marmotini has joined #zig
marmotini_ has quit [Ping timeout: 250 seconds]
xtreak has quit [Read error: Connection reset by peer]
xtreak has joined #zig
marmotini_ has joined #zig
marmotini has quit [Ping timeout: 250 seconds]
forgot-password has quit [Quit: leaving]
marmotini has joined #zig
marmotini_ has quit [Ping timeout: 272 seconds]
marmotini_ has joined #zig
marmotini has quit [Ping timeout: 246 seconds]
marmotini has joined #zig
marmotini_ has quit [Ping timeout: 250 seconds]
marmotini_ has joined #zig
marmotini has quit [Ping timeout: 250 seconds]
jjido has quit [Quit: Connection closed for inactivity]
marmotini_ has quit [Ping timeout: 245 seconds]
marmotini_ has joined #zig
xtreak has quit [Remote host closed the connection]
xtreak has joined #zig
marmotini has joined #zig
marmotini_ has quit [Ping timeout: 250 seconds]
scientes has joined #zig
marmotini_ has joined #zig
marmotini has quit [Ping timeout: 245 seconds]
xtreak_ has joined #zig
marmotini has joined #zig
xtreak has quit [Ping timeout: 250 seconds]
marmotini_ has quit [Ping timeout: 250 seconds]
marmotini_ has joined #zig
marmotini has quit [Ping timeout: 250 seconds]
marmotini has joined #zig
marmotini_ has quit [Ping timeout: 255 seconds]
xtreak_ has quit [Remote host closed the connection]
marmotini has quit [Ping timeout: 244 seconds]
marmotini_ has joined #zig
marmotini has joined #zig
marmotini_ has quit [Ping timeout: 244 seconds]
marmotini has quit [Remote host closed the connection]
marmotini_ has joined #zig
xtreak has joined #zig
scientes has quit [Remote host closed the connection]
scientes has joined #zig
marmotini_ has quit [Ping timeout: 255 seconds]
marmotini_ has joined #zig
marmotini has joined #zig
marmotini_ has quit [Ping timeout: 272 seconds]
marmotini_ has joined #zig
hg has joined #zig
marmotini has quit [Ping timeout: 272 seconds]
xtreak has quit []
allochi has joined #zig
Hejsil has quit [Quit: Page closed]
fengb_ has joined #zig
fengb has joined #zig
fengb has quit [Client Quit]
dirkson has quit [Quit: Cheers!]
marmotini has joined #zig
marmotini_ has quit [Ping timeout: 244 seconds]
nullheroes has quit [Quit: WeeChat 2.3]
allochi has quit [Quit: Page closed]
marmotini_ has joined #zig
marmotini has quit [Ping timeout: 246 seconds]
wilsonk has quit [Ping timeout: 245 seconds]
marmotini has joined #zig
marmotini_ has quit [Remote host closed the connection]
marmotini_ has joined #zig
marmotini has quit [Remote host closed the connection]
MajorLag has joined #zig
neceve has quit [Read error: Connection reset by peer]
tgschultz has quit [Ping timeout: 250 seconds]
MajorLag is now known as tgschultz
oats is now known as butt
butt is now known as oats
marmotini has joined #zig
marmotini_ has quit [Ping timeout: 246 seconds]
wilsonk has joined #zig
develonepi3 has quit [Quit: Leaving]
fsateler_ has quit [Ping timeout: 246 seconds]
Ichorio has joined #zig
<andrewrk> yes Hejsil
wilsonk has quit [Ping timeout: 250 seconds]
wilsonk has joined #zig
wilsonk has quit [Ping timeout: 245 seconds]
dd10 has joined #zig
return0e_ has joined #zig
return0e has quit [Ping timeout: 250 seconds]
dd10 has quit [Quit: Page closed]
dd10 has joined #zig
return0e has joined #zig
return0e_ has quit [Ping timeout: 246 seconds]
marmotini has quit [Remote host closed the connection]
<mikdusan> is std.LinkedList good for FIFO, or is another more suitable?
<mikdusan> *is there another more suitable?
<andrewrk> mikdusan, it's fine as far as time complexity goes, but depending on your particular use case there may be a more optimized data structure that the std lib doesn't have yet
<andrewrk> it's certainly not a mistake to start with std.LinkedList. easy to swap out the component later
<mikdusan> yup i’ll use it. just making sure i’m not missing any (better) existing std options
develonepi3 has joined #zig
Hejsil has joined #zig
<Hejsil> A linked list + A good allocator goes a long way in terms of speed. In the advent of code I did a LinkedList + FixedBufferAllocator solution which was only 4x slower than the ring buffer solution liampwll made
<andrewrk> Hejsil, in answer to your string literal question above - yep. Or if you wanted to change strings later you'd have to give it a type, like this: var s: []const u8 = "hi"; s = "bye";
<andrewrk> but dereferencing it would allow you to use it to initialize an array, as you pointed out
<Hejsil> Right, was just making sure we intended to break this code :)
<Hejsil> 'break' as in breaking change
<andrewrk> yep. we still have a lot of breakage to go before stabilizing
<andrewrk> I'm working on a major bug fix - decoupling LLVM types / LLVM debug info types from Zig types in stage1
<scientes> what is ConstValSpecialUndef ?
<andrewrk> scientes, `undefined`
<andrewrk> that's how `undefined` is represented in ConstExprValue
wootehfoot has joined #zig
<scientes> i'm confused how implicit_cast managed to convert a u16 to a u8
jjido has joined #zig
<scientes> anyways, ill focus on the other bugs there
<andrewrk> any comptime-known integer value is allowed to implicit cast to any other integer type if the value fits
<scientes> but in this case it doesn't fit
<scientes> oh my bad
<scientes> bad code
<scientes> caused by copy-paste
<Hejsil> andrewrk, wasn't llvm types used for @sizeOf?
<scientes> I hope what you are doing doesn't merge conflict with my work on some builtins
<andrewrk> Hejsil, yes. after my change zig computes struct offsets and sizes itself
<andrewrk> it will make https://github.com/ziglang/zig/issues/1512 easier to implement and make packed structs more useful
<andrewrk> I didn't really understand struct layout and alignment when I started zig but now I understand it quite well
<Hejsil> Aah. I see
<andrewrk> right now packed structs always have alignment of 1, for every field
<andrewrk> which makes it only useful for bitfields really
<andrewrk> but if you have the power to align fields manually then it becomes a powerful tool that can be used to lay things out in memory with great precision
<Hejsil> Sounds like something that also relates to Zig reordering fields of normal structs
<andrewrk> (which obviously you only need sometimes; normal structs should be OK for most things)
<andrewrk> yes, that will be more straightforward after this change too
<andrewrk> we also don't waste time creating llvm types and debug types that are only used at comptime
<andrewrk> it's taking me a few days though. with the upcoming release this comes at the cost of some other bug fixes
<fengb_> [Benjamin Feng, fengb] Wow, looks great. I've been dabbling with writing an emulator and having the language help align the memory correctly would be amazing
fengb has joined #zig
<andrewrk> scientes, it will probably merge conflict in ir.cpp but in easy-to-resolve ways
<andrewrk> do you have 3 way conflicts set up?
<andrewrk> [merge]
<andrewrk> conflictstyle = diff3
<andrewrk> this changed my life
<scientes> i'll start with that
<mikdusan> git config --global merge.conflictstyle diff3
return0e has quit []
<Hejsil> Hmm, found a bug in master while working on the comptime slicing https://clbin.com/FXy50
<scientes> mikdusan, he gave me something to put directly in ~/.gitconfig
return0e has joined #zig
<Hejsil> Actually, the alignment is unneeded
<andrewrk> scientes, mikdusan's command inserts it for you
<scientes> yes i know
Hejsil has quit [Ping timeout: 256 seconds]
Hejsil has joined #zig
dd10 has quit [Ping timeout: 256 seconds]
wilsonk has joined #zig
Hejsil has quit [Quit: Page closed]
fengb has quit [Quit: Page closed]
slipyx has left #zig ["WeeChat 2.2"]
<andrewrk> live coding on GeneralPurposeDebugAllocator starts in 20 minutes. https://www.twitch.tv/andrewrok/
nullheroes has joined #zig
hg has quit [Quit: WeeChat 2.4]
<scientes> an Allocator wrapper could be used to profile memory usage in debug mode
jjido has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
fsateler has joined #zig
fsateler has quit [Ping timeout: 250 seconds]
Flaminator has quit [Ping timeout: 244 seconds]
fsateler has joined #zig
Ichorio has quit [Ping timeout: 250 seconds]
wootehfoot has quit [Read error: Connection reset by peer]
allochi has joined #zig
tgschultz has quit [Ping timeout: 246 seconds]
<allochi> Hey, I have question about zig slices
<emekankurumeh[m]> ask away
tgschultz has joined #zig
<allochi> Hey, could you have a look at this https://pastebin.com/C3wpBmsH
<allochi> the test throws an error, I haven't done anything with zig for a while and I'm really rusty
<allochi> I can't figure it out
<emekankurumeh[m]> you need to import "std" to get the warn function
<allochi> not that sorry, I do import the std
<allochi> I'm sorry, I should be clear...
<allochi> what fails is `atest.value[0] = 0;`
<allochi> if I comment this, the test pass and prints out the first element of each array
<allochi> also, are there slice literals in zig?
<mikdusan> u have to “toslice” the array.
<mikdusan> and since it’s const, you’ll have to adjust your var.
<mikdusan> field.
<allochi> what is constant?
<mikdusan> but i don’t think u want that.
<allochi> which part is constant?
<mikdusan> well u have field value: []i32 which wants u want to use as mutable looking at your code.
<mikdusan> so it needs mutable storage. and forcing it to use address-of a literal array means (i believe) you just wrote to immutable storage.
<emekankurumeh[m]> what version of zig are you using?
<mikdusan> latest
<allochi> latest
<emekankurumeh[m]> your code seems to work fine https://godbolt.org/z/xUlwy_
<mikdusan> runtime: stop reason = EXC_BAD_ACCESS
<allochi> not here, I'm on macOS
<emekankurumeh[m]> i suppose there is a problem with godbolt then
<allochi> ok, I will check on my linux tomorrow, my other question is how toSlice?
<allochi> I know that with a variable I can do something like this a[0..]
<allochi> but how to slice with an array literal?
<emekankurumeh[m]> the arrays literals are stored as constants so any slices or references to them will be constant as well.
<allochi> ah! good to know.
<allochi> could this be why my code didn't work?
<mikdusan> this is ugly but it allocates the memory you need. and you’ll have to free it somewhere. https://gist.github.com/mikdusan/acb1f669553f9c19d8c4c78d4936f243
<allochi> yeah, not really pretty at all :)
<allochi> but there is something else...
<emekankurumeh[m]> i think in this situation a FixedBufferAllocator, wrapped in a ArenaAllocator would be better
<mikdusan> point is value needs mutable storage
<allochi> if the array literals are constant, why when I assign a variable an array literal and use the address of the variable, I can mutate the array.
<allochi> ?
<allochi> I will paste the snippet, give me a minute.
<emekankurumeh[m]> i just realized godbolt only compiles the code, it doesn't run it
<allochi> have a look at this
<allochi> you see if I assign the array literal to a variable and then use the variable address, I'm able to mutate the array, so it's not constant.
<allochi> sorry, this is not making sense, the array literal is basically just a memory block inside the code, and is can be accessed and modified.
<mikdusan> i think you’re right. i’m wrong. but the difference in your code is: 1 does it with a tmp that vanishes. the other does it with storage that’s around longer.
<mikdusan> line 28. `var a` is alive during use in line 33. while line 14 []i32{24,2} does not live past line 15. yet you use that memory in loop at line 17.
<allochi> I'm not sure it vanishes, again that array is in the stack, and I try to modify it while I'm still in the same stack.
<allochi> are you sure? is so what would be the workaround without using the heap?
<allochi> actually, this is not correct, I'm sorry
<allochi> it doesn't vanish
<allochi> the simple proof of that if I comment the line that mutate the array `atest.value[0] = 0;`
<allochi> the for loop is able to read the first element of every array and prints it out.
<allochi> if it vanish, then I should get segfault.
<mikdusan> in your original that’s what i got. a bad access.