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/
<daurnimator> fengb: made it to the next round of interviews....
NocturnDragon has joined #zig
<fengb> Congrats. Have I heard of the company?
wootehfoot has quit [Quit: Leaving]
NocturnDragon has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
waleee-cl has quit [Quit: Connection closed for inactivity]
<daurnimator> nope
stratact has joined #zig
<daurnimator> frmdstryr: you there?
ur5us has joined #zig
jicksaw has quit [Quit: ZNC is kill]
<frmdstryr> yo
ur5us has quit [Remote host closed the connection]
jicksaw has joined #zig
<frmdstryr> daurnimator: yes
<daurnimator> frmdstryr: want to have a pairing session to delve into read/write performance issues?
<frmdstryr> What time zone are you in? I'm about done for tonight
<daurnimator> frmdstryr: Melbourne/Australia. currently 13:17
<daurnimator> frmdstryr: atm I'm trying to figure out how to run your benchmark thing
<frmdstryr> What os?
<daurnimator> linux
<daurnimator> I think I have it now :)
<frmdstryr> Should be able to just run
<frmdstryr> Are you using the gist?
<frmdstryr> I made one that spawns the process and tests it automatically
<daurnimator> no. I grabbed things from one of your comments
<frmdstryr> Is my current hacked up one
<frmdstryr> Ignore the IPerf stuff that didn't work for some reason
<frmdstryr> Also the IOStream there while faster in the tests has only a minimal impact on the server https://github.com/frmdstryr/zhp
<daurnimator> frmdstryr: file name doesn't match comment...
<frmdstryr> At least for hello world
<daurnimator> I guess just append a 2?
<frmdstryr> Yeah didn't want to overwrite the one in the issue
<daurnimator> also I want to play with the std library... so having it all copied into the gist isn't useful :(
<frmdstryr> I just did that so I didn't have to rebuild & install every time (not sure if theres a way to get around that)
<daurnimator> frmdstryr: just pass ZIG_SKIP_INSTALL_LIB_FILES=ON when invoking cmake
<daurnimator> frmdstryr: honestly I'm getting lost in your code here.... I might be better just starting again
<frmdstryr> Mainly the same just doesn't have Iperf or any RW tests
<daurnimator> RW?
<frmdstryr> Read and write
<frmdstryr> echo
<daurnimator> frmdstryr: did you have an alternative that you used to check the fifo and stream branches?
<frmdstryr> readBufferedInStreamMixin
<daurnimator> frmdstryr: so what are you optimising for?
<daurnimator> reading by the byte?
<daurnimator> also readBufferedInStreamMixin doesn't seem to be present in your switch(READ_FN)
<frmdstryr> in order to process a stream it typically needs read byte by byte, ie readUntilDelimiter uses readByte
<frmdstryr> and yes the switch was added later after I got tired of using comment / uncomment
<daurnimator> frmdstryr: that's a terribly inefficient way to do things: readUntilDelimiter on a buffered stream should use mem.indexOfScalar internally
<daurnimator> infact I have a branch somewhere of doing that with fifo :)
<daurnimator> okay, so baseline of readBufferedInStream on my machine is 280 MB/s
<stratact> Okay, I give up, why the heck won't InStream.readUntilDelimiterOrEof read a file?
<daurnimator> stratact: explain?
<stratact> I'll share a paste of the output
<stratact> *pastebin
<daurnimator> what is the equivalent in zig of -fno-emit-frame-pointer ?
<daurnimator> stratact: looks like you closed a file while trying to read from it
NocturnDragon has joined #zig
<daurnimator> /usr/home/ what sort of system is that?
<frmdstryr> Use const stream = &in_stream.stream;
<frmdstryr> It's quite annoying
<stratact> daurnimator: /usr/home is a BSD thing
<frmdstryr> because it's very easy to do
<daurnimator> frmdstryr: heh. so investingating this is hard.... *the whole thing* is getting inlined
<stratact> frmdstryr: gotcha, thank you.
<NocturnDragon> Hello! I posted a message yesterday, but I never seen a response, and I don't see them in the chat history, I'll write it again, sorry if it's a duplicate and someone replied already!
<NocturnDragon> Hello! I posted a message yesterday, but I never seen a response, and I don't see them in the chat history, I'll write it again, sorry if it's a duplicate and someone replied already!
<NocturnDragon> Hello! I am new to Zig, and I wanted to starting using it to create Reflection data for a C project.
<NocturnDragon> When using types like https://github.com/garettbass/c-array or https://github.com/antirez/sds the actual type of the variable is just a T* or char *, but the real type is in this case a custom array or a custom string.
<NocturnDragon> In C I would annotate the type like `#define string_t char* __attribute__((annotate("string_t")))`, to discern from a simple char* to the custom types via a custom clang-tool.
<NocturnDragon> In Zig is there a way to have the GNU C99 __annotate__ attribute pipe through to the @TypeInfo and not get lost?
<daurnimator> NocturnDragon: yesterday you already found the relevant zig issue.
<NocturnDragon> Yes, I had found that one! So my messages got here. Weird that I couldn't see them on the chat history. Sorry for posting it again.
<daurnimator> the log bot has been missing for a few days
<daurnimator> or maybe not... it seems to be working now
<daurnimator> *shrug*
<frmdstryr> what whole thing is being inlined?
<daurnimator> frmdstryr: readtest2
<daurnimator> frmdstryr: either the whole thing is getting inlined, or zig is omitting frame pointers...
<stratact> frmdstryr: got past the bug finally... the `in_stream` symbol needed to be var'd while `stream` be const'd, thanks again.
<frmdstryr> daurnimator: Are you using evented?
<daurnimator> stratact: FWIW the mixin style should clean all that up.
<daurnimator> frmdstryr: 'evented'?
<NocturnDragon> Yeah, strange. Thank you daurnimator!
<stratact> daurnimator: I need to lie down for a bit, since this bug gave me a nice headache. I'll ping you about mixin style later ;)
<frmdstryr> async
<daurnimator> frmdstryr: ah no. just sync for now
<daurnimator> frmdstryr: so I'm still confused what you're trying to acheive
<daurnimator> frmdstryr: if you want to read byte-at-a-time, then you don't want a Buffered stream
<frmdstryr> Read a variable length of a stream until a pattern is matched then read the rest in big chunks
muffindrake has quit [Ping timeout: 276 seconds]
<daurnimator> frmdstryr: I'm struggling to turn that into a test case... this is where pairing might help :)
muffindrake has joined #zig
<daurnimator> ?
<daurnimator> I know what a http request looks like
<frmdstryr> So how do you parse it?
<frmdstryr> Assuming the post body may be uploading files of any size?
<daurnimator> well first off, http has multiple framing methods for the body
<daurnimator> so you need to handle content-length delimited; end of connection delimited; and chunked transfer encoding
NocturnDragon has quit [Quit: Textual IRC Client: www.textualapp.com]
<frmdstryr> looks like they're using a buffer instead of reading a byte time from an input buffer
<daurnimator> frmdstryr: yes
<daurnimator> frmdstryr: got discord?
<frmdstryr> no
<daurnimator> frmdstryr: http://sprunge.us/0HXqI0
<daurnimator> (not 100% correct; but should give you a feel)
_whitelogger has joined #zig
_whitelogger has joined #zig
knebulae has quit [Read error: Connection reset by peer]
<stratact> daurnimator: *poke*, what is mixin style and how do I use it? :)
<mikdusan> mixin is `usingnamespace` to import public decls from another struct; and also powerful is the struct can be defined at comptime. see lib/std/fifo.zig on a cool way to add `pub fn print()` to `LinearFifo` conditionally:
<pixelherodev> Whoooaaaaa
<pixelherodev> Okay, I'm suddenly very much interested in mixins
<daurnimator> What I'm blessing a "mixin" is the explicit style of: `pub usingnamespace SomeMixin(@This());`
<mikdusan> sounds good, the mixin knows target struct. opens big doors
<stratact> huh, after reading about the mixin concept on wikipedia, they sound similar to traits/interfaces but definitive by default instead of open to interpretation from implementation by other users. This is pretty nice, I like it. Reusable code in structs by injection.
<stratact> Hence, that's why they "mix in" into other structs
_whitelogger has joined #zig
<pixelherodev> Okay, I was impressed before but that second link is even more so
_whitelogger has joined #zig
<stratact> I think mikdusan was trying to show that's how a Mixin would unwrap at compile time with the first link?
<stratact> Actually now that I think about, using static conditionals allows for specialization, so with that included, Zig doesn't need any form of inheritance or composition
<daurnimator> stratact: you can only import functions with a mixin, not fields.
<stratact> but but... damn you :)
<stratact> I still think is pretty damn cool
<stratact> I am still re-learning Zig and picking up new stuff I haven't learned before. There is a reoccuring theme to Zig with its feature that I discover. I am impressed by the amount of thought and care went to the implementation with its language reuse and flexibility, it's god-like honestly.
<stratact> I'm not saying this through pure flattery, I really mean it, I'm mind-blown by it.
<pixelherodev> Eh, given how poorly thought out a lot of nature is, I'd say it's *better* :)
<stratact> 👍
<pixelherodev> Which symbol is that? It's not in the font my IRC client uses apparently
<pixelherodev> Those mixins look amazing - if not for the fact that I'm going to have to redo thousands of lines of code :P
<stratact> It's the thumbs up unicode emoji
<pixelherodev> Ah :P
<pixelherodev> Can I just say it irritates me that Unicode has six-byte sequences for emoji>
<pixelherodev> ?
<pixelherodev> Correction: that it has *any* such sequences
<stratact> The magic of code-points?
<daurnimator> so.... frmdstryr nerd sniped me earlier and I've spent a few hours writing production quality http request line parser...
<stratact> daurnimator: from the time saving feature of Mixins? ;)
<daurnimator> no. because I got it in my brain that I need to show that nothing really reads byte-at-a-time
<stratact> Well I'm not completely sure about that but maybe Rust brainwashed me into thinking that for UTF8
<daurnimator> stratact: if you want to go fast you read e.g. page at a time. if you're dealing with disks you read 16 meg at a time.
<pixelherodev> Wait, you're writing HTTP for the zig stdlib?
<pixelherodev> On that note, I hereby dub zig stdlib zag
<daurnimator> pixelherodev: yeah. I've had that on my personal backlog for over a year
<pixelherodev> Nice!
<daurnimator> the fifo module was a prerequisite for it
<daurnimator> previously I was delaying it on the async io abstraction too. but now with mixins I can ignore that piece
<stratact> daurnimator: I'm looking forward to your PR's merge
<mq32> <pixelherodev> On that note, I hereby dub zig stdlib zag
<mq32> lol
<mq32> <daurnimator> no. because I got it in my brain that I need to show that nothing really reads byte-at-a-time
<mq32> this reminds me of a story a friend told me
<mq32> he started at a new company and some days later he re-appeared in the chat and said: this is my place. here i can finally code with full power
<mq32> the company has a multi-threaded XML parser
<mq32> which splits the XML into arbitrary chunks ("take chunks of 1M bytes")
<mq32> parses those chunks (with maybe-broken tokens a the start/end) and merges them at the end into an XML dom
<daurnimator> sounds like you could never be namespace compliant
<daurnimator> (I once tried something similar back in the days when I was paid to work full time to XMPP)
<mq32> i have no idea
<mq32> but they also utilize SIMD for parsing
<mq32> so it's top-notch perf code
_whitelogger has joined #zig
<pixelherodev> Yeah but
<pixelherodev> *XML*
<pixelherodev> Don't get me wrong, XML is fun to write
<pixelherodev> It's just...
<pixelherodev> Well...
<pixelherodev> *XML*.
<daurnimator> who said its fun to write? I'll kill them
<mq32> i think XML is nicer to read as json for a human
<mq32> except when stuff comes into play :D
<pixelherodev> Let me rephrase that: code *using* XML is fun to write
<pixelherodev> If you have a good library, it's pretty easy to work with'
<daurnimator> lies
<pixelherodev> :P
<mq32> cross-references elements!
<pixelherodev> Okay, so if your "XML" is actually probably illegal according to the standard but it works well enough and your parser is fine with it, *then* XML is usually mildly tolerable
<daurnimator> as long as you or any one else doesn't look at it funny. or ever come with 10 feet of it again
<mq32> hehe
* mq32 looks at gigabyte-sized XML files
* mq32 is terrified
<scientes> XML is a horrible idea
<scientes> that for some bad reason was implemented
<shakesoda> in truth, aren't most ideas that actually get implemented
<shakesoda> but here we are
<scientes> it could be woorse
<mq32> some ideas are worse than others
<mq32> and then there are C declarations
<mq32> i'm teaching C to someone right now
<scientes> you mean the c preprocessor
<scientes> that is a different language
<mq32> preprocessor is okayish
<mq32> but declarations…
<scientes> ohhh yes
<mq32> and i was like: "Let's declare a function pointer."
<scientes> those are not THAT bad
<mq32> and then, 1 hour later i had explained the very basics of declarations :D
<scientes> its better to learn by doing
<pixelherodev> Oh god
<pixelherodev> Function pointer declarations in C...
<scientes> mq32, cause the only point of those things is to prevent problems
<scientes> you could just call every function without a type signature at all
<scientes> and then try to remember which register things were in
<mq32> scientes: not in modern C anymore :D
<shakesoda> every now and again i need to typedef a function pointer, and google gets involved most of the time
<mq32> typedef Type a, *b;
<mq32> it's so crazy that typedef is a storage modifier
<mq32> like static
<scientes> #define D #define
<scientes> ^that works
<pixelherodev> typedef return_type(name*)(normal_arglist); right?
<pixelherodev> Haven't done that in a long while now
<shakesoda> that looks right but i can't say it is with confidence
<mq32> pixelherodev: just like declaring a function pointer variable
<pixelherodev> Wait hold on scientes do you mean that later instances of `D a a` will be like #defining?
<mq32> and no, its'
<mq32> typedef return_type (*name)(normal_arglist);
<pixelherodev> Ugh
<pixelherodev> Right
<shakesoda> dangit
<shakesoda> didn't even notice the side of the *
* shakesoda weeps in years of c
<mq32> but who the hell thought that typedef is a storage specifier?!
<mq32> typedef void (*foo)(void), *ptr;
<mq32> this is also nice :D
<mq32> scientes: nice
<mq32> i also like the implemetation of a fluid simulation that uses itself as a start vector
_whitelogger has joined #zig
<gonz_> Oh, wow, `using namespace [control-flow] struct1 ... structN`
<gonz_> `usingnamespace`*
<gonz_> There's some heavy duty emergent behavior out of all these simple parts in the language.
<mq32> yep
<daurnimator> >.< why is everyone only reading my examples for 2 months ago now
<gonz_> I can't speak for anyone else but I was gone for a while, at least.
<mq32> daurnimator: i still wonder why *your* mixins are accepted whereas my mixin approach was critized
<mq32> and we did exactly the same :D
<daurnimator> mq32: did we? and is it accepted?
<daurnimator> gonz_: you were gonz_ for a while? :P
<mq32> i did not push anything to the stdlib, but made use of them for my vector math lib
<gonz_> :D
<daurnimator> mq32: and where was it critisized?
<mq32> here in the chat, by: "don't do mixins, they hide what functions are actually available in the struct" or something like that :D
<mq32> doesn't matter much, i just noticed that^^
<gonz_> Hey, I was wondering if maybe someone had sat down and made a GLM-like thing for zig
* mq32 looks at gonz_
* mq32 looks at his link above
<mq32> :D
<gonz_> That's why I'm mentioning it, though. I guess the tone didn't come across in text.
<mq32> :D
<gonz_> Imagine there's a "would you look at that" in there
<mq32> !
<mq32> and i'm proud of my swizzle implementation
<mq32> comptime at it's best
<mq32> vec2(0, 1).swizzle("xxy0")
<mq32> returns vec4(0, 0, 1, 0)
<mq32> glm has a swizzle thing going which is the most gruesome c++ hackery i've ever seen
<daurnimator> `/src/analyze.cpp:5441 in type_has_bits. This is a bug in the Zig compiler.` I think I'm getting this when passing a 0-bit type as a `var` argument
<mq32> and in zig it's just like "yeah, go through that string, index the fields by the characters in the string and return a vector with that size"
<shakesoda> mq32: i once looked at glm's swizzle implementation
<shakesoda> never again
<mq32> shakesoda: i still have bad dreams about that :D
<shakesoda> that stuff is truly horrifying
<gonz_> It might make for a good comparative demonstration in a talk
<gonz_> As part of a "Zig: An amuse bouche" talk, maybe
<mikdusan> hmm given any enum literal, how to get the name of it? eg. `.i_am_a_literal` and want comptime []u8 "i_am_a_literal"
<mq32> @tagName
<mikdusan> @tagName needs an enum value. i have only an enum literal. consider `fn foo(comptime arg: var)` and `foo(.i_am_a_literal);`
<mq32> oh huh
<mikdusan> i was just thinking to shave 1 char from your swizzle -> `vec2(0, 1).swizzle(.xxy0)` :)
<mq32> does .0000 work? :D
<mq32> i don't think that's a legal identifier
<mikdusan> heh nope
mahmudov has quit [Ping timeout: 268 seconds]
qbradley has quit [Remote host closed the connection]
<pixelherodev> scientes, whoooa
<daurnimator> mikdusan: hmm. what happens when you @typeInfo on an enum literal?
wootehfoot has joined #zig
BitPuffin has quit [Quit: killed]
dtz has quit [Quit: killed]
Demos[m] has quit [Quit: killed]
D3zmodos has quit [Quit: killed]
Snektron has quit [Quit: killed]
emekankurumeh[m] has quit [Quit: killed]
fengb has quit [Quit: killed]
Demos[m] has joined #zig
jokoon has joined #zig
BitPuffin has joined #zig
dtz has joined #zig
D3zmodos has joined #zig
fengb has joined #zig
Snektron has joined #zig
<frmdstryr> daurnimator: Were you able to build a fast parser? Interested to what your findings are
<daurnimator> frmdstryr: I literally haven't stopped working on it
<daurnimator> since you left
<frmdstryr> Whats the throughput?
<frmdstryr> :)
<daurnimator> frmdstryr: may have gotten distracted with creating an actually correct http connection parser
<frmdstryr> I put a challenge for you in the #3840
<daurnimator> frmdstryr: FWIW at one point I had 7GB/s throughput on the plain tcp tests
<daurnimator> frmdstryr: happy to pair
<frmdstryr> But is that processing or read chunk write chunk?
<frmdstryr> any processing must read or seek byte by byte at some point
<daurnimator> frmdstryr: that was by-chunk
<daurnimator> frmdstryr: and no. you don't need to do byte-by-byte very often
<daurnimator> frmdstryr: e.g. if you're uploading a file, then you read a chunk from the filesystem; then write a chunk to the socket
<frmdstryr> How do you know when the headers are complete (or any delimiter for that matter) without reading each byte?
<frmdstryr> mem.indexOfPos still has to read each byte
<daurnimator> frmdstryr: you read a big chunk and then use mem.indexOfPos on it
<daurnimator> it's much more efficient operating on a cache line of data at a time
<frmdstryr> that's what the buffered reader does not?
<frmdstryr> read one chunk into the buffer
<Snektron> Today's aoc made me realize that there needs to be a way to iterate over all permutations of a slice in the std lib
<Snektron> because its not the first time that i've had to do such a thing with a programming challenge
<daurnimator> oh right AOC.... I've missed a few days
<daurnimator> frmdstryr: yes. but the issue is bufferedInStream in the non-fifo branch doesn't allow you to play with the contents easily
<frmdstryr> it could just do mem.indexOfPos(u8, "\n", stream.buffer)
<daurnimator> frmdstryr: yes that's the vague idea.
<frmdstryr> but indexOfPos is still looping over every byte in the buffer and doing mem.eql
<daurnimator> that gets optimized much better though
<frmdstryr> correct, but why not make readByte just as fast if possible
<daurnimator> without a `try` in there or any branching beyond a loop index, llvm can work its magic
<frmdstryr> readByte should really just return a ptr to somewhere the buffer but the streams api doesn't really work like that
<daurnimator> frmdstryr: it can on the stream-mixin branch
<frmdstryr> How do I see the llvm output?
<daurnimator> --verbose-llvm-ir?
<frmdstryr> oh nice :)
<frmdstryr> Looking at the branch, what does usingnamespace actually do?
<Snektron> it imports all functions and static fields of a structure into another
<frmdstryr> Is import a ptr or an actual concat of the struct as if it was written that way?
<frmdstryr> (eg if i just copy and paste all the fields over)
<daurnimator> frmdstryr: it doesn't include fields; just functions and constants
<daurnimator> frmdstryr: but for those: its as if you wrote them there
<frmdstryr> so in terms of caching it has to lookup the vars somewhere else when accessing a non const field then?
<daurnimator> huh?
<mq32> frmdstryr: it's only syntactic sugar, nothing that has any impact on runtime
<mq32> probably also decreases compiletime as functions don't have to be parsed twice
leeward has joined #zig
<leeward> When I multiply -1 by -1 (i8 0x80), I get an integer overflow. Is this a bug? *% seems to behave correctly.
<mq32> "works for me"™
<frmdstryr> Is there a way to repeat a []const u8 x times? Ie "abc" * 10
<mq32> "abc" ** 10
<mq32> should do that
<frmdstryr> sweet, thanks
<stratact> I just wrote this to repeat 0s in static buffer: `var buffer: [bufsize]u8 = [_]u8{0} ** bufsize;`
<stratact> something I recalled
<mq32> yeah this is quite useful
<daurnimator> stratact: you don't need the signature on the left
<mq32> for string literals, it's now necessary
<stratact> daurnimator: thanks. mq32: I see, that was just a buffer for reading into a file. I adapted the code I wrote earlier into a readline iterator of sorts, pretty fun to implement.
<daurnimator> stratact: use a fifo at least :)
<stratact> oh... I'll look into that then.
<daurnimator> actually I made a handy commit for you just now
<stratact> oh that's right, it's still a PR?
<daurnimator> stratact: no private branch. let me push
* stratact will stand by
jokoon has quit [Read error: Connection reset by peer]
<stratact> daurnimator: ah, this is very neat.
<stratact> So by understanding what fifo means (first in first out), it's an optimized structure for buffering?
<daurnimator> stratact: yes
<stratact> I was having this "epiphany" from looking at the code :)
<stratact> TIL
mahmudov has joined #zig
<frmdstryr> Returning bytes directly from the BufferedInStream buffer I can get 2.0GB/s reads
<mq32> that's fast
<frmdstryr> vs 1.3 GB/s using the current readByte
leeward has quit [Ping timeout: 268 seconds]
<daurnimator> frmdstryr: what do you mean by "returning directly"?
<frmdstryr> Returning a the byte at the buffer's current start_index instead of copying it
<daurnimator> frmdstryr: I'm still not sure why you're operating on bytes at all...
<daurnimator> frmdstryr: usually you look from some delimiter; or you read a 4-byte length followed by a body
<frmdstryr> If the BufferedInStream is fast it should make life easier
<stratact> daurnimator: is this related to what you told me earlier about reading bytes-at-a-time is being slow as it is :)
<stratact> Still, 1.3 GB/s -> 2.0 GB/s is amazing. This is the power of FIFOs
<daurnimator> frmdstryr: it is fast.... but its important how you access it
<frmdstryr> Honestly I think the InStream and OutStream should be just replaced with the buffered readers
<daurnimator> InStream and OutStream are interfaces
<frmdstryr> Currently ever read method has to each byte twice
<daurnimator> no it doesn't...
waleee-cl has joined #zig
<frmdstryr> Sorry when the buf.len less than the in stream size with the BufferedInStream
<frmdstryr> *in stream buffer size
<frmdstryr> copies to the internal buffer then to the dest buf when read
<frmdstryr> when it should just return the pointer
<frmdstryr> but the current stream api won't work like that
<daurnimator> frmdstryr: normally size of buffer should be >> size of your read.
<stratact> (I learned that the hard way)
<stratact> I recall back when I was programming in Rust, even their BufferedReader struct had some sort of limitation compared to doing the low level C-like approach (which Zig uses), but it was for a niche use
<stratact> Oh yeah, I was writing a GUI frontend for Gentoo's portage at the time and was dealing with GTK+'s idle_add() sync issues and needed more output flow from the stdout buffer
casaca has quit [Ping timeout: 268 seconds]
<daurnimator> also it would be fixed if our InStream had a readv-like interface
casaca has joined #zig
<andrewrk> that's a good idea, to make the primitive readv
<daurnimator> andrewrk: with the mixin style we can make it conditional :)
<daurnimator> i.e. you could provide *either* and the mixin figures it out
<daurnimator> (or you could provide both)
<stratact> mixins are so wonderful 😄
<frmdstryr> daurnimator: frmdstryr: FWIW at one point I had 7GB/s throughput on the plain tcp tests, do these tests exist somewhere?
wootehfoot has quit [Read error: Connection reset by peer]
<daurnimator> frmdstryr: nope. I was just one test of many I was playing with locally
<daurnimator> frmdstryr: I'm pushing all the ancilliary work up to my stream-mixin branch for now
<frmdstryr> The fastest I can get is 1.3 GB read & write using file read on a streamserver connection
<frmdstryr> maybe netcat is the bottleneck
<daurnimator> also maybe my PC is faster
<andrewrk> daurnimator, the main problem I have with mixin style is name collisions
<andrewrk> and also, the problem of "where is this implemented?" becomes more tricky to answer
<daurnimator> andrewrk: aren't they errors? which is the desired behaviour? what would you want instead?
<frmdstryr> I managed to get the bufferedinputstream to match the file.read speed :)
<andrewrk> they're independent; they should be in different namespaces
<andrewrk> this is contrived, but, say you had a Counter interface and a Timer interface and they both have reset(). there's no reason for this to clobber each other; both have independent meanings
<andrewrk> with current pattern, it would be foo.counter.reset() or foo.timer.reset()
<daurnimator> andrewrk: in the current pattern you're *forced* to put them on sub-objects. You don't get the opportunity to put them in the upper level
<andrewrk> yeah, that's a feature
<andrewrk> putting them in the upper level -> the problem of "where is this implemented?" becomes more tricky to answer
<daurnimator> I think that's a bad thing: if I have a `BufferInStream` I don't want to have to do (&buf_stream.stream).method();
<daurnimator> though it does suggest good hygine for naming your mixings
<andrewrk> you mean buf_stream.stream.method()
<stratact> ouch, my upper-level mixin love took a dive...
<andrewrk> stratact, everything is a trade-off. there are certainly benefits to the mixin style. you're a curious person and so I would encourage you to try both
<daurnimator> frmdstryr: http://sprunge.us/vviR1J so this is where I got to for now
<daurnimator> oh, that's on debug mode. let me turn on release-fast and see....
<daurnimator> lots of room for improvement still: I'm using the page allocator!
<daurnimator> (also single threaded; single connection)
<andrewrk> frmdstryr, what did you end up doing?
<frmdstryr> Dump everything into one IOStream struct and make readByte return a ptr to the input buffer
<andrewrk> why is readByte() getting called at all for these benchmarks?
<frmdstryr> Was trying to make readUntilDelmiterOrEof fast
<andrewrk> ah
<andrewrk> that makes sense
<andrewrk> if you have a buffer though, you don't need readByte() for that function
<andrewrk> make the buffer full, then scan for the delimiter
<frmdstryr> daurnimator: My computer is slower today for some reason but i'm currently getting "Requests/sec: 12285.48"
<frmdstryr> but then if you read too far you have to put it back into the buffer somehow
<daurnimator> andrewrk: see my link to stratact earlier :)
<andrewrk> doesn't the buffer have an index?
<frmdstryr> yes, are you saying just do indexOf directly on the stream's input buffer?
<frmdstryr> that'd also work unless it's split over multiple chunks :)
<andrewrk> yes, fill up the buffer, look for the delimiter, if you don't find it then do another full read into the buffer. that's maximum efficiency right?
a_chou has joined #zig
a_chou has quit [Client Quit]
<frmdstryr> my thinking was if readByte returns the buffer there should be no difference
<scientes> if the buffer is really big you could also hack it by triggering a page fault at the end
<frmdstryr> ptr to the index of the buffer
<scientes> instead of using a range check
<daurnimator> I'm heading to bed. https://github.com/daurnimator/zig/tree/h1 contains my WIP
a_chou has joined #zig
<stratact> andrewrk: This chat room is very powerful. I learned about 4 different programming concepts in the past 9 hours. Being here is just great for me.
<andrewrk> happy to hear that
<daurnimator> frmdstryr: http://sprunge.us/RkF916 <-- example usage
<scientes> but given avx-512 you can just unroll the whole loop
<andrewrk> night daurnimator
<daurnimator> andrewrk: night :)
<Snektron> i've never actually worked with a cpu that has avx 512
<stratact> daurnimator: thanks for your help as well. Have a good night
<scientes> Snektron, yeah, I've only used it on VPSes that I got specially because they had it
<scientes> laptops still do not have it
<Snektron> I doubt laptops are going to have it in anywhere near the future
<Snektron> i think it takes a rather large chunk of the die
<scientes> also lots of thermal envelope
cbarrett has joined #zig
<scientes> does avx-512 have predication?
<Snektron> yes
<Snektron> i think there is a new kind of register, a flag register
<scientes> there has always been mask registers
<scientes> (only on x86)
<Snektron> is that not what you meant by predication?
<scientes> predication means you mask lanes for vector operations
<andrewrk> Snektron, I thought most consumer laptops already had it? my /proc/cpuinfo has "avx" in the flags
<scientes> andrewrk, avx and avx2 is avx-256
<andrewrk> ah
<Snektron> on the topic of cpu's
<Snektron> I have a really strange issue with one of my university assignments. Its on sorting, and i implemented a very simple radix sort
<Snektron> however, its twice as fast on my puny laptop cpu versus the server cpu's we are supposed to benchmark on
<scientes> are you sure you are using the right build flags>
<scientes> check with perf
<Snektron> I checked
<Snektron> The biggest differences where that the server does a lot more context switches
<Snektron> but it also has significantly less page faults
<scientes> maybe its due to KVM?
<scientes> virtualization
<scientes> but the main virtualiation overhead is page faults
<Snektron> server has 30% more cache misses even though it has 5 times the amount of cache
<Snektron> i don't think the cpus are virtualized
<Snektron> Since its a supercomputer
<scientes> ../src/ir.cpp:11493:8: error: ‘ConstExprValue’ does not name a type; did you mean ‘ConstErrValue’?
<scientes> what happened?
<scientes> looks like the earth moved below my feet
<mikdusan> rename ConstExprValue -> ZigValue
<fengb> andrewrk: the test change I’d like to make would break all thread safety. I know tests aren’t there yet and wasm isn’t either but I’m a little scared to introduce such a sledgehammer
<andrewrk> fengb, isn't wasm guaranteed to be single-thread?
<fengb> It is right now, but there’s an open proposal
<fengb> And if we can get async working, then we can start getting memory clashes
<andrewrk> how so?
<andrewrk> memory allocation wouldn't suspend
<fengb> I need the page data in a specific state to be testable
<fengb> And I can’t reset it without hosing existing memory. I’m starting to question how useful these tests are to maintain
<fengb> It was helpful for me to find bugs, but it’s really hard to run in a suite
<andrewrk> ah I think I see what's going on here
jicksaw has quit [Ping timeout: 250 seconds]
jicksaw has joined #zig
<fengb> I could check alloced addresses instead. It’s more indirect but a lot less flaky
<fengb> Then I can check reuse and conventional vs extended in almost any context
dingenskirchen has quit [Quit: dingenskirchen]
dingenskirchen1 has joined #zig
a_chou has quit [Ping timeout: 250 seconds]
dingenskirchen1 is now known as dingenskirchen
a_chou has joined #zig
adamkowalski has joined #zig
<adamkowalski> What are the options for runtime polymorphism in Zig? Is it union(enum) for closed sets and something like std.mem.Allocator for open sets? Am I missing anything?
<adamkowalski> What do we call the type of polymorphism that std.mem.Allocator. Do we just say we are constructing a vtable manually?
a_chou has quit [Quit: a_chou]
mforney has joined #zig
adamkowalski has quit [Ping timeout: 240 seconds]
dimenus has quit [Read error: Connection reset by peer]
dimenus has joined #zig
adamkowalski has joined #zig
adamkowalski has quit [Ping timeout: 250 seconds]
WendigoJaeger has joined #zig
<stratact> hmm, what's the best way to trim whitespace from a string? I see std.mem.trim() exists but...
adamkowalski has joined #zig
<stratact> Oh cool, an example on github shows this: std.mem.trim(u8, raw_bytes, " \r\n\t")
adamkowalski has quit [Ping timeout: 240 seconds]
Akuli has joined #zig
<stratact> daurnimator: I'll need advice when you get up. I found what looks to be FreeBSD's terminfo file but it's in an odd place. Would this be the file to parse and tokenize for data like in your Lua program? `/usr/src/contrib/file/magic/Magdir/terminfo` ... I take it in Linux it's in the /usr/share/terminfo directory which makes more sense.
<stratact> I have to wonder why it's not part of the base system but in the source code?
adamkowalski has joined #zig
<stratact> Ooooh, I need to either use the BSD /usr/share/misc/termcap.db or install ncurses. I wonder if termcap is compatible?
waleee-cl has quit [Quit: Connection closed for inactivity]
adamkowalski has quit [Ping timeout: 245 seconds]
wootehfoot has joined #zig
waleee-cl has joined #zig
WendigoJaeger has quit [Quit: Powered by WinIRC]
Akuli has quit [Quit: Leaving]
<lupine> hmph, trying to do day 7 in zig and running up against concurrency. I think
<lupine> could also just be a bug in my machines...
wootehfoot has quit [Read error: Connection reset by peer]
<lupine> well, I call `async machine.run();` - and that call never returns, even though it eventually ends up going all the way to an `std.os.read` which has no data. attaching with gdb, I just see us sat in wait4()
<lupine> switched to threads, it's working now ^^
reductum has joined #zig
<Snektron> nice
<Snektron> I just copy paste my intcode thingy whenever i need it
<Snektron> also, if you guys like that kind of stuff, theres also the synacor challenge: https://challenge.synacor.com/
<Snektron> I did that one in Zig too, but that was last year
<Snektron> its by the same buy apparently
<Snektron> guy
<Snektron> oh btw, andrewrk, i forgot to mention last time that the callbacks in std.sort aren't compile time. Does that mean they are a function pointer?
<fengb> Zig is smart enough to in-line them
<fengb> I’m not sure how that works but it works
<Snektron> i think its a bit weird
<pixelherodev> Function pointer inlining isn't unusual
<Snektron> because b in `fn a(b: fn() void) void` is neither a pointer nor comptime
<pixelherodev> Even *C* has it
<Snektron> pixelherodev, not part of the language spec as far as i know
<mq32> i think it's better to have this as an implementation detail
<mq32> size-optimized code may omit the inlining, speed-optimized code may inline more aggressivly
<Snektron> i'm not quite sure that is the right solution
<mq32> either you have to allow inline specification in the language or you should have that as a compiler option
<mq32> because it's application dependent what is the right choice here
<Snektron> What does it even mean to pass a function by value
<mq32> ask that a functional programmer and he will tell you "what is a value anyways if not a function returning a constant?"
<Snektron> you mean a function returning another function which represents the constant
<fengb> Zig doesn’t really pass by value though
<fengb> Pass by value or constant ref, whichever the compiler decides
wootehfoot has joined #zig
leeward has joined #zig
<leeward> Ask a question, leave for several hours. That's me.
<mq32> welcome back leeward
<leeward> thanks