ChanServ changed the topic of #zig to: zig programming language | ziglang.org | be excellent to each other | channel logs: https://irclog.whitequark.org/zig/
qazo has joined #zig
qazo has quit [Ping timeout: 245 seconds]
wink_ has quit [Ping timeout: 268 seconds]
zachcarter has joined #zig
<zachcarter> hello
<zachcarter> checking out zig, coming from the Nim world
iovec has joined #zig
iovec has left #zig [#zig]
reductum has joined #zig
<reductum> I'm trying to track down a memory leak. I have a loop creating hundreds of thousands of nodes in a linked list.
qazo has joined #zig
<reductum> When I use heap.DirectAllocator to allocate the new nodes, I quickly use up all the memory of my machine.
<reductum> But if I calculate how much space all the nodes will take, allocate a buffer of that size, and used a heap.FixedBufferAllocator, there is no memory explosion.
<reductum> Now, I'm not surprised the fixed buffer allocator is faster, but I would expect the 2 allocators to ultimately allocate the same amount of memory.
<reductum> Maybe I'm missing something simple. If anyone has any ideas, they would be most welcome.
qazo has quit [Ping timeout: 250 seconds]
qazo has joined #zig
qazo has quit [Ping timeout: 250 seconds]
wilsonk has quit [Read error: Connection reset by peer]
SimonN has quit [Ping timeout: 250 seconds]
SimonN has joined #zig
<andrewrk> reductum, DirectAllocator isn't meant to be used as a general purpose allocator. zig has no general purpose allocator in the standard library yet.
<andrewrk> DirectAllocator on posix systems calls mmap directly. so if you allocate 1 byte, you get an entire page
qazo has joined #zig
<reductum> andrewrk: Thank you. I had assumed it wrapped malloc. I should have read the source more closely!
<andrewrk> reductum, better standard library docs will happen eventually
<andrewrk> reductum, also if you're willing to link against libc (or already are linking against libc) I would recommend to use std.heap.c_allocator, which wraps malloc
brainzap has joined #zig
<reductum> andrewrk: I happen to be working on Advent of Code stuff, and want to abide by the Zig rules.
<reductum> But it's been a really lovely experience exploring the current zig standard library and getting used to the language.
<reductum> Thanks for clearing up my confusion :)
<andrewrk> reductum, ah, for advent of code, I can recommend the ArenaAllocator backed by DirectAllocator. like this: https://github.com/andrewrk/advent-of-code-2018/blob/a16aa1c55c3a2f629a289b0193546512f40fe2cb/day1b.zig#L4-L10
<andrewrk> idea being that you're going to run the thing once, so you don't mind allocating everything in one big arena, and then freeing it all together at the end (or just let the OS free it on shutdown)
<andrewrk> *not shutdown - on application exit
brainzap has quit [Ping timeout: 246 seconds]
<reductum> That sounds ideal! I'll try it out.
wink_ has joined #zig
wilsonk has joined #zig
<reductum> Day 10 is actually the first one I've done in a while that doesn't require an allocator.
qazo has quit [Read error: Connection reset by peer]
IntoxicatedHippo has joined #zig
emekoi has joined #zig
<emekoi> is this (https://gist.github.com/emekoi/d30b8f184d912869dc60b41304452d7e) a working implemention of fcntl?
emekoi has quit [Ping timeout: 256 seconds]
sjums has quit [Ping timeout: 268 seconds]
brainzap has joined #zig
brainzap has quit [Quit: I have updated my privacy policy in preparation for the EU's General Data Protection Regulations (GDPR). To receive a copy of the IRC log pleas click the following link]
basro has quit [Disconnected by services]
basro_ has joined #zig
basro_ is now known as basro
brainzap has joined #zig
brainzap has quit [Remote host closed the connection]
brainzap has joined #zig
brainzap2 has joined #zig
brainzap has quit [Ping timeout: 250 seconds]
reductum has quit [Quit: WeeChat 2.3]
bilebucket has joined #zig
<euantor> zachcarter: Nice to see a face I recognise from Nim here :)
brainzap2 has left #zig ["You're never drinking alone when you've got the internet."]
return0e has quit [Ping timeout: 240 seconds]
return0e has joined #zig
<zachcarter> o/ euantor :)
d_s has quit [Remote host closed the connection]
zachcarter has quit [Ping timeout: 245 seconds]
IntoxicatedHippo has quit [Quit: Leaving]
bilebucket has quit [Ping timeout: 240 seconds]
steveno has joined #zig
unique_id has joined #zig
<unique_id> I like how "struct { x: if(true) Foo else void }" replaces "static if" (an if statement that does not introduce a scope). I never made that connection before.
unique_id has quit [Quit: Konversation terminated!]
halosghost has joined #zig
steveno_ has joined #zig
steveno has quit [Ping timeout: 250 seconds]
Hejsil has joined #zig
<andrewrk> alright, let's get everybody's pull requests merged today :)
<halosghost> all 12?
<andrewrk> I'm gonna try
<halosghost> ambitious
<halosghost> I believe in you :)
steveno_ has quit [Ping timeout: 250 seconds]
<andrewrk> halosghost, well, not copy elision yet. there's still a bunch to do
steveno_ has joined #zig
<halosghost> hehe
<MajorLag> If it helps, mine has no conflicts with master since I rebased it a while back. As long as you're satisfied with the code it should be a freebie.
<andrewrk> MajorLag, nice, I'll go on to that one after the one I'm looking at now
jjido has joined #zig
Zaab1t has joined #zig
Zaab1t has quit [Client Quit]
<daurnimator> aw, no copy ellision :(
steveno_ has quit [Ping timeout: 268 seconds]
<andrewrk> daurnimator, it's still coming along, slowly but surely
steveno_ has joined #zig
wootehfoot has joined #zig
meheleventyone has joined #zig
meheleventyone has quit [Remote host closed the connection]
meheleventyone has joined #zig
<mgxm> first time testing zig and am getting this error on freebsd
<mgxm> xf86_64.zig:101:15: error: invalid token: '&'
Zaab1t has joined #zig
<andrewrk> mgxm, willing to contribute a little? try this: https://clbin.com/d3iG0 and then `make install` and see what the next error you get is
<mgxm> sure
meheleventyone has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
steveno_ has quit [Quit: Leaving]
sjums has joined #zig
<sjums> Hey, I currently have a piece of code crashing the zig compiler without any stack traces or errors. Is this ever intended?
<andrewrk> sjums, no, that's always a bug
<andrewrk> unless it's a stack overflow in which case it's a bug in stage2 but not stage1
<sjums> Unsure what it is. Will try to make a minimal example
<andrewrk> thanks
<sjums> ...tomorrow :) currently heading to bed!
<andrewrk> good night
<sjums> Thanks. You too whenever you reach that time 👌
<mgxm> andrewrk: after patching: https://clbin.com/YvL0D
<andrewrk> mgxm, @maxValue is replaced by std.math.maxInt
<andrewrk> does the second error have any notes?
<mgxm> I'm home now, I will try to build on my machine.
<andrewrk> mgxm, your machine is also x86_64, yes?
Hejsil has quit [Quit: Page closed]
<andrewrk> try this: https://clbin.com/PgVGw
<mgxm> same error with maxValue, I will clone and start again... maybe I'm doing something wrong.
jjido has quit [Ping timeout: 250 seconds]
<andrewrk> std.math.maxInt, not @maxValue
<andrewrk> @maxValue was deleted and that code needs to be updated
<andrewrk> don't forget to `make install` after you modify std lib files
<andrewrk> you probably don't need to clone and start again
emekoi has joined #zig
halosghost has quit [Quit: WeeChat 2.3]
<mgxm> so, I changed all the references from maxValue to use std.math.maxInt, and now I will try to fix the other errors.
<andrewrk> mgxm, sounds like progress
<mgxm> std/os/file.zig:183:33: error: no member named 'access' in '/usr/home/build/zig/build/lib/zig/std/os/freebsd/index.zig'
<mgxm> /std/os/file.zig:183:52: error: no member named 'F_OK' in '/usr/home/build/zig/build/lib/zig/std/os/freebsd/index.zig'yye
<andrewrk> mgxm, looks like you need to either add the `access` freebsd syscall in freebsd/index.zig or adjust the code that is depending on `access` to use a different system API
<mgxm> yes, I Ill try to do that
<mgxm> but I have to start all the build process again and again
<andrewrk> all the build process? why?
<andrewrk> when you do `make install` it is supposed to only build the things that changed
<mgxm> if not, I get Unable to create builtin.zig: invalid format
<andrewrk> I was debugging this issue earlier, on my freebsd raspberry pi, but gdb didn't work and lldb kept freezing and kill -9 didn't kill it
<andrewrk> and `make` was rebuilding all the source files, not only the ones that changed
<andrewrk> so I gave up for now
<andrewrk> maybe debugging will work better on x86_64
<andrewrk> mgxm, whatever is causing that error is probably in os.cpp in the compiler
<mgxm> cool, thank you
<mgxm> I'lll try to find the issue
<andrewrk> mgxm, it has to do with reading the cache from ~/.local/share/zig/stage1/
<mgxm> yes, indeed... removing the cache exe/ud4....txt resolved the error
Zaab1t has quit [Quit: bye bye friends]
<andrewrk> don't get used to doing that though... that's supposed to be working
<andrewrk> there's probably a silly bug in the freebsd os.cpp functions
MajorLag has quit [Read error: Connection reset by peer]
MajorLag has joined #zig
wootehfoot has quit [Read error: Connection reset by peer]
<mgxm> andrewrk: I was reading the code an trying to figure out the error
<andrewrk> mgxm, can you see if `this_path` and `chf->path` are different by some strange thing? perhaps one of them has an extra null byte or something like that
<mgxm> yes, of course
<mgxm> I will make my dinner and come back later