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
faustinoaq has joined #crystal-lang
faustinoaq has quit [Ping timeout: 260 seconds]
<FromGitter> <girng> nice, now github homepage shows my issues
<FromGitter> <girng> i don't like this
<FromGitter> <girng> how i switch back
<FromGitter> <girng> ok im trying to figure out why my code is acting like a bottleneck when over 50 games are run. which is 750 iterations per second, and there all sending `socket.write_bytes`, `socket.send`. the fibers just stop working. ⏎ here is the code: https://paste.ee/p/ERClR please look at the bottom at players.each part and read my commentary there
<FromGitter> <girng> when i check top though, the CPU usage is 0.3%, memory usage is 0.xx% as well. very low, doesn't make sense, what's going on?
<FromGitter> <bew> I/O operations doesn't use memory or cpu, so it makes sense to me i think
<FromGitter> <girng> @bew yah, sdogruyol he thought it was I/O issues as well. but what does that mean exactly? is my network link just not fast enough for the throughput? i mean it's a local server so i should be fine, is there a way to monitor this stuff?
<FromGitter> <bew> iotop ? ^^ or htop can do it too iirc
<FromGitter> <girng> i tried to run iotop on WSL, but I get an error. let me try htop
<FromGitter> <girng> ok `htop` works. when i run my gmaeserrver and load up the game. what shouldi be looking for?
<FromGitter> <girng> ok so it looks like ` 20 0 1721M 8684 3016 S 2.0 0.1 0:00.27 /home/girng/.cache/crystal/crystal-run-GameServer.tmp` goes to around 10% CPU while the games are created. then it goes back to 0%, when the fibers stop
tom has joined #crystal-lang
tom is now known as Guest83802
Guest83802 has quit [Client Quit]
Guest83802 has joined #crystal-lang
Guest83802 has quit [Client Quit]
duane has quit [Ping timeout: 256 seconds]
faustinoaq has joined #crystal-lang
<FromGitter> <girng> iotop not working, but `atop` does: screenshot here (https://i.gyazo.com/6f7b99f0c7c48a58245be5617907af69.png). top part is BEFORE, bottom part is when the IO lock happens
faustinoaq has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> say i wanted a dynamic key on a namedTuple...
<FromGitter> <S-YOU> which become Hash
<FromGitter> <Blacksmoke16> is what i thought
<FromGitter> <girng> coldplay - magic :D
<FromGitter> <girng> where the hell are the syslogs for WSL
<FromGitter> <girng> im in /var/log and doing `ls`,and it shows: `alternatives.log apt atop btmp dist-upgrade dpkg.log fsck lastlog lxd sysstat unattended-upgrades wtmp` wtf lol
<FromGitter> <girng> found it, https://github.com/Microsoft/WSL/issues/534 looks like you need to enable it via `sudo service rsyslog start`
<FromGitter> <girng> ok, checked syslogs after i ran gameserver, not seeing anytihng about open files or any errors that would cause the tcp io hiccup. am not sure what to do
faustinoaq has joined #crystal-lang
duane has joined #crystal-lang
Yxhuvud has quit [Read error: Connection reset by peer]
Yxhuvud has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.1]
pabs_ has quit [Ping timeout: 260 seconds]
alex`` has joined #crystal-lang
pabs has joined #crystal-lang
<FromGitter> <phoffer> Hey everyone, sorry I haven’t been around for quite a while. I was wondering if there is any news regarding using Crystal for Ruby native extensions? I’ve just received serious interest from someone at a very large Rails company, so it looks like I will be resuming work on my crystalized_ruby project soon :) I just wanted to check in the community first, no reason to duplicate or compete against other
<FromGitter> ... people’s efforts
<FromGitter> <S-YOU> Great, expecting libgen and crystal_lib improves better too.
<FromGitter> <faustinoaq> > I was wondering if there is any news regarding using Crystal for Ruby native extensions? ⏎ ⏎ @phoffer Sadly not yet 😓
<FromGitter> <faustinoaq> There is some nice slides here (https://es.slideshare.net/AnnaKazakova/how-to-write-ruby-extensions-with-crystal) though 😉
<FromGitter> <faustinoaq> Also a Proof of Concept here (https://github.com/manastech/crystal_ruby)
faustinoaq has quit [Quit: IRC client terminated!]
<FromGitter> <phoffer> @faustinoaq both the slides and the POC were inspiration for my https://github.com/phoffer/crystalized_ruby 😄 but it needs a lot of re-working to be compatible with current crystal
<FromGitter> <faustinoaq> @phoffer Oh, nice, I think crystal-ruby extension is a good things, although actually the community is more focused in get some things done (parallelism, windows, stable)
<FromGitter> <phoffer> Oh yeah those are all absolutely more important. There’s been some chatter in the past, so I wanted to make sure I didn’t miss anything. But it is rightfully wayyyy down the list of priorities (if it even still is listed)
<FromGitter> <girng> :( :( :(
<FromGitter> <girng> `crystal build --debug test.cr && ./test`. where is my debug log file at?
<FromGitter> <phoffer> Additionally, I think it’s something that should be cared about more by the Ruby community. It’s not Crystal’s responsibility to get itself embedded in Ruby. I don’t think it’s reasonable to expect Crystal team to create that
<FromGitter> <girng> is it possible to print out debugging information to a file with a compiler command?
<FromGitter> <faustinoaq> > (if it even still is listed) ⏎ ⏎ @phoffer Yeah, I think is still listed somewhere 😅
<FromGitter> <faustinoaq> > where is my debug log file at? ⏎ ⏎ @girng Embedded within your executable
<FromGitter> <faustinoaq> Crystal doesn't generate debug files like C# yet
<FromGitter> <elorest> @phoffer glad to see you're still in the crystal community.
<FromGitter> <elorest> Are you still in northern utah?
<FromGitter> <elorest> We're putting together a crystal meetup next wednesday if you'd be interested.
<FromGitter> <faustinoaq> @girng Check this https://amberframework.gitbook.io/amber/examples/crystal-debug
<FromGitter> <girng> @faustinoaq or ANYONE if u got time, can you please run this https://paste.ee/p/JIKlx and then this for socket https://paste.ee/p/b1ERL
<FromGitter> <girng> im only getting up to `Games Open: 200. Game Iterations: 26577, Msgs Sent: 26577 ⏎ `
<FromGitter> <girng> and all the fibers stop... iuno what to do or how to debug no errors or anything
<FromGitter> <girng> see, it just bottoms out at 26,000 or so: https://i.gyazo.com/2df02d3ad34387068363f7a2a7415035.png
<FromGitter> <phoffer> That’s putting it nicely Isaac 😓 I’ve been absent quite a while but I do follow as I can. Yes still in town, although I’ll be moving down to Tucson next month. Ironic I know 😄 Where is that meetup planned? I’ll have to check if I can make it
<FromGitter> <faustinoaq> @girng Already trying... 😉
<FromGitter> <girng> @faustinoaq awesome, does it continue to get higher n higher?
<FromGitter> <faustinoaq> Yep, Is almost `120_000` now 😅
<FromGitter> <girng> WTF
<FromGitter> <elorest> @phoffer it will be at slingshot in Orem.
<FromGitter> <elorest> I'm also moving the AZ next month lol.
<FromGitter> <faustinoaq> @girng It Stopped here ^^
<FromGitter> <girng> @faustinoaq ohhhhh i see. so it does bottom out for you too, but at a higher rate. so it's prob how my code is structured. bcz it should continue to send messages to you the entire time.. i wonder what's stopping the loop in the `tick_rate` fiber
<FromGitter> <faustinoaq> @girng This is the resource usage for server (`s`) and client (`c`) ^^
<FromGitter> <girng> interesting, doesn't seemtoo high
<FromGitter> <faustinoaq> @girng If I add more clients (5) it continues growing (haven't stopped yet)
<FromGitter> <girng> really? wtf
<FromGitter> <faustinoaq> 1) 4 clients
<FromGitter> <faustinoaq> It stopped at `Games Open: 200. Game Iterations: 539339, Msgs Sent: 539339`
<FromGitter> <faustinoaq> Let me add more clients and see what happen 😅
<FromGitter> <faustinoaq> Ok, I added more clients (6 more) ^^
<FromGitter> <girng> yah, aint no bottleneck at all then. something going on with the loop in the fiber i think
<FromGitter> <girng> it's being closed... iuno how lol
<FromGitter> <girng> this aint io issue or cpu/memory issue either. i just checked iotop on my debian VPS. it shows nothing. i think it's the way i structured the server possibly 😆
<FromGitter> <faustinoaq> Ten clients, stopped at `Games Open: 200. Game Iterations: 1058679, Msgs Sent: 1058679`
<FromGitter> <faustinoaq> @girng No resources issues, my machine is working fine 😅
<FromGitter> <faustinoaq> The 5GB usage is because chrome 😅
<FromGitter> <girng> 😅 haha thx for testing it bro, helps a lot :D
<FromGitter> <faustinoaq> I almost have 50 open tabs 😆
<FromGitter> <girng> im gonna re-factor and start fresh i think
<FromGitter> <faustinoaq> @girng BTW, Actually the server output didn't stop, just keep printing the same message
<FromGitter> <faustinoaq> @girng BTW2, I consider my CPU is quite slow (1.3 GHz Intel Celeron late 2014) plus 8GB DD3L RAM
<FromGitter> <girng> @faustinoaq something is really screwy. because i just did 1 game, and let the tick_rate run for 5 minutes, only got up to 17,000 messages sent, then stopped (Same for game iteration). i think something is triggering the tick_rate fiber and closing it. not sure what it is
qard has joined #crystal-lang
<FromGitter> <faustinoaq> I think WSL is pretty slow 😅
<FromGitter> <girng> @faustinoaq im testing it on my vps too, cause stupid iotop didn't work on WSL 😄
<FromGitter> <girng> i tihnk my vps is slower xDD
<FromGitter> <faustinoaq> @girng Why don't try to install some linux distro in your machine? 😅
<FromGitter> <faustinoaq> I also have Windows 10 in my machine, I have a partition with Manjaro Linux
<FromGitter> <faustinoaq> And works pretty nice. I'm using just 20GB for Linux partition, all remaining space is for Windows 😅
<FromGitter> <faustinoaq> I still need Windows to work with Visual Studio and .Net 😅
<FromGitter> <girng> @faustinoaq not sure. i have a love hate relationship with WSL don't really want to leave it yet. but i heard of manjara linux is popular in the godot community as well, alot of people use it hahah
<FromGitter> <faustinoaq> I still prefer Manjaro Linux. though
<FromGitter> <faustinoaq> My partition looks like this (Yep, I know, "what a mess" 📡 )
<FromGitter> <girng> haha
early has quit [Quit: Leaving]
early has joined #crystal-lang
qard has quit [Quit: qard]
rohitpaulk has joined #crystal-lang
sagax has quit [Quit: Konversation terminated!]
qard has joined #crystal-lang
<FromGitter> <girng> @faustinoaq i think i fixed it. issue was at line 44 here: https://paste.ee/p/JIKlx in the tick_rate. all the `200` games was basically using write_bytes, and send, on the same socket. which at 15hz is 3000 times a second lol. what i did was just replace 200 with `1`, and then on socket, i am using: https://paste.ee/p/jC1Ua which just creates 50 connections. each connection is getting its socket written at
<FromGitter> ... a 15hz interval (which is normal). now i'm at `Games Open: 1. Game Iterations: 358380, Msgs Sent: 358380`, on this 600MHz cpu. and still going up! so it's working now, with 50 connections. cpu at 20% tho lol
<FromGitter> <girng> In any event, the new server: https://paste.ee/p/Y5ggo, socket: https://paste.ee/p/FXe9P im at 50 games open, and at 20% cpu on the VPS. i'm going to go higher hopefully this VPS host doesn't ban me LOL
qard has quit [Quit: qard]
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
hightower2 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
alex`` has quit [Quit: WeeChat 2.1]
<FromGitter> <vladfaust> Hi. Is there a way to create SHA1 hash from string with given salt? Ruby's `scramble = ::OpenSSL::Digest::SHA1.new(salt).update(pass).digest`
<FromGitter> <manveru> @vladfaust `OpenSSL::Digest::SHA1.new('hi').update('there').hexdigest == `OpenSSL::Digest::SHA1.new('hithere').hexdigest`
<FromGitter> <manveru> in other words, just append the strings, same effect
<FromGitter> <vladfaust> Oh great, thank you very much!
<FromGitter> <vladfaust> And the last question, if I may: how to `xor(string1, string2)`?
<FromGitter> <manveru> `"a".bytes.zip("b".bytes).map{|(a,b)| (a | b).chr }` like this?
<FromGitter> <manveru> i'm sure there's a better way... i'm not good at byte fiddling
<FromGitter> <vladfaust> @manveru if you're "not good", I'm zero. I'll take yours, thanks. But if anyone have a better solution, please share
<FromGitter> <yxhuvud> Isn't that or and not xor?
<FromGitter> <vladfaust> My task has been simplified, I now need to xor two `Bytes` (`Slice(UInt8)`), which must be easier
<FromGitter> <manveru> ah, true
<FromGitter> <manveru> so it needs `^` instead
<FromGitter> <vladfaust> I'm getting the overall concept of XOR, I need to perform byte-by-byte XORing of each UInt8 within the `Slice`. But what's the final result of XORing two `Slice`s?
<jsn-> a hash of concatenation of salt and data is usually not a very good idea cryptograhically, you should consider using hmac instead
<mps> is there list of crystal operators, with (even short) description, somewhere
<FromGitter> <vladfaust> @jsn- thanks, but it doesn't depend on me atm :)
<mps> vladfaust: how I missed that page reading few times docs? tnx
<jeromegn> is there a way to run a block of code in the root fiber absolutely?
<jeromegn> I guess I can make a queue via a channel in the root fiber
<jeromegn> waiting for tasks to run
<FromGitter> <vladfaust> XORing `Bytes`, btw: `bytes.map_with_index { |b, i| b ^ other[i] }`
<wuehlmaus> is it possible to require only a certain method from a library?
<wuehlmaus> i have require "http/client" and it's quite fat
<wuehlmaus> something like .. from http/client require get :)
<z64> no
<z64> though i'm curious what you mean by "fat"; source parsing is "blazing" fast, and the compiler only compiles methods that your code uses
<z64> so if you could require single methods, it would be the same
<wuehlmaus> the binary gets fat
<wuehlmaus> yes, i know upx
alex`` has joined #crystal-lang
<z64> i dont think there is anything you can do about that, other than `--no-debug` like https://crystal-lang.org/docs/using_the_compiler/ suggests (and calling "strip", whatever that is)
<z64> (i don't think --no-debug is worth it though)
duane has quit [Ping timeout: 256 seconds]
<FromGitter> <vladfaust> Please see https://gist.github.com/vladfaust/5f7a30c2ef292e0fec693ec7a6ed5a93. I need Crystal output to equal JS's. Any help would be appreciated. In particulat, I'm stuck with updating digests, I think I'm doing it wrong
<FromGitter> <vladfaust> omg, gitter go home
<FromGitter> <vladfaust> Fixed with `salt = Base64.decode(encoded_salt)[0, 20]`
<FromGitter> <vladfaust> Sorry for interruption
duane has joined #crystal-lang
<FromGitter> <faustinoaq> ^^ This is very useful 😄
<FromGitter> <forkev_twitter> @z64 & @wuehlmaus - the reference to strip through me for a loop too, as given the context of the crystal documentation you'd think this was a compile flag. After some head scratching, I found it's an external tool, aka, review https://sourceware.org/binutils/docs/binutils/strip.html for post processing the compiled binary.
<z64> yeahh, i tried it myself in my terminal after that on a whim. thanks for clarifying though
<FromGitter> <faustinoaq> > the binary gets fat ⏎ ⏎ wuehlmaus, z64, Interesting Gist Here (https://gist.github.com/teaearlgraycold/c7b181f7bc543ee9c37cfd45df5f8856#gistcomment-2154719) :-)
<FromGitter> <faustinoaq> Also see https://github.com/dom96/binary_size
<FromGitter> <forkev_twitter> very cool. thank you Faustino. I've not seen these.
<FromGitter> <faustinoaq> by dom96 😉
<wuehlmaus> faustinoaq: great link, thanks a lot
<wuehlmaus> forkev_twitter: i knew strip for a long time, i just thought that --release would have done that automatically. I really learned something today.
<FromGitter> <vlazar> Does anybody know any Crystal hards for generating MS Word documents? I see there are some for PDF, but found nothing for DOCX :( I need template based document generation, simple placeholder replacements but also loops and conditionals.
<FromGitter> <manveru> @vlazar if you got a lib for reading zips, just unpack and replace that way?
<FromGitter> <vlazar> You mean DOCX is just an XML file and suggest to use XML to work with it? I thought maybe are some some higher level libs for that. Trying so sneak Crystal in for my task if possible :)
<FromGitter> <manveru> yeah, basically, unzip and work with the XML... i don't think i've seen a lib for specially for docx
<FromGitter> <vlazar> yeah, sounds like a lot of fun :) might try this or maybe stick to Ruby for now
<wuehlmaus> i have an Apple and i have to always link libressl or brew openssl to my http/client stuff because /usr/lib stuff is too old. Is there a trick to always do it without using some shell script?
<wuehlmaus> i have to do --link-flags '-I/usr/local/opt/libressl/include -L/usr/local/opt/libressl/lib'
<wuehlmaus> yet https stuff is so omnipresent nowadays and i always do the same
<FromGitter> <manveru> for static linking?
<wuehlmaus> until now i solve it via a shell script
<wuehlmaus> no, not static linking
<FromGitter> <manveru> i just had a coworker trying to compile our webserver and he had to export some pkgconfig path env var
<FromGitter> <manveru> because it couldn't find ssl either
<FromGitter> <manveru> never had that issue in nix-shell
<wuehlmaus> nor did i
<wuehlmaus> oh, nix shell , not unix shell :)
<FromGitter> <manveru> yeah :)
woodruffw has quit [Quit: And then he took off.]
Ven`` has joined #crystal-lang
Ven`` has quit [Client Quit]
hightower2 has quit [Ping timeout: 240 seconds]
hightower2 has joined #crystal-lang
snsei has joined #crystal-lang
<FromGitter> <Blacksmoke16> say i have something like https://play.crystal-lang.org/#/r/43cv
<FromGitter> <Blacksmoke16> is there a way to pass it a variable as a key when calling `foo()`
<FromGitter> <Blacksmoke16> ex ⏎ ⏎ ```def bar(value) ⏎ key = "van" ⏎ foo(key: value) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5aff1f3b5666c42eb62110c8]
<FromGitter> <bew> no, no way, a variable is runtime information, but method resolution is at compile-time
<FromGitter> <Blacksmoke16> **args is a namedTuple yea?
<FromGitter> <bew> yep
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Blacksmoke16> have to go to plan b
<FromGitter> <vladfaust> Is it possible to call a function within itself not by name but with some keyword? E.g. ⏎ ⏎ ```def foo(i = 5) ⏎ recursive(i--) unless i < 0 ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5aff2a20f04ce53632eb3fee]
<oprypin> no
<oprypin> lol maybe
<oprypin> vladfaust, https://carc.in/#/r/43dg
<FromGitter> <vladfaust> Nice, thanks, @oprypin
<FromGitter> <vladfaust> When doing `Benchmark.measure`, which output value is relevant?
<FromGitter> <vladfaust> Like, elapsed real time?
<FromGitter> <vladfaust> I mean, is "system CPU time" relevant to benchmarking performance?
<FromGitter> <vladfaust> I constantly thinking that I'm asking stupid questions 😟
<hightower2> vladfaust: system CPU time is amount of time spent executing syscalls in kernel (as opposed to user CPU time which is everything else). You are interested in the sum (3rd field)
<oprypin> vladfaust, well at least this one is not a stupid question. i don't know it either. though maybe it's possible to find generic information online
<FromGitter> <vladfaust> Thank you, guys, gonna use the 3rd value (googled more thoroughly)
<oprypin> vladfaust, me personally i'd look at real time in brackets
<oprypin> it's what i care about -- "how long would I need to sit there waiting for the result" -- as I understand it
<hightower2> Yes, but that time (4th time) is, from what I understand, the "wall clock" time. And if you're running anything else on the computer so it's busy, this time may be longer than realistic
<oprypin> but I think the non-real numbers can exceed real numbers when parallelism is involved
<oprypin> and you wouldn't want to penalize an efficient parallel implementation
<hightower2> mm good point
<oprypin> hightower2, @vladfaust ^
<hightower2> Nice one. But still, maybe it would be possible to argue that you want to be looking at how much time on the CPU the entire job took. Whether this work was parallelizable so it actually ended sooner in real time, could be a different matter..
<FromGitter> <vladfaust> @oprypin I see, will remember this
<hightower2> Can I (if yes, how) check in runtime if a method on an object exists?
<FromGitter> <jwoertink> You could patch Object with a methods method using {{ @type.methods }} and some other stuff, then see if that array contains the method you're looking for...
<FromGitter> <jwoertink> Might be an easier way, but that was my first thought
chumlee has joined #crystal-lang
<hightower2> jwoertink: oh I know, the method is basically in relation to an instance var, if the var doesn't exist the method doesn't either. I'll check the instance var (will construct the name inside the macro) and that'll do
<FromGitter> <bew> what's your usecase?
<hightower2> I am in a macro. I have {{ call.name }} which is the string I start with. Then I need to prefix it with something, like {{ "test_" + call.name.stringify }}, and check if method of that name exists on some object. If yes, I call it, if not I call next.
<oprypin> ok but would you please explain what you're actually trying to do
<oprypin> you promised that 24 hours ago
<FromGitter> <bew> ah so that's not runtime
<hightower2> bew: yes, well, the macro generates some def()s which actually run in runtime. But I have the convenience of macro generating it, so... yeah
<hightower2> oprypin, hehe, I know. In essence I am porting some code over... specifically the code that registers listeners and then emits events. I used papierkorb's "cute" module for events in Crystal and am now trying to brige the gap between the original code's behavior and what I can do with cute
<hightower2> bridge*
<hightower2> not sure how else / more closely to describe it without going into ugly specifics :)
<oprypin> that just tells me that possibly you know what you're doing and that maybe i don't really want to know after all
chumlee has left #crystal-lang [#crystal-lang]
<hightower2> I think I got it working, except one last bit. Which is that if I emit signal "x", then after calling all its listeners, the code prepends a word to it (like "element_x") and then goes to call that modified name on all parent objects
<FromGitter> <bew> we have noo idea what you're talking about
<hightower2> Ok (that's why I didn't bother explaining earlier). Thanks for help.
sz0 has joined #crystal-lang
duane has quit [Ping timeout: 260 seconds]
<FromGitter> <ezrast> @hightower2 Not runtime, bit is https://crystal-lang.org/docs/syntax_and_semantics/responds_to.html what you're looking for?
<hightower2> ezrast: yes, used it and got it working, thanks
qard has joined #crystal-lang
qard has quit [Quit: qard]
txdv has quit [Ping timeout: 268 seconds]
qard has joined #crystal-lang