ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.2 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
alex`` has quit [Ping timeout: 248 seconds]
<FromGitter> <bew> anyone understood this comment? https://github.com/crystal-lang/crystal/issues/6115#issuecomment-390825505 ( @BrucePerens I don't understand it, sorry)
<jeromegn> is there a "thing" to communicate between forked processes in Crystal? a bit like nodejs' messaging within a cluster.
<jeromegn> I could just use a pipe I suppose
<jeromegn> I was wondering about passing a tcp socket (file descriptor) to a forked process.
<FromGitter> <bew> I know this can be done using unix sockets, maybe you search search this way
<FromGitter> <bew> *can
<jeromegn> I'll check that out :)
<FromGitter> <faustinoaq> @bew, see: https://github.com/amberframework/amberframework.org/pull/104 :-D
<FromGitter> <bew> nice, thank you!
<FromGitter> <jwoertink> Aside from `Array#[]` is there another array method to take a slice of an array by passing an offset and a limit? Something similar to Ruby's `Array#slice`
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
greengriminal has quit [Quit: Leaving]
That_Guy_Anon1 has joined #crystal-lang
That_Guy_Anon has quit [Ping timeout: 245 seconds]
<jeromegn> any way to get the file descriptor from an http request / response?
<FromGitter> <bew> @jwoertink don't think so, are you missing sth?
rohitpaulk has joined #crystal-lang
<FromGitter> <bew> jeromegn I don't get it.. a file descriptor is basically an identifier of an open file in a process, I don't think it makes any sense to get it from an http request. What are you trying to do? What's your usecase
<jeromegn> I want the master process to fork processes and then dispatch sockets to those forks
<jeromegn> depending on certain criteria
<jeromegn> I created bindings for https://github.com/sharvil/flingfd (just 2 useful functions) and wanted to try it out with a simple example
<jeromegn> but I guess maybe it's not well suited for http :D
<jeromegn> @bew does that sound possible?
<jeromegn> there's no accessing the underlying socket for an http request. I could expose it some other way though
<FromGitter> <faustinoaq> hehe, so funny XD
<FromGitter> <bew> hmm I don't know, and don't have time right now to really think about it..
<jeromegn> hehe all good
<FromGitter> <bew> jeromegn you can always do the same basic example as in the readme
<FromGitter> <bew> of flingfd
<jeromegn> I'm assuming that works fine
<FromGitter> <bew> But I'd suggest to implement this in Crystal, to have support for the crystal concurrency model. 'cause using this library will completely block the crystal process when you do `flingfd_simple_recv` and other fibers won't be able to run..
<jeromegn> indeed
<jeromegn> once I know it "can" work, I'll probably do that
<FromGitter> <bew> @faustinoaq :D
<FromGitter> <bew> then try the given example, you'll see if it 'can' work ;)
<FromGitter> <jwoertink> @bew no. The `[a...b]` method works, but requires an additional calculation for paginating. Using `slice` would be cleaner
<FromGitter> <bew> what do you mean 'paginating' ?
<FromGitter> <jwoertink> where you take a collection and split it in to smaller collections that you can associate with a number
<FromGitter> <jwoertink> ``` edge = page * limit ⏎ offset = edge - limit ⏎ collection[offset...edge]``` [https://gitter.im/crystal-lang/crystal?at=5b0381fc2df44c2d0647f64c]
<FromGitter> <jwoertink> being able to do `collection.slice(offset, limit)` would be nice
<FromGitter> <bew> there is also `def (start : Int, count : Int)`, maybe that's less calculations?
<FromGitter> <jwoertink> oh, interesting. Let me try that
<FromGitter> <jwoertink> nice! Thanks @bew. That works
<FromGitter> <bew> yw ;) actuall that's how `def (range : Range)` is implemented :P
<FromGitter> <bew> checkout the stdlib sources from time to time, you'll learn a lot ;)
duane has joined #crystal-lang
<jeromegn> @bew I made a TCPServer instead and copy pasted some code to process http requests headers and such. it works, I can pass sockets between process just fine :)
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
notdaniel has joined #crystal-lang
<wmoxam> Am trying to compile crystal from git on OpenBSD using v0.24.2, am not sure what to look at next :P
duane has quit [Ping timeout: 245 seconds]
<wmoxam> ah I bet this is a ulimit thing :p
sz0 has quit [Quit: Connection closed for inactivity]
pabs has quit [Ping timeout: 256 seconds]
pabs has joined #crystal-lang
<FromGitter> <Grabli66> Hi! There is Future class in crystal. But why it's not documented? It's marked with # :nodoc: It's for internal use only? I think it's much better than "spawn" :)
alex`` has joined #crystal-lang
<FromGitter> <bew> Why?
<FromGitter> <Grabli66> Cause it has many useful things, like method "get", that blocks and wait for result. And it catches exceptions from fiber
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
notdaniel has quit [Quit: Leaving]
That_Guy_Anon1 has quit [Quit: Leaving]
mps has left #crystal-lang [#crystal-lang]
johndescs_ has joined #crystal-lang
johndescs_ is now known as johndescs
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 252 seconds]
Raimondii is now known as Raimondi
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
<FromGitter> <straight-shoota> I don't know why it is undocumented, but it's probably going to be removed from stdlib.
<FromGitter> <Grabli66> But why?
rohitpaulk has quit [Ping timeout: 245 seconds]
<crystal-gh> [crystal] sdogruyol pushed 1 new commit to master: https://git.io/vhv5l
<crystal-gh> crystal/master 8c24616 Ary Borenszweig: Fix: faster compilation for JSON::MappingError (#6111)
<FromGitter> <sdogruyol> @Grabli66 concurrent in std definitely needs more love
<FromGitter> <Grabli66> You are right. :) Just dreaming about to see Futures and something like async/await. ⏎ async def mymethod : Future(Int32) ⏎ puts "GOOD" ⏎ end ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5b03f4e4f04ce53632f8c0c5]
rohitpaulk has joined #crystal-lang
<travis-ci> crystal-lang/crystal#8c24616 (master - Fix: faster compilation for JSON::MappingError (#6111)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/382086585
<DeBot> https://github.com/crystal-lang/crystal/pull/6111 (Fix: faster compilation for JSON::MappingError)
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
<FromGitter> <girng> I'm using this as a server.cr https://paste.ee/p/y8GD2 and when I load up a bunch of connections, and close them. I'll get `Connections: 11` lingering around, or that value will be more. Dependent how many sockets I connect and close. And yes, I am terminating the connection from my clientside (I installed CurrPorts on windows), and all the sockets get closed. `netstat -ntu` will show 11 established connections
<FromGitter> ... as well. What causes these sockets to be lingering in the crystal app, is it an issue with an OpenVZ container? I should try this on KVM VPS maybe?
<FromGitter> <bararchy> @girng you are closing them `only` on the client side?
<FromGitter> <girng> Yes, and in server.cr
<FromGitter> <bararchy> You just wait endlessly to the client.read
<FromGitter> <bararchy> What is your read timeout ?
<FromGitter> <girng> Not sure, never set it. I'll set it to something and try again
<FromGitter> <bararchy> Do a reasonable read_timeout, something like a minute?
<FromGitter> <bararchy> depends on your game
<FromGitter> <bararchy> how much time does it makes sense to wait for a client to write info?
<FromGitter> <girng> No idea, it depends on their action. I can add in a ping interval or something?
<FromGitter> <bararchy> yeha
<FromGitter> <bararchy> its a good idea
<FromGitter> <bararchy> if they don't respond to ping in 30 sec kill the socket
<FromGitter> <girng> @bararchy Thank you sir, fixed it
<FromGitter> <bararchy> 👍 :)
<jeromegn> is there a way to ensure something always runs in the root fiber? I think I'll probably need to use a channel, receiving from the root fiber, to run "tasks" sent from all over the place.
<FromGitter> <faustinoaq> jeromegn, `Fiber.yield` or `sleep`
<jeromegn> if I understand correctly, this would just tell the schedule to run a different fiber, but it wouldn't guarantee stuff ran in the root fiber
<FromGitter> <girng> @bararchy Hey, well would you look at that! Now that the connections close, I loaded up tens of thousands of connections. Closed them all, and the memory usage went back down!
<FromGitter> <bararchy> :)
<FromGitter> <bararchy> happy to help
<FromGitter> <bararchy> make sure you configuer ulinmit for the service
<FromGitter> <girng> Hah, yeah.
<FromGitter> <bew> @Grabli66 why would you want async/await when everything is already asynchronous?
<txdv> file io is blocking
<FromGitter> <Grabli66> Cause i think that futures and async/await is simple in usage than fibers and channels.
<FromGitter> <bew> Not really, if it's going to block, the fiber is paused and another fiber will run until the file io unblock, so it doesn't block the whole thread, things can still happen
<FromGitter> <bew> txdv when you say blocking, you meant on the thread level?
<FromGitter> <bew> @Grabli66 do you know how to use fibers/channels? It looks quite simple to me
<FromGitter> <Grabli66> Yes. And i think futures are better :) simpler. You can chain them, you can catch their exceptions, you can await of their execution.
<FromGitter> <bew> You can go implement them in Crystal if you want, i'm sure you 'll help someone else ;)
<FromGitter> <Grabli66> There is Future class in crystal
<FromGitter> <bew> Not that you can use, but you can implement one, documented, that will stay for sure, and with more features! The one you saw is an implementation detail for some method, it's not to be used directly i guess
<FromGitter> <Grabli66> Too hard :)
<txdv> bew: not for file IO
<FromGitter> <bew> Show me the code if you have time, i don't believe you.. Where is it not using evened IO?
<FromGitter> <bew> evented*
<txdv> :D
<txdv> how can i prove something that does not exist bew?
duane has joined #crystal-lang
<txdv> there is no green thread switching in the code reading the files
<txdv> bew: explain this https://carc.in/#/r/2nof
<FromGitter> <Grabli66> I believe you :)
<FromGitter> <bew> urandom does not have an end, you can't read it completely, but that's funny :P
<FromGitter> <bew> Are you sure this PReader is what's used for file io?
<txdv> asdasd
<FromGitter> <txdv> /dev/random is the blocking one?
<FromGitter> <txdv> still returns the same output
<FromGitter> <txdv> i showed you the code, i showed you an example, and all i get is "are you sure?"
duane_ has joined #crystal-lang
<txdv> asd
<txdv> my tmux shit is frozen
<txdv> it accepts input, but it doesn't renew anything
<FromGitter> <Grabli66> But why IO for files is blocking? Why devs did not made it async?
<FromGitter> <txdv> because linux has no non blocking file io
<FromGitter> <txdv> the only working solution is to put it into a thread pool
duane has quit [Ping timeout: 245 seconds]
txdv has quit [Quit: WeeChat 1.9.1]
<FromGitter> <txdv> there is no green thread switching code in this method
<FromGitter> <Grabli66> But. It can be possible to read by blocks and yield a fiber on each read.
<FromGitter> <bew> There is `Scheduler.reschedule`
<FromGitter> <bew> Which does the work
<FromGitter> <txdv> so File.read("/dev/random") should work with a timer printing some random numbers then?
txdv has joined #crystal-lang
<FromGitter> <txdv> because /dev/random is blocking right?
<FromGitter> <bew> I think reading urandom does not block because it's so fast, there is no delay.. I don't know for random
<FromGitter> <txdv> /dev/random does block
<FromGitter> <txdv> when there is not enough entropy
<FromGitter> <bew> I think it's because the `read` call doesn't give you the control back when it's blocking
<FromGitter> <txdv> o my god
<FromGitter> <txdv> "He is not an alcoholic, he just drinks 5 liters of beer every evening!"
<FromGitter> <txdv> i already read it
<FromGitter> <txdv> i already looked at the kernel code
<FromGitter> <bew> The O_NONBLOCK flag has no effect when opening /dev/urandom. When ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b041e71f04ce53632f97541]
<FromGitter> <txdv> yeah, try reading /dev/random then
snsei has joined #crystal-lang
<FromGitter> <bararchy> @txdv It wont return while it's readable
<FromGitter> <bararchy> and because random is always readable, it wont return
<FromGitter> <bew> Wut: https://github.com/crystal-lang/crystal/blob/master/src/file.cr#L32 it sets `unblocking: true` whyy
<FromGitter> <bew> Oops
<FromGitter> <bew> `blocking: true`
<FromGitter> <bararchy> because it's a file
<FromGitter> <bararchy> and a file has a specific size?
<FromGitter> <txdv> ok, try just iterating reading multi gb file on your local machine
<FromGitter> <txdv> and look if any timer event gets read
<FromGitter> <txdv> gets fired
<FromGitter> <bararchy> this?
snsei has quit [Ping timeout: 245 seconds]
<FromGitter> <bararchy> oh, nvm
<FromGitter> <bararchy> I thought it was related
<FromGitter> <bararchy> This is realted -> https://github.com/crystal-lang/crystal/pull/5849
<FromGitter> <bararchy> @bew ?
<FromGitter> <txdv> and how is it related?
<FromGitter> <bararchy> I think there is a bug in unbuffered read
<FromGitter> <bararchy> yeha, nvm, it might not be realted at all, mixed buffered with blocking
<FromGitter> <bew> @txdv note: the class `File::PReader` is not used anywhere
<z64> @bew is it not..? (perhaps anymore?) i apparently ran into it in the wild https://github.com/samueleaton/raze/issues/3#issuecomment-323002485, though looking back now the context doesn't quite make sense to me
<crystal-gh> [crystal] sdogruyol opened pull request #6117: Update project status in README (master...update-readme) https://git.io/vhfBu
<FromGitter> <ArtLinkov> hey guys, I have a situation where I have and array of array of array (etc..) for an unknown number of arrays within an arrays
<RX14> bcardiff is back btw
<RX14> i'm sure you noticed if you were looking at the issue tracker
tilpner has quit [Read error: Connection reset by peer]
tilpner has joined #crystal-lang
<FromGitter> <bew> Oh nice ;) (didn't notice yet, it must be on my unsubscribed issues)
<FromGitter> <sdogruyol> I think it's time for this PR :) https://github.com/crystal-lang/crystal/pull/6117
<FromGitter> <sdogruyol> would love to have more input from the community
<FromGitter> <bew> Yeah good idea!
<FromGitter> <Grabli66> May be set 1.0 version to crystal? :) And say everyone that it's production ready.
<FromGitter> <bew> Huh no?
<Vexatos> sounds like a very good idea
<FromGitter> <sdogruyol> @Grabli66 that'd be a really YOLO way of doing it :)
<FromGitter> <yxhuvud> speaking of YOLO, my latest commit have these stats: 2066 files changed, 25978 insertions(+), 25933 deletions(-). Lets just say I wish ruby had `tool format`
<FromGitter> <sdogruyol> I'd call that `brave`
<FromGitter> <sdogruyol> :D
<FromGitter> <epergo> mm maybe specify current version and a link to the changelog, list companies using it in production, add top 5 sponsors and say that crystal core team main objectives are parallelism and windows support (if these are the objectives ofc)
<crystal-gh> [crystal] RX14 closed pull request #5849: Always read unbuffered when IO::Buffered#sync = true (master...feature/io-buffered-sync-read) https://git.io/vxCg3
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
wontruefree has joined #crystal-lang
<RX14> jhass, you around? Would be nice to get nightly releases working on carc.in, wondering how much work it would be
<travis-ci> crystal-lang/crystal#4e0dc9e (master - Always read unbuffered when IO::Buffered#sync = true (#5849)): The build has errored. https://travis-ci.org/crystal-lang/crystal/builds/382205181
<DeBot> https://github.com/crystal-lang/crystal/pull/5849 (Always read unbuffered when IO::Buffered#sync = true)
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
alex`` has quit [Quit: WeeChat 2.1]
<FromGitter> <bararchy> RX14 he might be on Ruby chan
<RX14> jhass is in the channel
<RX14> the question is whether he's listening
<FromGitter> <manveru> he's just invisible from gitter
<RX14> he's not on gitter
<FromGitter> <manveru> that's what i meant
DTZUZU has quit [Quit: WeeChat 1.9]
<crystal-gh> [crystal] asterite closed pull request #6104: Allow visibility modifiers without a target (similar to Ruby) (master...feature/visibility-without-exp) https://git.io/vphIn
DTZUZU has joined #crystal-lang
<FromGitter> <Grabli66> Please, tell me why? https://play.crystal-lang.org/#/r/4430
wontruefree has quit [Quit: bye]
wontruefree has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
<z64> looks like some kind of overflow internally, if i had to guess
<FromGitter> <Grabli66> I think it's a bug :)
<FromGitter> <r00ster91> what about adding ` : Int32` at `year`, `month` and `day`?
<FromGitter> <Grabli66> Then it works
sz0 has joined #crystal-lang
<FromGitter> <r00ster91> I think I will make a PR
<FromGitter> <Grabli66> Great
Nik736 has joined #crystal-lang
<crystal-gh> [crystal] r00ster91 opened pull request #6118: Fix Time.new and Time.utc (master...patch-3) https://git.io/vhJJF
return0e_ has joined #crystal-lang
<z64> why break other larger containers
Jenz has joined #crystal-lang
<FromGitter> <faustinoaq> Hey @/all can you 👍 this: https://github.com/inch-ci/inch_ci-web/issues/147 ? Would be nice to have doc coverage on crystal 😅
That_Guy_Anon has joined #crystal-lang
Jenz has quit [Quit: Reconnecting]
Jenz has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
Jenz has quit [Ping timeout: 240 seconds]
<FromGitter> <faustinoaq> https://www.techempower.com/benchmarks/#section=test&runid=ae097e87-3b23-402c-8f51-1608e16dd11a
<FromGitter> <faustinoaq> Oh god!, JVM Frameworks are incredibly fast 
<FromGitter> <faustinoaq> Almost 10x faster than crystal, go, even some Rust frameworks 😅
<FromGitter> <faustinoaq> I'm wondering how JVM is so fast
<FromGitter> <faustinoaq> Also ASP.Net is performing very well, almost same as JVM
<FromGitter> <faustinoaq> The only frameworks faster than JVM and .Net are raw C++/C things like h2o or ulib
<FromGitter> <faustinoaq> Maybe we can create some bindings to h2o or even ulib, WDYT?
Jenz has joined #crystal-lang
<FromGitter> <faustinoaq> Would h2o/ulib bindings perform better than Crystal `HTTP::Server`?
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
<jeromegn> woah, didn't know we had access to run ids
<jeromegn> *test runs, I mean
<jeromegn> how long ago was that test ran? how come stuff got so fast all of a sudden!
<jeromegn> the fastest plaintext run in round 15 was 2.7 Mil
<jeromegn> but in this run it's over 7 Mil
<FromGitter> <Grabli66> I dont believe in that benchmarks. :)
<jeromegn> I believe in it when it favors Crystal
<jeromegn> :D
wontruefree has quit [Quit: bye]
<FromGitter> <bew> Hehe of course ^^
<FromGitter> <bew> @faustinoaq I believe there are some improvements we could do by avoiding copies and mem allocations to be faster
Jenz has quit [Quit: Lost terminal]
wontruefree has joined #crystal-lang
duane_ has quit [Ping timeout: 248 seconds]
Nik736 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
snsei has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
moei has quit [Quit: Leaving...]
That_Guy_Anon has quit [Quit: Leaving]
moei has joined #crystal-lang
wontruefree has quit [Quit: bye]
rohitpaulk has joined #crystal-lang
pabs has quit [Ping timeout: 252 seconds]
pabs has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]