ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.32.1 | 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
sagax has quit [Remote host closed the connection]
leavengood has joined #crystal-lang
ur5us has quit [Ping timeout: 240 seconds]
alex`` has quit [Quit: WeeChat 2.7]
alex` has joined #crystal-lang
alex` is now known as Guest66641
Guest66641 is now known as alex``
_ht has quit [Ping timeout: 246 seconds]
_ht has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.7]
alex` has joined #crystal-lang
alex` is now known as Guest2560
Guest2560 is now known as alex``
alex`` has quit [Client Quit]
alex`` has joined #crystal-lang
ancorgs has joined #crystal-lang
baweaver has joined #crystal-lang
<FromGitter> <oren> how to open my vim editor from a crystal program. I wasn't sure what to google for so I googled for doing it in Ruby. The first result was a stackoverflow - `system("#{ENV['EDITOR']} 'yourfile.txt")`
alex`` has quit [Ping timeout: 268 seconds]
alex`` has joined #crystal-lang
sagax has joined #crystal-lang
<FromGitter> <oren> i downloaded the crystal repo itself and trying to grep for various keywords. ..
alex`` has quit [Ping timeout: 240 seconds]
<FromGitter> <spTorin> @oren ⏎ Process.run(ENV["EDITOR"], args: {"myfile.txt"})
<FromGitter> <oren> @spTorin when I run `crystal src/note.cr` the program stops after about a second and I don't see vim at all.
<FromGitter> <oren> unfortunately even crystal-by-example repo doesn't have an example of using Process - https://github.com/askn/crystal-by-example
<FromGitter> <oren> Is there a process for 'requesting a missing doc'?
<FromGitter> <636f7374> Great!
<FromGitter> <636f7374> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e41084e340a8019bbb22b59]
<FromGitter> <636f7374> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e4108a155b6b04bf6a24e44]
<FromGitter> <636f7374> SOCKS5 server will be available ~ 85% (Progress).
<FromGitter> <636f7374> Six hours to complete.
<FromGitter> <636f7374> So easy, checking for errors, and making a SOCKS5 client may take hours.
<FromGitter> <636f7374> 1) Part ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e410a433716b919ba0b938a]
<FromGitter> <spTorin> @oren ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ With this you can see what wrong. [https://gitter.im/crystal-lang/crystal?at=5e410b2ff3718e705df2874c]
<FromGitter> <oren> Unhandled exception: execvp (vim "myfile.txt"): No such file or directory: No such file or directory (Errno)
<FromGitter> <oren> even after i am creating the file i get it. i'll try use an absolute path
<FromGitter> <oren> even when I try `Process.run("vim", args: {"/tmp/myfile.txt"}, output: stdout, error: stderr)` I get this error
<FromGitter> <spTorin> @oren Try some GUI editor: `Process.run("gedit", args: {"/tmp/myfile.txt"})`
<FromGitter> <oren> @spTorin works with gedit!
<FromGitter> <oren> so what's the difference? why is vim causes trouble?
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
<FromGitter> <mavu> @oren I suspect that just connecting stdout and stderr is not enough to "simulate" an interactive terminal session.
<FromGitter> <mavu> I can run the example with "nano" editor and get ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5e41177f3716b919ba0bb29e]
<FromGitter> <oren> @mavu anything you recommend me to try?
<FromGitter> <halfdan> both of those (nano/vim) use ncurses - I'm gonna guess the expect a valid tty
<repo> mavu: try using Process::Redirect::Inherit for stdin, stdout and stderr
<repo> *input, output, and error
<FromGitter> <j8r> @halfdan may be right 👍
<repo> at least that works for me
<repo> obviously you'll have to start your crystal program from a tty
<FromGitter> <oren> that works for me as well. how do i open a specific file?
<repo> well.. you just pass it in an array as the second argument to Process.run
<FromGitter> <oren> ```code paste, see link``` ⏎ ⏎ And I see the following error: Error: expected named argument, not , [https://gitter.im/crystal-lang/crystal?at=5e411be262e9db4bf78c173f]
<FromGitter> <oren> sorry, works now
<FromGitter> <oren> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e411c6f1d23aa47aa05a117]
<FromGitter> <oren> so now that we got this working, what does all those line mean and how could I figure this out without your help?
<FromGitter> <oren> I am asking this because I assume that other people will face this issue and we need to document it if we think this is important for future users
<FromGitter> <oren> this also works: ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5e411fdf1d23aa47aa05a8d6]
Human_G33k has quit [Ping timeout: 272 seconds]
Human_G33k has joined #crystal-lang
<FromGitter> <636f7374> SOCKS5 server will be available ~ 70% (Progress).
<FromGitter> <636f7374> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e413b11d4daaa26c1948e29]
alex`` has joined #crystal-lang
Human_G33k has quit [Ping timeout: 240 seconds]
Human_G33k has joined #crystal-lang
Human_G33k has quit [Read error: Connection reset by peer]
Human_G33k has joined #crystal-lang
Nekka has quit [Quit: zzz]
Nekka has joined #crystal-lang
sfcgeorge has joined #crystal-lang
alex`` has quit [Ping timeout: 260 seconds]
alex`` has joined #crystal-lang
<FromGitter> <Daniel-Worrall> ```code paste, see link``` ⏎ ⏎ Anyone else think of a more elegant solution to getting a number suffix E.g. 1st, 2nd, 3rd,4th etc [https://gitter.im/crystal-lang/crystal?at=5e415ad045000661fcb087cf]
<FromGitter> <Daniel-Worrall> Ahh, it doesn't work for 11th
<FromGitter> <Daniel-Worrall> I'm gonna need to use a range
<FromGitter> <Daniel-Worrall> or something
<FromGitter> <Daniel-Worrall> https://carc.in/#/r/8jbc
alex`` has quit [Quit: WeeChat 2.7]
alexherbo2 has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> nice
<FromGitter> <j8r> I got this working, quite happy :)
<FromGitter> <j8r> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e4164d1cd2d737bb06c0496]
<FromGitter> <ImAHopelessDev_gitlab> nice, @j8r !
<FromGitter> <ImAHopelessDev_gitlab> long time no see
<FromGitter> <j8r> @ImAHopelessDev_gitlab hi, we seen each other yesterday
<FromGitter> <ImAHopelessDev_gitlab> oh ya lol
<FromGitter> <j8r> but yes, before yesterday, long ti;e - nice to see you
<FromGitter> <j8r> My router may be slower than kemal, but it is a bit unfair because mine does casting. ⏎ Perhaps it will be faster on basic routes
<FromGitter> <Blacksmoke16> what is `Group` in this context?
<FromGitter> <Blacksmoke16> like `/10/information/20`?
<FromGitter> <j8r> just an example, query a group that an user belongs for instance
<FromGitter> <j8r> it doesn't have a sense outside testing
<FromGitter> <Blacksmoke16> i more so mean i assume there is logic that converts the group # into a group object?
<FromGitter> <j8r> yes, inside the node in router tree, types are stored
<FromGitter> <j8r> Then the casting is done at this level.
<FromGitter> <Blacksmoke16> is it like a method defined on `Group` itself?
<FromGitter> <j8r> yep, a method is required to be implemented for casting: `Group.from_string`
<FromGitter> <Blacksmoke16> gotcha
alexherbo29 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 272 seconds]
alexherbo29 is now known as alexherbo2
<FromGitter> <Daniel-Worrall> Int to Hex string?
<FromGitter> <Daniel-Worrall> sorry, I mean base 16
<FromGitter> <Blacksmoke16> iirc `1.to_s 16`
<FromGitter> <j8r> not sure if `context[UserID, Group]` is better than `context.parameter UserID, Group`
<FromGitter> <Daniel-Worrall> ty
<FromGitter> <halfdan> ```code paste, see link``` ⏎ ⏎ What am I doing wrong? Stared at this for an hour now [https://gitter.im/crystal-lang/crystal?at=5e417c0fd4daaa26c1953120]
<FromGitter> <Blacksmoke16> im not super familiar with the c binding stuff, but your block has too many arguments
<FromGitter> <halfdan> The C function I'm trying to bind is ⏎ ⏎ > fun scan = hs_scan(db : HsDatabaseT, data : LibC::Char*, length : LibC::UInt, flags : LibC::UInt, scratch : HsScratchT, on_event : MatchEventHandler, context : Void*) : HsErrorT ⏎ ⏎ with MatchEventHandler defined as ... [https://gitter.im/crystal-lang/crystal?at=5e417ca8d4daaa26c195322f]
<FromGitter> <Blacksmoke16> like normally you would have to yield each arg, like `yield id, from, to`
<FromGitter> <halfdan> I'm trying to follow https://crystal-lang.org/reference/syntax_and_semantics/c_bindings/callbacks.html which does not use yield at all
<leavengood> You have a callback not a block.
<FromGitter> <halfdan> d'oh
sfcgeorge has quit [Quit: Textual IRC Client: www.textualapp.com]
<FromGitter> <kndt> does crystal have multithreading yet?
<FromGitter> <Daniel-Worrall> Behind a compiler flag, yes.
<FromGitter> <kndt> when was this added
<FromGitter> <Daniel-Worrall> There are still bugs to work out
<FromGitter> <Daniel-Worrall> 1) 32.0
<FromGitter> <Daniel-Worrall> We're on 0.32.1
<FromGitter> <kndt> cool
<FromGitter> <kndt> so it should be faster than go?
<FromGitter> <Blacksmoke16> it was added in `0.28.0`
<FromGitter> <kndt> @Blacksmoke16 👍
<FromGitter> <Blacksmoke16> i lied
<FromGitter> <Blacksmoke16> `0.31`
<FromGitter> <kndt> lol
<FromGitter> <kndt> does it have a builtin runtime scheduler or event loop like go or node?
<FromGitter> <Blacksmoke16> id read that blog post, it goes into detail on the implementation and stuff
<FromGitter> <kndt> in the post it seems you have to specify the amount of cores
<FromGitter> <Blacksmoke16> the default is 4
<FromGitter> <Blacksmoke16> > (Optionally specify the amount of workers thread as in CRYSTAL_WORKERS=4, by default is 4)
<FromGitter> <kndt> for example the goruntime does multiplexes the async on several cores if needed
<FromGitter> <Nicolab> @kndt ⏎ ⏎ > so it should be faster than go? ⏎ ⏎ I tested only multi-threaded channels, I observed better performance than Go. A significant difference in mono thread -> multi-threads gain, compared to Go mono thread -> multi-threads gain [https://gitter.im/crystal-lang/crystal?at=5e4180b3df1153705e280b75]
<FromGitter> <Nicolab> Like Go, sometimes there's no point in putting in all the CPUs. I have better perfs with 3 threads than 8 (probably a contention with the mutex).
<FromGitter> <kndt> @Nicolab many thanks from what you mention it seems crystal overall is more performant than go
<leavengood> @halfdan: I looked more at your code and I believe the issue is because of the parenthesis Crystal thinks your block takes one parameter (the entire callback), not the 5 parameters of the callback.
<FromGitter> <Daniel-Worrall> Seems the alpine docker isn't working with libxml
DTZUZU has joined #crystal-lang
<FromGitter> <Nicolab> @kndt I didn't go into the details, but that's what I observe. Better multi-threads gain, better JSON serialization, better request processing (with Kemal compared to echo and Gin)
<FromGitter> <Blacksmoke16> @Daniel-Worrall you can pass the flags manually
<FromGitter> <Daniel-Worrall> what flags
<FromGitter> <Blacksmoke16> `shards build --production --static --no-debug --link-flags "$(pkg-config libxml-2.0 --libs --static)"`
<FromGitter> <Daniel-Worrall> ty
<FromGitter> <Blacksmoke16> if you're doing a like `docker run ...` use `'$(pkg-config libxml-2.0 --libs --static)'`
<FromGitter> <Blacksmoke16> so it executes in the container versus host
DTZUZU2 has quit [Ping timeout: 245 seconds]
<FromGitter> <Daniel-Worrall> yea ty, it just brought that up
<FromGitter> <Daniel-Worrall> Is that a bug that's getting fixed?
<FromGitter> <Blacksmoke16> @j8r would know more
<FromGitter> <Nicolab> @kndt Also the lack of generics or inheritance in Go forces to do freestyle (reflect, serialization, deserialization). With Crystal no need, it's well equipped out of the box. ⏎ ⏎ After all is not better, the compilation of Crystal is longer, the lack of support in VS code (no auto-completion, go to def, mouse-over doc, ...), forced to dig deep into projects in Github to understand how to do some basics
<FromGitter> ... (where there is a plethora of docs and examples for Go). ⏎ ⏎ There are better and worse, weighs the pros and cons. [https://gitter.im/crystal-lang/crystal?at=5e4183f4df1153705e281694]
<FromGitter> <kndt> @Nicolab I guess go has a wider community
DTZUZU has quit [Ping timeout: 265 seconds]
<FromGitter> <Nicolab> @kndt , Yes, it's the cause, but it will come. I'm confident :)
<FromGitter> <kndt> @Nicolab the bigger company backing does give people confidence, I think confident developers should go with what's better
DTZUZU has joined #crystal-lang
<FromGitter> <Nicolab> Indeed, also people are sensitive to marketing and the buzz effect. Time validates and invalidates these things.
<FromGitter> <Nicolab> I'm pushing a backend (mobile app) in Crystal at the end of March ^^
alexherbo29 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 268 seconds]
alexherbo29 is now known as alexherbo2
<FromGitter> <Daniel-Worrall> I just pushed an rss feed that took way too long to make
<FromGitter> <halfdan> @leavengood Thanks for noticing my snafu earlier.
blackbeard420 has quit [Quit: ZNC 1.7.5 - https://znc.in]
hpyc9 has quit [Quit: ZNC 1.7.5 - https://znc.in]
<FromGitter> <j8r> @Blacksmoke16 I suppose it was not easy to implement handlers to be executed on a set of paths, for example an authentication handler to execute before all `/mypath` requests?
<FromGitter> <Blacksmoke16> for athena?
<FromGitter> <j8r> yes
<FromGitter> <Blacksmoke16> mm cant say i thought about it
<FromGitter> <Blacksmoke16> would be pretty easy to do, but nothing built in atm
<FromGitter> <Blacksmoke16> like
<FromGitter> <j8r> I think (for me) the only solution it to directly bind a Proc to the Node
<FromGitter> <Blacksmoke16> ```return unless event.request.path.starts_with? "/mypath"```
<FromGitter> <Blacksmoke16> each listener itself is responsible for knowing if it should act on a given event
blackbeard420 has joined #crystal-lang
<FromGitter> <Blacksmoke16> another way would be to do something similar, but base it off a module you include in the controllers you want it to execute on
<sorcus> Hi :-)
<FromGitter> <Blacksmoke16> or even define an abstract controller that includes it that can then be inherited from
hpyc9 has joined #crystal-lang
<FromGitter> <Blacksmoke16> im not familiar enough with your code to have a suggestion :/
alexherbo23 has joined #crystal-lang
<sorcus> https://sorcus.name/screenshot-2020-02-10_18-48-15.png - how can i strip user directory from binary? X-)
<FromGitter> <Blacksmoke16> 403s
<sorcus> Oh, sorry. Wait a few minutes.
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo23 is now known as alexherbo2
<sorcus> Blacksmoke16: you should open it now.
<FromGitter> <Blacksmoke16> whoa, not sure what im looking it
Human_G33k has quit [Ping timeout: 240 seconds]
<sorcus> Blacksmoke16: He-he, it's a binary, opened in vim :-D
<FromGitter> <mavu> did you compile with --release?
<FromGitter> <mavu> I assume this is debug info?
<sorcus> Blacksmoke16: I'm build a package for Archlinux and get warning "Package contains reference to $srcdir". This is because binary referenced to user directory...
<sorcus> mavu: Yeap, `crystal build --release linker.cr` used.
<FromGitter> <Blacksmoke16> what in code reference references the user dir?
<FromGitter> <j8r> @Blacksmoke16 I was just wondering how you have done, thanks!
<FromGitter> <HCLarsen> Hey folks, haven't been here in a while, I was just wondering if there's anything new about installing Crystal on a Raspberry Pi.
<FromGitter> <Blacksmoke16> rgr, tl;dr i guess i didnt do it? kinda just leave it up to the user
<sorcus> Blacksmoke16: Nothing. This path from YAML Mapping exception.
<FromGitter> <HCLarsen> Last time I tried, there was an unofficial package, but I don't know if that's up to date.
<FromGitter> <Blacksmoke16> i eventually want to implement some security related stuff, but TBD
* FromGitter * tenebrousedge does not know anything about RPis
<sorcus> Blacksmoke16: Exception rescued and show `Ooops`, but still referenced to user directory.
<FromGitter> <Blacksmoke16> yea i dont have any ideas :/
<sorcus> Blacksmoke16: I think it's a dead code, because rescue used at top level (if i understand correctly) and `Missing yaml attribute: foo` will never be called...
<sorcus> Blacksmoke16: And this means that binaries, builded with crystal, can't be reproduceble.
Human_G33k has joined #crystal-lang
<sorcus> Blacksmoke16: https://sorcus.name/screenshot-2020-02-10_19-13-15.png - one source code for building. Different build directories... Different sha256 sums... That's not ok. :-(
<FromGitter> <Blacksmoke16> :shrug: bit out of my area of familiarity
<sorcus> Blacksmoke16: :-(
<FromGitter> <mavu> @HCLarsen You can easily build it yourself, ⏎ follow the steps in the accepted answer. https://stackoverflow.com/questions/42796143/how-do-i-install-crystal-lang-on-rapsberry-pi
<sorcus> Blacksmoke16: If set attribute type to `Int32?` instead of `Int32`, no any references in binary. X-) :-(
<sorcus> Blacksmoke16: Maybe it should be configured via compile-time flag?
<FromGitter> <Blacksmoke16> no idea mate, maybe make an issue/forum post?
<sorcus> Blacksmoke16: Yeah, maybe yes.
sagax has quit [Read error: Connection reset by peer]
<sorcus> Blacksmoke16: Thank you for discussion. :-)
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <j8r> that's really too bad not to have interfaces for class methods :(
<FromGitter> <Blacksmoke16> bump the issue 😉
<FromGitter> <j8r> I'm finding alternatives
<FromGitter> <Blacksmoke16> i mean couldnt you do like
<FromGitter> <Blacksmoke16> raise an exception unless the child overrides it?
<FromGitter> <j8r> maybe, but it will kind of already
<FromGitter> <HCLarsen> @mavu that's almost 3 years old, does it still work?
<FromGitter> <j8r> I'll just document it then
<FromGitter> <Blacksmoke16> yea true, id just define them on the interface and document them there
sagax has joined #crystal-lang
<FromGitter> <mavu> @HCLarsen I think so. you might need to change llvm versions or something, I don't remember. just try it. I think it will work.
<FromGitter> <mavu> @HCLarsen you can skip the part about installing llvm3.9 or sth. unless you are building for a very old version, just use whatever you have on the PI. ⏎ (i think :) )
<FromGitter> <HCLarsen> @mavu seems very complicated. Even Julien commented there about the difficulty of doing this.
<FromGitter> <HCLarsen> I wonder if it may just be simpler to write my code on one machine, and cross compile for the Pi.
return0e_ has quit [Remote host closed the connection]
Human_G33k has quit [Ping timeout: 265 seconds]
return0e has joined #crystal-lang
_ht has quit [Remote host closed the connection]
<FromGitter> <straight-shoota> Memory size can also be an issue on Raspberry Pi. Even for relatively small programs. Cross compilation is a good option as it works and when you set up a multistage build workflow once, there's not much hassle with it.
<sorcus> straight-shoota: And what with my issue? Bur or feature? :-D
<sorcus> *bug
<FromGitter> <tenebrousedge> it's a featured bug! :D
<sorcus> Haha :-D
<FromGitter> <jwoertink> Speaking of memory size... We are having issues with an app we just launched. I posted on the forum here https://forum.crystal-lang.org/t/new-app-new-errors/1674/5
<FromGitter> <jwoertink> but what I was wondering is, aside from using `GC.stats`, is there a good way to track memory usage?
<FromGitter> <jwoertink> My thought was we throw something at the start of a web request to log out how much memory is being used, then log out that thing at the end, and may track if there's a memory leak or something.
<FromGitter> <jwoertink> I've never actually done anything like that, so not sure where to start in crystal
<sorcus> Good night :-)
<FromGitter> <Blacksmoke16> @jwoertink make it a http handler as the first one?
<FromGitter> <jwoertink> Yeah, I can use a handler to wrap my stats logging, but how do I get the stats? (aside from GC.stats)
<FromGitter> <jwoertink> or is using the GC like that the best way?
<FromGitter> <636f7374> @jwoertink You can free memory manually.
<FromGitter> <jwoertink> In my case, this page only takes about 160 requests to tank the app completely. If I spin up 160 requests and say hit this page at the same time, then it goes down
<FromGitter> <jwoertink> Do I just tell the GC to run to free it manually?
<FromGitter> <636f7374> @jwoertink Not using finalizer
<FromGitter> <636f7374> Override finalizer, but can be dangerous but effective.
<FromGitter> <jwoertink> I'm not sure what you mean. Is `finalizer` a method on something?
<FromGitter> <636f7374> @jwoertink I use manual free memory in MITM server.
<FromGitter> <636f7374> @jwoertink ⏎ ⏎ ```def finalize ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e41db60340a8019bbb47932]
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Benchmark.html#memory(&)-instance-method
<FromGitter> <Blacksmoke16> Essentially just uses GC stats before and after getting bytes used
<FromGitter> <636f7374> @jwoertink E.g. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e41dba3b612cc7bb15c3a2b]
<FromGitter> <636f7374> @jwoertink
<FromGitter> <jwoertink> ah interesting
<FromGitter> <636f7374> @jwoertink E.g. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e41dbf1df1153705e291b8c]
<FromGitter> <636f7374> @jwoertink However, if you mishandled (improperly used) there may be hidden leaks, you must test your code multiple times.
<FromGitter> <jwoertink> Yeah, I think there might be a leak, and I'm just trying to figure out how to confirm that
<FromGitter> <Blacksmoke16> Htop?
<FromGitter> <Blacksmoke16> And just watch usage of it as you make requests
<FromGitter> <636f7374> Just like rust-lang
<FromGitter> <636f7374> @jwoertink ```
<FromGitter> <636f7374> @jwoertink ⏎ ⏎ *<RX14>* at least show me the composition of the heap by object type ⏎ *<RX14>* hopefully show me what's keeping each object alive ⏎ *<RX14>* and ideally show me where objects are being allocated in the source ... [https://gitter.im/crystal-lang/crystal?at=5e41ddb2cd2d737bb06d570f]
<FromGitter> <jwoertink> well, giving up isn't an option here lol
<FromGitter> <jwoertink> looks like htop isn't on these containers, but we have top. I ran that and see the memory used increases like you'd expect
<FromGitter> <jwoertink> but then the app just becomes unresponsive
<FromGitter> <watzon> You can always use valgrind to find memory leaks
<FromGitter> <watzon> Not the easiest to figure out, but it works
<FromGitter> <636f7374> @watzon ```
<FromGitter> <jwoertink> I hadn't heard of that. Sounds neat though
<FromGitter> <636f7374> @watzon ⏎ *<RX14>* but valgrind isn't a leak debugger ⏎ *<RX14>* to debug a memory leak you really need to know what objects are on the heap and where they come from ⏎ *<RX14>* no non-crystal-specific tool will be able to know what crystal type an allocation is ⏎ *<RX14>* even then surely all your tool would tell you was that all the memory was allocated by __crystal_malloc ...
<FromGitter> <jwoertink> Ok, so it looks like we either have 2 major issues, or one issue is leading to the other. But the other one doesn't seem to be memory related
<FromGitter> <jwoertink> We hit the app enough times and docker is like "yeah, your app is good", but the app doesn't take any request. It just sits there frozen
<FromGitter> <636f7374> @jwoertink socket leak?
<FromGitter> <636f7374> @jwoertink Most likely a socket leak, E.g. Too many open files
<FromGitter> <636f7374> lsof -p pid
<FromGitter> <watzon> Ahh yeah that could do it. If you're not closing files after you're finished with them.
<FromGitter> <636f7374> sample pid -wait 10
<FromGitter> <636f7374> I encountered multiple socket leaks while making a MITM server.
ur5us has joined #crystal-lang
<FromGitter> <636f7374> So I think you should test / check it.
<FromGitter> <jwoertink> ah. Actually a socket leak does sound familiar
<FromGitter> <j8r> RX14 strange, it says on Wikipedia (https://en.wikipedia.org/wiki/Valgrind) ⏎ ⏎ > Valgrind (/ˈvælɡrɪnd/) is a programming tool for memory debugging, memory leak detection, and profiling.
<FromGitter> <j8r> ok, leak detection != leak debugger?
<FromGitter> <j8r> the first is runtime, the other compile time I suppose
<FromGitter> <j8r> we will need something like jstack then
<FromGitter> <watzon> It would be really nice to have a Crystal specific tool for memory leak debugging
<FromGitter> <636f7374> asterite is too mysterious.
Vexatos has quit [Read error: Connection reset by peer]
<FromGitter> <j8r> ok?
<FromGitter> <watzon> Valgrind is meant for C/C++, so its output isn't the most helpful with Crystal or other languages
<FromGitter> <j8r> @watzon 💯
<FromGitter> <636f7374> (asterite) It's like a robot, doesn't it seem to sleep?
<FromGitter> <j8r> lol, why?
Vexatos has joined #crystal-lang
<FromGitter> <watzon> Lmao
<FromGitter> <j8r> as you already know there are different time zones
<FromGitter> <636f7374> I see it every time, almost any time.
<FromGitter> <636f7374> :)
<FromGitter> <jwoertink> wait... doc.... you mean to tell me, you build a time machine?
<FromGitter> <j8r> even at UTC+5 for example?
<FromGitter> <j8r> @jwoertink Have a metric tracking `GC.stats`?
<FromGitter> <jwoertink> Using the GC.stats before and after this one action shows a change in about 1.5MB being used
<FromGitter> <jwoertink> but we have 4GB of RAM
<FromGitter> <jwoertink> so 160 requests to that page shouldn't wipe out the memory
<FromGitter> <636f7374> GC.stat are not accurate.
<FromGitter> <jwoertink> We're now digging in to the idea of the sockets though
<FromGitter> <636f7374> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e41e27c340a8019bbb48c3d]
<FromGitter> <636f7374> okay
<FromGitter> <j8r> @jwoertink what does happen if the database closes the socket?
<FromGitter> <j8r> also, does your other apps use TLS too?
<FromGitter> <jwoertink> Not sure if it's the database socket, or like the web server sockets, but interesting thing is if we do a count on lsof for these PIDs, before the app tanks it's like 21
<FromGitter> <jwoertink> but after the app tanks, it's like 333
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <636f7374> The easiest way: lsof -p pid
<FromGitter> <636f7374> ps ax | grep something
<FromGitter> <j8r> what odes this app have that others don't?
<FromGitter> <jwoertink> They all connect to the same database. The new one doesn't get as much traffic as the old one
<FromGitter> <jwoertink> They all run on docker Ubuntu 18 whatever
<FromGitter> <jwoertink> The old one is on crystal 0.29, and new one on 0.31.1
<FromGitter> <jwoertink> all of them are Lucky apps. But the old one uses the clear shard, and the new one uses the avram shard. Though, both of those just wrap PG and crystal-db shards
<FromGitter> <636f7374> Maybe some exception is thrown in some places, causing the socket to leak.
<FromGitter> <jwoertink> DB is hosted on RDS, and apps are hosted on elasticbeanstalk with cloudfront in front of them. Nothing really crazy or overly complicated
<FromGitter> <jwoertink> We were actually seeing `Errno Error reading socket: Bad file descriptor` quite a bit
<FromGitter> <jwoertink> and `Errno Error writing to socket: Broken pipe `
<FromGitter> <jwoertink> those are some of the larger count errors we get in bugsnag
<FromGitter> <jwoertink> The older apps get the broken pipe all the time too, but that app never goes down
<FromGitter> <j8r> @jwoertink I suspect something related to OpenSSL https://github.com/rdp/crystal/blame/master/src/openssl/ssl/socket.cr
<FromGitter> <j8r> perhaps there is a recent change that causes this
<FromGitter> <636f7374> Have you turned on the thread feature?
<FromGitter> <jwoertink> That's a pretty decent guess. I wonder how I could confirm that though
<FromGitter> <636f7374> #8714
<DeBot> https://github.com/crystal-lang/crystal/issues/8714 (Crystal::ThreadLocalValue(Deque(Fiber)), Thread... Server hangs, crash, Deadlock?)
<FromGitter> <jwoertink> No, not yet.
<FromGitter> <636f7374> It can only be a socket leak.
<FromGitter> <636f7374> Memory leaks do not cause programs to freeze。
<FromGitter> <j8r> `/usr/share/crystal/src/openssl/ssl/socket.cr:116:5`
<FromGitter> <j8r> sounds like yes
<FromGitter> <jwoertink> maybe this? https://github.com/crystal-lang/crystal/issues/3953
<FromGitter> <636f7374> E.g. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e41e5e1340a8019bbb49640]
<FromGitter> <636f7374> Ensure foolproof, no socket leaks
flips has joined #crystal-lang
<FromGitter> <636f7374> You guys continue to discuss, I'm going to check if there are any implementation errors in SOCKS5 :)
<FromGitter> <jwoertink> thanks for the help
<FromGitter> <jwoertink> We're just going over a few tests to see what other info we can find
<FromGitter> <636f7374> :)