ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <domgetter> To play with that, I'll have to rebuild the compiler, right?
<FromGitter> <domgetter> I can't seem to be able to build that at all
<FromGitter> <domgetter> Does this do anything? https://crystal-lang.org/api/1.2.1/LLVM/Type.html#vector%28count%29%3Aself-instance-method
<FromGitter> <domgetter> I tried making a LLVM::Type.new but the compiler just complains `Error: undefined constant LLVM::Type`
<FromGitter> <Blacksmoke16> afaik most stuff in `LLVM` isn't really a public API?
<FromGitter> <Blacksmoke16> prob have to require it
<FromGitter> <Blacksmoke16> `require "llvm"`
<FromGitter> <domgetter> Okay that worked, but I don't understand how to make a `LLVM::Type.new`. It wants a `LibLLVM::TypeRef` but I don't really know what that means
<FromGitter> <Blacksmoke16> what are you trying to do?
<FromGitter> <domgetter> My ultimate goal is to get LLVM to vectorize 8 Float32s
<FromGitter> <domgetter> So I figure if I tell it there's a vector there, it will do the job
<FromGitter> <domgetter> Here's a snippet of my code
<FromGitter> <domgetter> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=6189d3aaa41fd206993113b9]
<FromGitter> <domgetter> I was hoping to get LLVM to turn that into an FMA with AVX2, but I don't know how to communicate to LLVM through Crystal that this should be treated as an 8-element vector of singles
<FromGitter> <domgetter> And it doesn't seem to "notice" it, since the runtime is much slower than it should be (i.e. 8x slower)
<FromGitter> <Blacksmoke16> did you build with `--release`?
<FromGitter> <domgetter> Yes
<FromGitter> <Blacksmoke16> maybe something useful in https://github.com/crystal-lang/crystal/issues/3057?
<FromGitter> <Blacksmoke16> have a feeling it would need compiler support, like the fork is doing. idk the state of it but rebasing on master and getting it working could be a good stat :shrug:
<FromGitter> <domgetter> I'll give that a shot, thanks
<FromGitter> <Blacksmoke16> start*
postmodern has quit [Read error: Connection reset by peer]
adam12 has quit [*.net *.split]
wolfshappen has quit [*.net *.split]
Vexatos has quit [*.net *.split]
wolfshappen has joined #crystal-lang
adam12 has joined #crystal-lang
Vexatos has joined #crystal-lang
wolfshappen has quit [Max SendQ exceeded]
ur5us has quit [Ping timeout: 240 seconds]
wolfshappen has joined #crystal-lang
hightower3 has joined #crystal-lang
sorcus has quit [Ping timeout: 268 seconds]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 250 seconds]
ur5us has joined #crystal-lang
<FromGitter> <jrei:matrix.org> Is there a way to listen to IO writes, like inotify for files but here for IOs? Or, do I have to use the basic sleep loop to continuously check for new bytes?
ur5us has quit [Ping timeout: 264 seconds]
<yxhuvud> jrei: What kind of IO?
<FromGitter> <jrei:matrix.org> IO::Memory. Ideally, I'd like to to some processing for each line line written on it
<yxhuvud> Then no. If it had been a pollable IO based on file descriptors then wait_readable would work, but IO::Memory is just a chunk of memory with the same api without the same support from the OS. (assuming *nix, windows doesn't really have the same model with readability)
<FromGitter> <jrei:matrix.org> I use IO::Memory, but could an other thing I guess. Basically, what I need: ⏎ ⏎ 1) spawn a third party process inside crystal ⏎ 2) gets its output, and do some processing for each line [https://gitter.im/crystal-lang/crystal?at=618a544829ddcd0293712c1a]
<FromGitter> <jrei:matrix.org> hum... could make the process write into a file, then use inotify - may be overkill
<FromGitter> <jrei:matrix.org> Another thing is IO::Memory#gets does not discard what has been read...
<FromGitter> <jrei:matrix.org> but that's logical
<yxhuvud> I believe it should be possible to use pipes for that, simply spawn another fiber that read each line.
<yxhuvud> (and tell spawn to redirect output into the pipe)
<FromGitter> <jrei:matrix.org> For now I use the block variant of Process.run, then do a loop inside it
taskylizard has joined #crystal-lang
taskylizard has quit [Remote host closed the connection]
taskylizard has joined #crystal-lang
taskylizard has quit [Changing host]
taskylizard has joined #crystal-lang
<FromGitter> <Dan-Do> @jrei:matrix.org Sounds like my work on nodejs for crystal. I used Channel to communicate.
<FromGitter> <Dan-Do> Whenever there is a command send to REPL (started by Process.run), the Channel now that there is something expected on the stdout, so I just readline on that IO
<FromGitter> <jrei:matrix.org> In my case it is a long lived, single Process.run
<FromGitter> <jrei:matrix.org> Ok the REPL is one too
<FromGitter> <jrei:matrix.org> I don't get how channel can help?
<FromGitter> <Dan-Do> yeah, same as node, just start once then send command to REPL
<FromGitter> <Dan-Do> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=618a65f638377967f4a0fc2a]
<FromGitter> <Dan-Do> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=618a6643f2cedf67f9d55976]
<FromGitter> <Dan-Do> basically, just loop then `.gets`, it's non-blocking
taskylizard has quit [Remote host closed the connection]
taskylizard has joined #crystal-lang
<FromGitter> <jrei:matrix.org> I can just do ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=618a681c7db1e3753e8ebd03]
<FromGitter> <jrei:matrix.org> and do the gets inside the sleep.
taskylizard has quit [Remote host closed the connection]
taskylizard has joined #crystal-lang
<FromGitter> <jrei:matrix.org> What I find is, as-is, the gets will always be empty. I have to deal with `pos` also
taskylizard has joined #crystal-lang
taskylizard has quit [Changing host]
taskylizard has quit [Remote host closed the connection]
taskylizard has joined #crystal-lang
taskylizard has quit [Remote host closed the connection]
taskylizard has joined #crystal-lang
taskylizard has quit [Remote host closed the connection]
taskylizard has joined #crystal-lang
taskylizard has quit [Changing host]
taskylizard has joined #crystal-lang
taskylizard has quit [Client Quit]
<FromGitter> <jrei:matrix.org> In Crystal, modules and mixins are the same?
ox is now known as oz
<FromGitter> <jrei:matrix.org> I've seen it in the docs, I find more confusing than just calling it the usual way - module
sorcus has joined #crystal-lang
<FromGitter> <jrei:matrix.org> @Dan-Do: I'll end up using a custom IO, with a custom logic inside `CustomIO#write` :)
<FromGitter> <Blacksmoke16> could also use a multiwriter and just have your custom IO to react to writes but not actually do the writing. Or i suppose decorating the actual IO would prob be easier
<FromGitter> <jrei:matrix.org> On my case it will be more a multireader - read both stdout and stderr, and somehow merge them into a single stream
<FromGitter> <jrei:matrix.org> and having a lock to prevent them to write at the same time of course
<FromGitter> <jrei:matrix.org> or, I may not even need a lock in not on a multi-threaded environment? unsure
hightower2 has joined #crystal-lang
hightower3 has quit [Ping timeout: 250 seconds]
<FromGitter> <oprypin:matrix.org> j8r (https://matrix.to/#/@jrei:matrix.org): uuummm just so you know, there's an OS level feature to give you an already merged stream from those two
<FromGitter> <naqvis> > I use IO::Memory, but could an other thing I guess. Basically, what I need: ⏎ > 1. spawn a third party process inside crystal ⏎ > 2. gets its output, and do some processing for each line ⏎ ⏎ @jrei:matrix.org you can take a look at how i've done the very same in playwright_cr (https://github.com/naqvis/playwright-cr) ... [https://gitter.im/crystal-lang/crystal?at=618aa33dee6c260cf76c2133]
<FromGitter> <jrei:matrix.org> oprypin (https://matrix.to/#/@oprypin:matrix.org): but I don't really want them pre-merged, I need to identify what's stderr and stdout, then merge them in to a given data format
<FromGitter> <jrei:matrix.org> @naqvis: The code looks clever. Can you point me to the relevant parts? From what I've seen it may be related to Stream or Transport?
<FromGitter> <naqvis> yeah, `Transport` class is what wraps those stdin/stdout pipes
<FromGitter> <jrei:matrix.org> What you have done sound similar from what @Dan-Do suggested
<FromGitter> <jrei:matrix.org> Why using Channels, for example `@outgoing.send`, instead of directly calling a method to do the logic?
<FromGitter> <jrei:matrix.org> like `@write.do_some_processing(message)`?
<FromGitter> <naqvis> for async communication
<FromGitter> <naqvis> directly calling method would have blocked the execution
<FromGitter> <naqvis> STDIO/OUT communication is done in fibers
<FromGitter> <jrei:matrix.org> what would block?
<FromGitter> <jrei:matrix.org> because if the processing is quick and the operations mainly IO bound, it won't change much
<FromGitter> <naqvis> don't know your use-case, but for my particular use-case, that wasn't the option
<FromGitter> <oprypin:matrix.org> j8r (https://matrix.to/#/@jrei:matrix.org): um in your case you're reading two streams, so you need two fibers surely? ⏎ i know generally this is solvable with a `select` but Crystal just doesn't make it natural to use
<FromGitter> <jrei:matrix.org> the processing can be long?
<FromGitter> <oprypin:matrix.org> `select` is either deprecated or removed or something like that
<FromGitter> <jrei:matrix.org> I don't need fiber at al
<FromGitter> <oprypin:matrix.org> so is your problem solved, then?
<FromGitter> <naqvis> > the processing can be long? ⏎ ⏎ yes, because playwright does things in browsers
<FromGitter> <jrei:matrix.org> One custom IO for STDERR, another one for STDOUT, and they both write to a single store. Yeah I figured this out
<FromGitter> <jrei:matrix.org> @naqvis: Fair enough then!
<FromGitter> <jrei:matrix.org> on my case the processing is fairly quick
<FromGitter> <naqvis> then you can just work on STDIN/OUT pipes directly
<FromGitter> <oprypin:matrix.org> OK so `select` is not deprecated at all, but this is the entire list of actions it supports: `Channel#send #receive #receive? #timeout` `Fiber #timeout .timeout`
<FromGitter> <oprypin:matrix.org> searched via `crystal$ git grep -E 'def.+select_action'`
<FromGitter> <jrei:matrix.org> What I do basically ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=618aada6d78911028a2c1712]
<FromGitter> <oprypin:matrix.org> as I understand, there is no way at all to process two IO streams at once without involving fibers at some point
<FromGitter> <oprypin:matrix.org> j8r (https://matrix.to/#/@jrei:matrix.org): hmm maybe that can work, but sometimes Process likes to receive only a real OS-level pipe, not a fake IO. have you verified this?
<FromGitter> <naqvis> > as I understand, there is no way at all to process two IO streams at once without involving fibers at some point ⏎ true, but j8r is stating that IO activity doesn't take long, so assume he would be going sequentially, write_io and then read_io
<FromGitter> <jrei:matrix.org> oprypin (https://matrix.to/#/@oprypin:matrix.org): https://github.com/crystal-lang/crystal/blob/ffc5523/src/process.cr#L241
<FromGitter> <jrei:matrix.org> stdio_to_fd is probably what you meant
<FromGitter> <oprypin:matrix.org> j8r (https://matrix.to/#/@jrei:matrix.org): aah then you're in luck! there's the hidden fiber :)
<FromGitter> <oprypin:matrix.org> so indeed, since Process requires an OS-level pipe, for custom IOs Crystal implicitly spawns a fiber just to forward data from the pipe to an IO if the IO is not already an OS-level one
<FromGitter> <jrei:matrix.org> True, there are this hidden fibers out there in Crystal 😄
<FromGitter> <oprypin:matrix.org> so i think you're not gaining anything by choosing to write a custom io instead of explicit fibers
<FromGitter> <jrei:matrix.org> How would you do that, which channels?
<FromGitter> <oprypin:matrix.org> spawn { loop { read stdout, write into logger } } ⏎ spawn { loop { read stderr, write into logger } }
<FromGitter> <jrei:matrix.org> another advantage here is I don't need any additional `while true` loop
<FromGitter> <jrei:matrix.org> how it is better?
<FromGitter> <oprypin:matrix.org> doesn't involve an extra implicit pipe
<FromGitter> <oprypin:matrix.org> and avoids the need of creating a custom IO class
<FromGitter> <jrei:matrix.org> what IO will I pass to `Process`?
<FromGitter> <oprypin:matrix.org> none. https://crystal-lang.org/api/1.2.0/Process/Stdio.html Pipe
<FromGitter> <oprypin:matrix.org> and then you can read directly from it
<FromGitter> <oprypin:matrix.org> https://crystal-lang.org/api/1.2.0/Process.html#output%3AIO%3A%3AFileDescriptor-instance-method
<FromGitter> <jrei:matrix.org> ha ok I see, I didn't know that
<FromGitter> <jrei:matrix.org> yeah definitely better then.
<FromGitter> <jrei:matrix.org> I always found Process is Crystal is not very easy to get right, and what we want. Having few docs does not help :/
<FromGitter> <oprypin:matrix.org> yea i just know what to expect from it due to experience with Python where everything is pretty much the same
<FromGitter> <jrei:matrix.org> Thanks, it works by using `Process#new`, not forgetting to define `:pipe` for output and error, spawn after at the end `Process#wait`
<FromGitter> <oprypin:matrix.org> very glad to hear
notzmv has quit [Ping timeout: 240 seconds]
Peter0x41 has joined #crystal-lang
^raz^ has joined #crystal-lang
raz has quit [*.net *.split]
Peter0x44 has quit [*.net *.split]
ur5us has joined #crystal-lang
hightower2 has quit [Ping timeout: 250 seconds]
f1refly has quit [Read error: Connection reset by peer]
f1refly has joined #crystal-lang
notzmv has joined #crystal-lang
antoni is now known as antoszka