RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.20.1 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
sp4rrow has joined #crystal-lang
sp4rrow has quit [Read error: Connection reset by peer]
sp4rrow_ has joined #crystal-lang
_whitelogger has joined #crystal-lang
hako has quit [Ping timeout: 260 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 250 seconds]
pawnbox has joined #crystal-lang
snsei has joined #crystal-lang
triangles2 has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
triangles has quit [Ping timeout: 268 seconds]
snsei has quit [Ping timeout: 245 seconds]
pduncan has quit [Ping timeout: 245 seconds]
pduncan has joined #crystal-lang
pduncan has quit [Ping timeout: 258 seconds]
snsei has joined #crystal-lang
pduncan has joined #crystal-lang
z64 has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
matp has quit [Remote host closed the connection]
matp has joined #crystal-lang
triangles2 has quit [Quit: Leaving]
bjz has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
pduncan has quit [Ping timeout: 240 seconds]
soveran has quit [Ping timeout: 250 seconds]
<crystal-gh> [crystal] dylandrop opened pull request #3675: Add documentation to Array#pop (master...add-documentation-to-pop) https://git.io/v1KnH
sp4rrow_ has quit [Quit: The Internet needs a break and I need a cookie]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
bjz has joined #crystal-lang
mooe has joined #crystal-lang
<mooe> Hi, is there an easy way to convert an array to hash in crystal? ['a', 'b', 'c', 'd'] -> {"a"=>"b", "c"=>"d"}
<mooe> in ruby you can do Hash[*arr], but I don't think that works (I can't get it to atleast)
<FromGitter> <jwoertink> You have an Array(Char) and want a Hash(String, String)?
<mooe> yeah
<mooe> well array(string)
<FromGitter> <bararchy> mooe: are you sure those are 'chars' in the array ? or did you mean array(String)
<FromGitter> <bararchy> ok :)
<FromGitter> <jwoertink> Single quote is not a string. Gotta be careful of that :)
<FromGitter> <jots_twitter> if you can get your array like: `[["a","b"],["c","d"]].to_h`
<FromGitter> <jwoertink> As for a "easy" way...
<FromGitter> <jwoertink> Yeah that ^
<mooe> alright, cool, thanks
<FromGitter> <jots_twitter> also: `h = {} of String => String; ["a","b","c","d"].each_slice(2) { |i| h[i.first] = i.last }`
<FromGitter> <jots_twitter> nice that some stackoverflow ruby works for crystal :-)
pawnbox has quit [Remote host closed the connection]
snsei has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 250 seconds]
sp4rrow has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 258 seconds]
pawnbox has quit [Remote host closed the connection]
soveran has joined #crystal-lang
stnly has joined #crystal-lang
pawnbox has joined #crystal-lang
akwiatkowski has joined #crystal-lang
mark_66 has joined #crystal-lang
akwiatkowski has quit [Quit: Konversation terminated!]
<Yxhuvud> [1,2,3,4].each_slice(2).to_h also works
<Yxhuvud> (it also works in ruby, FWIW)
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
gloscombe has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
gloscombe has quit [Quit: Lost terminal]
gloscombe has joined #crystal-lang
crystalmq has joined #crystal-lang
<crystalmq> Hello all, I was having a problem with sockets being 'saturated'.
<crystalmq> And now, I've simplifed some code, and was wondering if anyone would be kind enough to take a look to see if it's my mistake or a bug.
<FromGitter> <bararchy> socket << "message" will be better
<FromGitter> <bararchy> ```code paste, see link``` ⏎ ⏎ Why not just sleep 1 ? [https://gitter.im/crystal-lang/crystal?at=584e78a5be9d43bc634ce9c5]
unshadow has joined #crystal-lang
<crystalmq> @bararchy sleep 1 seems to yield the same results.... but the effect doesn't change.
<FromGitter> <bararchy> crystalmq: Does your issue is that it's blocking ?
<crystalmq> bararchy: It seems like it, I would expect the requests to be stable - but it seems like if I have two sockets inputting and outputting at a high volume, only one socket gets processor time, the other doesn't
<crystalmq> I'm not exactly sure what is causing it, I'm quite new to Crystal, but I am a rubyist.
<crystalmq> The reason I noticed this, is because I was benchmarking a test message queue written in crystal and noticed when the requests got high enough this effect happened, eventually it would get killed by the OOM killer.
<crystalmq> So, i tried to reproduce the problem in the simplest form... which i have done thankfully.
<crystalmq> But this is way beyond my knowledge level, so i thought to reach out to the community before creating a git issue to make sure it wasnt my fault.
<FromGitter> <bararchy> crystalmq: I commented on both your codes
<FromGitter> <bararchy> in the gist
<FromGitter> <bararchy> try those samples and tell me if you see any change
<crystalmq> @bararchy testing now
<FromGitter> <bararchy> Now, usually sockets in crystal (as oppose to ruby defaults) are non_blocking, so a socket.read will return with or without any data, just poitning it out
<FromGitter> <bararchy> this is whay a good thing is to check if `socket.read > 0`
<crystalmq> Understood.
<crystalmq> Now I'm getting a broken pipe
<crystalmq> Error writing file: Broken pipe (Errno)
<crystalmq> (on the sender)
<FromGitter> <bararchy> This is good, it means that on of your parts (client or server) closes the socket
<FromGitter> <bararchy> on=one
<FromGitter> <bararchy> why not create a new socket for each message ?
<FromGitter> <bararchy> and closing the used one after each write\read
<crystalmq> A new socket would be wasteful especially when under heavy load (~150k/sec)
<crystalmq> Plus, there would be significant operating system load in spawning that many new sockets
<FromGitter> <bararchy> Hm.... then we need to figure out who closes the socket and why
<crystalmq> ah, i know why the connection is being closed
<crystalmq> its because your new code removed the loop :D
<FromGitter> <bararchy> Oh, my mistake then XD
<crystalmq> Just added in the loop
<FromGitter> <bararchy> I just wanted to show the approche regarding socket read\write operations
<crystalmq> (and updated the gist)
<FromGitter> <bararchy> does it work now ?
<crystalmq> Nope, in fact it makes the symptoms worse surprisingly
<crystalmq> let me create a new gist
<FromGitter> <bararchy> 404 page not found
<FromGitter> <bararchy> secret gist maybe ?
<crystalmq> Ah
<crystalmq> Looks like my account has been flagged annoyingly
<crystalmq> one moment
<BlaXpirit> wow, the account is just gone wtf
<crystalmq> "Your account has been flagged. Because of that, your profile is hidden from the public. If you believe this is a mistake, contact support to have your account status reviewed." :(
<FromGitter> <bararchy> Oo
<FromGitter> <bararchy> wierd
<crystalmq> Very weird.
<FromGitter> <bararchy> anyway, why is the sleep there ?
<crystalmq> The sleep is there because without it - you get the second example
<crystalmq> Where, there's a large number of requests then... 0
<FromGitter> <bararchy> hm.....
<crystalmq> It seems to give the inbound socket time to 'release' to allow other things to be processed
<FromGitter> <bararchy> Oh
<FromGitter> <bararchy> I know
<crystalmq> if i dont add the sleep, it will never stop processing the inbound data
<FromGitter> <bararchy> do
<FromGitter> <bararchy> socket.flush
<crystalmq> where?
<crystalmq> which end
<FromGitter> <bararchy> both, on each "write" or << operation ⏎ ⏎ socket << "msg" ⏎ socket.flush ⏎ ... [https://gitter.im/crystal-lang/crystal?at=584e7e80bb7d528222e9a51c]
<FromGitter> <bararchy> this will force the socket to finish writing before moving to do other stuff
<crystalmq> Ok one moment
<crystalmq> client << payload[0, msg] client.flush
<crystalmq> woops
<unshadow> Wow, the gitter <> IRC bot looks wierd
<unshadow> haha
<crystalmq> hey @unshadow. We spoke yesterday (my time) :)
<unshadow> Same dude unshadow=bararchy
<unshadow> :)
<crystalmq> *faceplam*
<unshadow> unshadow in IRC
<unshadow> hahah
<crystalmq> the socket.flush didn't do anything. Could it be because the socket is constantly writing
<crystalmq> that it has no time to receive any data back?
<unshadow> well, the underlying socket should have two buffers read,write
<unshadow> so there should not be any issues there
<unshadow> this is how IO.select(read,wrrite) works
<unshadow> can you pase the whole code snippet again ? I'll take a longer look
<unshadow> paste*
<crystalmq> Yeah, let me just adjust the example slightly
<crystalmq> give me 5 min
<FromGitter> <bararchy> Sure :)
unshadow has quit [Quit: leaving]
ponga has quit []
pawnbox has joined #crystal-lang
<crystalmq> @unshadow
<crystalmq> with my app I'm noticing some intersting behaviour
soveran has quit [Remote host closed the connection]
leafybasi has quit [Ping timeout: 260 seconds]
mooe has quit [Quit: Connection closed for inactivity]
gloscombe has quit [Ping timeout: 258 seconds]
leafybasi has joined #crystal-lang
gloscombe has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
snsei has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
snsei has quit [Ping timeout: 245 seconds]
crystalmq has quit [Ping timeout: 260 seconds]
p0p0pr37_ has joined #crystal-lang
p0p0pr37 has quit [Read error: Connection reset by peer]
p0p0pr37_ is now known as p0p0pr37
bjz has quit [Ping timeout: 256 seconds]
bjz has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
<crystal-gh> [crystal] rbviz opened pull request #3678: Fix SDL samples on linux (master...fix-sdl-samples-on-linux) https://git.io/v1K5e
crystalmq has joined #crystal-lang
<crystalmq> @RX14 @unshadow
<crystalmq> Problem solved.
<crystalmq> It was the event loop being exhausted. I had an erroneous spawn inside the message distribution block that was starting a new fiber for each message being sent.
<crystalmq> When we reached 150k/messages a second, there wasn't enough room left to process anything else, so it ground to a halt. After removing that event block we're happing pushing 300k/messages a second now.
<crystalmq> *spawn
z64 has joined #crystal-lang
gloscombe has quit [Quit: Lost terminal]
pawnbox has joined #crystal-lang
gloscombe has joined #crystal-lang
<Yxhuvud> Suppose I have an ordered array. What is the most efficient way to insert a new number into that? (or alternatively, so we have any better data structure for that?)
<Yxhuvud> or even more alternatively speaking, if we have a priority queue then that would be even neater
<BlaXpirit> Yxhuvud, if the insertions tend towards the beginning or the end, Deque can outperform Array. but if it's uniform, then it probably won't
<Yxhuvud> the simplicity of doing << followed by sort_by! beats that, even if the performance may be better
<FromGitter> <sdogruyol> @crystalmq that's amazing
<Yxhuvud> good to know that external resources like that exist, even if I need to keep to stdlib in this particular case
mgarciaisaia has joined #crystal-lang
<FromGitter> <spalladino> @crystalmq those are truly awesome numbers! Are you planning to run it on a production environment? If so, do send us a shout-out, we'd love to add it to the list.
gloscombe has quit [Ping timeout: 250 seconds]
gloscombe has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
mgarciaisaia has quit [Ping timeout: 260 seconds]
pduncan has joined #crystal-lang
crystalmq has quit [Ping timeout: 260 seconds]
vivus-ignis has joined #crystal-lang
mark_66 has quit [Remote host closed the connection]
mgarciaisaia has joined #crystal-lang
mark_66 has joined #crystal-lang
<FromGitter> <bararchy> > **<crystalmq>** When we reached 150k/messages a second, there wasn't enough room left to process anything else, so it ground to a halt. After removing that event block we're happing pushing 300k/messages a second now. ⏎ ⏎ ⏎ How did you remove the event block ? [https://gitter.im/crystal-lang/crystal?at=584ec738be9d43bc634ec0f3]
dostoyevsky has quit [Quit: leaving]
dostoyevsky has joined #crystal-lang
asterite has quit [Ping timeout: 250 seconds]
DeBot has quit [Ping timeout: 260 seconds]
jhass has quit [Ping timeout: 268 seconds]
jhass has joined #crystal-lang
asterite has joined #crystal-lang
leafybasi has quit [Ping timeout: 258 seconds]
pawnbox has quit [Read error: Connection reset by peer]
pawnbox has joined #crystal-lang
leafybasi has joined #crystal-lang
<FromGitter> <samueleaton> Is there a Crystal parser comparable to https://github.com/ternjs/acorn that breaks files down into tokens and whatnot? The goal is to build some more tooling on top of Crystal.
<RX14> @samueleaton you can use the crystal lexer
<RX14> just require the parts you need from the crystal compiler
<RX14> yeah probably
<FromGitter> <spalladino> @samueleaton you can use the doc generator as inspiration, which walks the program's types and methods https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/tools/doc/generator.cr
<FromGitter> <samueleaton> @spalladino I was the last person to commit to that file and didn't even remember until I saw some code that looked too familiar haha! 😆 Thanks! very helpful.
<FromGitter> <spalladino> Hahahahah I didn't notice your name at the top :-P
lacour has joined #crystal-lang
<crystal-gh> [crystal] Sija opened pull request #3680: Implement HTTP::WebSocket#on_{ping,pong} handler (master...websocket-ping) https://git.io/v16Mr
<crystal-gh> [crystal] trans closed pull request #3608: YAML support for emitting tags and style (master...emit-tags) https://git.io/v1Y1v
gloscombe has quit [Quit: Lost terminal]
sp4rrow has joined #crystal-lang
mark_66 has quit [Remote host closed the connection]
Ven has joined #crystal-lang
pawnbox_ has joined #crystal-lang
pawnbox has quit [Read error: No route to host]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<crystal-gh> [crystal] asterite pushed 4 new commits to master: https://git.io/v16hj
<crystal-gh> crystal/master d17c248 Ary Borenszweig: IO::Sized: optimized `gets`
<crystal-gh> crystal/master 08fa553 Ary Borenszweig: Don't consider var as nilable if conditionally assigned inside initialize, but has initializer. Fixes #3669
<crystal-gh> crystal/master 44a2fc4 Ary Borenszweig: Implement optimized `ARGF#gets`. Fixes #3667
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/v16jU
<crystal-gh> crystal/master a7135c8 TSUYUSATO Kitsune: Allow to pass IO to from_yaml
pawnbox_ has quit [Remote host closed the connection]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/v16js
<crystal-gh> crystal/master dfc4367 TSUYUSATO Kitsune: Clean up empty line on crystal init lib
<crystal-gh> [crystal] Sija opened pull request #3681: Use Slice.empty and Bytes consistently throughout the codebase (master...slice-empty) https://git.io/v1ieR
olbat has quit [Ping timeout: 268 seconds]
<travis-ci> crystal-lang/crystal#a34f32f (master - HTTP::UnknownLengthContent: optimized `gets`): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/183344731
mooe has joined #crystal-lang
<travis-ci> crystal-lang/crystal#a7135c8 (master - Allow to pass IO to from_yaml): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/183344925
greengriminal has joined #crystal-lang
vivus-ignis has quit [Ping timeout: 250 seconds]
djbell has quit [Ping timeout: 245 seconds]
sp4rrow has quit [Read error: Connection reset by peer]
sp4rrow has joined #crystal-lang
sp4rrow has quit [Quit: The Internet needs a break and I need a cookie]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/v1iBz
<crystal-gh> crystal/master f850fa0 Ary Borenszweig: Travis: don't run in verbose mode anymore
<FromGitter> <taylorfinnell> hello! is the verbose fomatter (crystal spec -v) excluded from the help list (crystal spec -h) for some reason? it looks to me like it may have some formatting issues so perhaps that is why it is not documented
<RX14> you need to use crystal spec -- --help
<RX14> there are two sets of options
<RX14> options for the compiler, and options for the spec executable
<travis-ci> crystal-lang/crystal#dfc4367 (master - Clean up empty line on crystal init lib): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/183345431
<FromGitter> <taylorfinnell> sorry, I was not clear. I am wondering why the verbose spec formatter is not documented. why is it not in the available options for crystal spec -h
<FromGitter> <taylorfinnell> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=584f180e28d755bf14f89e1b]
<FromGitter> <taylorfinnell> `-v` is not shown
<FromGitter> <taylorfinnell> i suspect it's because it's a little buggy
<FromGitter> <taylorfinnell> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=584f181cbe9d43bc6350d6c6]
<FromGitter> <taylorfinnell> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=584f1827b4ffd59e381d745f]
<crystal-gh> [crystal] asterite closed pull request #3611: Ensure wrapper usage (master...feature/ensure-wrapper) https://git.io/v13eT
<RX14> because those options are the compiler help
<RX14> and only shows the compiler options
<RX14> verbose is a spec option
<FromGitter> <taylorfinnell> ohh
<FromGitter> <taylorfinnell> i totally missed your `crystal spec -- --help` comment
<FromGitter> <taylorfinnell> so sorry! thank you!
<crystal-gh> [crystal] asterite closed pull request #3621: Add missing --no-color option to spec and eval command (master...fix/add-no-color-option-to-spec-and-eval) https://git.io/v1n7F
<FromGitter> <taylorfinnell> i wonder if the strange output is something on my end, or a bug in the formatter
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/v1iu5
<crystal-gh> crystal/master c5e1388 rogerdpack: make builds cross compile to correct target if using the llvm triple (--target) x86_64-apple-darwin16.1.0 which my sierra box with llvm 3.9 advertises
Ven has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/v1iz9
<crystal-gh> crystal/master 898a7ee Dylan Drop: Fixes #3547; as call with implicit receiver when invoked as a parameter to a method call
sp4rrow has joined #crystal-lang
<crystal-gh> [crystal] asterite closed pull request #3671: Improve rehash when collision is high (master...optimize-rehash) https://git.io/v1oEO
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Remote host closed the connection]
<travis-ci> crystal-lang/crystal#f850fa0 (master - Travis: don't run in verbose mode anymore): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/183384615
<crystal-gh> [crystal] asterite pushed 4 new commits to master: https://git.io/v1iDS
<crystal-gh> crystal/master 351bdf3 Ary Borenszweig: Codegen: add missing location to TypeCastError
<crystal-gh> crystal/master e06e747 Ary Borenszweig: String: avoid allocating memory when creating an empty string from bytes
<crystal-gh> crystal/master 7621d03 Ary Borenszweig: Formatter: fixed a few cases with special calls and implicit self receiver
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
<travis-ci> crystal-lang/crystal#0fc091e (master - Mention make help in contributing guide + other fixes): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/183391925
z64 has quit [Quit: can i go home now?]
bjz has joined #crystal-lang
bjz has quit [Client Quit]