<FromGitter>
<Daniel-Worrall> if anything, this aoc is showing me how bad at efficient string parsing I am. I could just regex everything but I'm scared that's slow
<FromGitter>
<viraptor1:matrix.org> Regex is surprisingly quick as long as you reuse a compiled one. I mean, you can usually be more efficient, but typically expect a few %, not few X improvement.
<Andriamanitra>
string parsing is not the part i would be worried about when it comes to speed in aoc :p
<FromGitter>
<Joe23232> Hi
<FromGitter>
<Joe23232> I am ready to start working on the Smithay project
<FromGitter>
<mattrberry> ||Do spoiler tags work on gitter?||
<FromGitter>
<mattrberry> Nope
<hightower3>
Hey is there a way to control when a backtrace is shown? I have a program where I want the unhandled exception to print the message to the screen and exit. But I don't want it (especially in --release mode and stripped) to also try to include the backtrace
<hightower3>
In such cases I don't want backtrace at all, and especially when (after --release and stripped binary) it looks totally useless, such as:
<hightower3>
Unhandled exception: Error opening file with mode 'r': 'gfd': No such file or directory (File::NotFoundError)
<hightower3>
from ???
<hightower3>
from ???
<hightower3>
and about 18 more lines of ???
<FromGitter>
<erdnaxeli:cervoi.se> I think you should catch the exception and print whatever you want
Flipez has joined #crystal-lang
<FromGitter>
<naqvis> hightower3 there is no hook or global exception handler. Though you can achieve your desired outcome via monkey patching and overriding the behavior ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ above code will print normal exception backtraces in dev/debug mode, but will override the behavior in release mode only. [https://gitter.im/crystal-lang/crystal?at=5fcdf56a2d8b7c763848bcda]
<hightower3>
interesting, thanks
<hightower3>
would be so cool if there was a built-in feature for this
<hightower3>
erdnaxeli:cervoi.se: right, but I don't want to wrap absolutely everything in begin/rescue, especially when my goal is actually that I don't want to rescue it
<FromGitter>
<naqvis> yeah, but tbh one should avoid delegating exceptions to global handler, as code should be dealing with them
<hightower3>
right
<FromGitter>
<erdnaxeli:cervoi.se> you can wrap your main entry point
<FromGitter>
<vladfaust> Does spec behaviour change with `-Dpreview_mt`? It is possible to parallelize tests, at least by files? Where can I read about how exactly `it` works? There is definitely something goes on under the hood. In fact, these changes were drivers of me abandoning Crystal last summer, because I could not make migrate specs pass due to those changes (https://github.com/vladfaust/migrate.cr/issues/22)
<oprypin>
specs just dont run in parallel
<FromGitter>
<vladfaust> Is it possible to make them run in parallel, at least by-file?
<yxhuvud>
not currently, AFAIK. It would be pretty nice to have that feature though.
<oprypin>
yea just do it outside of crystal
<FromGitter>
<vladfaust> Alright, thanks
<FromGitter>
<vladfaust> Is that true that running multiple `crystal spec` in parallel may lead to linking errors?
<oprypin>
vladfaust, sure, seems likely
<FromGitter>
<vladfaust> Not stonks
<oprypin>
vladfaust, try `crystal run` isntead
<oprypin>
`crystal spec foo.cr bar.cr` is just `crystal eval 'require "./foo"; require "./bar"`
<yxhuvud>
is crystal run more threadsafe than crystal spec? I don't see why.
<FromGitter>
<vladfaust> Multiple parallel `crystal run` also lead to linking errors
<oprypin>
yxhuvud, it is because `crystal run filename.cr` uses `$cache/absolute-filename.cr/`
<straight-shoota>
Multiple compiler instances can't run in parallel currently
<oprypin>
`crystal eval` uses `$cache/eval/` excuse me
<oprypin>
straight-shoota, as i can tell, it can run, as long as it's `crystal build` or `crystal run` pointed at different root source files
<oprypin>
or u can also give a different CRYSTAL_CACHE to each of it
<FromGitter>
<vladfaust> `Error renaming file: '/root/.cache/crystal/usr-lib-crystal-ecr-process.cr/_main.o.tmp' -> '/root/.cache/crystal/usr-lib-crystal-ecr-process.cr/_main.o': No such file or directory (File::NotFoundError)` :thinking:
<straight-shoota>
it *can* work, but not reliably
<straight-shoota>
using different CRYSTAL_CACHE should do
<FromGitter>
<vladfaust> Per `run`?
<straight-shoota>
per compiler instance, so if you're using run, then per run
<oprypin>
vladfaust, i hypothesize if you `run` different source files then it will work anyway
<oprypin>
`for i in {1..10}; do CRYSTAL_CACHE_DIR=$(mktemp -d) crystal eval "p $i" & ; done` works
<straight-shoota>
you can also compile sequentially and then run the executables in parallel. That should be no issue (unless the specs themselves have parallel execution issues)
<straight-shoota>
do note that using a fresh cache may result in longer compilation times, thus reducing the benefit of parallel execution
<FromGitter>
<vladfaust> Thanks
<oprypin>
ultimately yes, i think setting CRYSTAL_CACHE_DIR always has a better alternative
<oprypin>
if you're doing `crystal run different_filename.cr` each time then that just works fine
<oprypin>
if you're doing `crystal run same_filename.cr` then.. why? just build it first once
<oprypin>
`crystal spec a.cr` and `crystal spec b.cr` indeed cannot run in parallel because the cache dir they occupy is based *only* on the current working directory
<jhass>
anyone looked into putting file locks on the cache into the compiler? feels like it should be an easy stop gap solution to this issue for now
<oprypin>
have fun implementing that on windows i guess
<jhass>
could be a noop stub on windows, not worse than now
<FromGitter>
<vladfaust> Thanks for the advice. I will consider building specs before running them in parallel
<straight-shoota>
oprypin, crystal run different_filename.cr could fail if you have macro run in the code
<oprypin>
😩
<FromGitter>
<vladfaust> > if you're doing crystal run different_filename.cr each time then that just works fine ⏎ ⏎ No, it fails w/ `Error renaming file:`
<hightower3>
Hey @BlackSmoke16 see the Box vs. Class thing from yesterday: https://carc.in/#/r/a2q9
<hightower3>
Unless I made a mistake in the example, it seems to confirm that jhass' solution works (wrapping it in a class) while Box doesn't
<FromGitter>
<asterite> it seems using flock should be a simple change. If I have time I'll do it later, otherwise feel free to send a PR
<FromGitter>
<asterite> the file lock should be in the nested directory in the cache dir
<oprypin>
thats what i meant but guess i said it wrong
<FromGitter>
<Blacksmoke16> ah, the `Enumerable#zip` does
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<yxhuvud>
@asterite: btw, I'm getting a strange compilation error. Does #sum have issues with recursion? https://github.com/yxhuvud/aoc20/blob/issue/day7.cr#L26 The issue goes away if I do an explicit `return 0 unless contained[current]?` (contains aoc spoilers, so don't look if you don't want to see part1)
<yxhuvud>
or I guess I'll see if I can create an issue about it
<straight-shoota>
yeah it's hard for the compiler to figure out what the return type of that method is because it recursively calls itself
<straight-shoota>
adding an explicit return type to the method signature should fix this
<FromGitter>
<asterite> oh, you are discussing it here too :)
<kevinsjoberg>
My solution came out okay, but there's probably a more clever way of solving it. I just put all bags in a graph and ran DFS over it.
<yxhuvud>
yes, sorry about that :)
<yxhuvud>
I'll go back to cleaning up my solution :)
<kevinsjoberg>
I tried to optimize it by keeping track of visited vertices, but I get worse results, not better.
<kevinsjoberg>
Not sure if I implement it wrong or it's just overhead given the puzzle size.
<FromGitter>
<jwaldrip:matrix.org> Is the the official gitter room now?
<frojnd>
How can I define default value as an argument for Time.class? I tried like this: def url(url, time = Time.class = Time.utc) but it gives me: Error: can't restrict Time to Time.class
<FromGitter>
<Blacksmoke16> `time : Time = Time.utc`
<frojnd>
Argh
<FromGitter>
<Blacksmoke16> you want to restrict it to an instance of time, not a class
<FromGitter>
<j8r> Now that Matrix <-> Gitter works, the custom IRC bridge is now superfluous
<FromGitter>
<j8r> > The core Matrix team maintains bridges to Slack, IRC, XMPP and Gitter, and meanwhile the wider Matrix community provides bridges for Telegram, Discord, WhatsApp, Facebook, Hangouts, Signal and many more.
<FromGitter>
<j8r> so, if Matrix become the main Crystal chat, we will have "free" Gitter, IRC and Slack bridges
<oprypin>
jwaldrip:matrix.org, welcome
<oprypin>
j8r, it's still not obvious how to bridge matrix and irc. the good kind of bridging assumes you use the irc room only or the matrix room only. but we still have both explicit irc and gitter rooms
<FromGitter>
<jwaldrip:matrix.org> I would love to see IRC slowly go away with the advent of Matrix.
<oprypin>
jwaldrip:matrix.org, pls
<FromGitter>
<jwaldrip:matrix.org> I know, I know. It's just realllly old tech.
<FromGitter>
<j8r> It is not going away, but being more and more less used for special cases, like for mail
<frojnd>
So my time's default value is time : Time = Time.utc, but can I also pass it as a string?
<frojnd>
Then I would have to define my time within Tuple? Something like def url(url : String, {time : Time = Time.utc, time : String}) .. end ?
<frojnd>
Would this work
<FromGitter>
<j8r> oprypin: AFAIK be can use both IRC and Matrix
<oprypin>
frojnd, wut
<oprypin>
frojnd, u really should make 2 method overloads
<oprypin>
j8r, i'm listening to suggestions
<oprypin>
like, actual actions to resolve this
<frojnd>
Was hoping I can save a few lines with some magic :D
<FromGitter>
<j8r> I think, creating a Matrix room, bridging to this Gitter one, Slack and Discord?
<FromGitter>
<Blacksmoke16> frojnd you should have another overload that accepts a string, converts it to a time instance, then calls the other overload
<oprypin>
j8r, people will not leave freenode irc just like that
<FromGitter>
<j8r> Why leave?
<oprypin>
frojnd, this works `def url(url : String, time : (Time | String) = Time.utc)`
<oprypin>
j8r, this is just telling you how to join an irc room from matrix
<FromGitter>
<j8r> > It will then listen for incoming IRC messages and forward them through to Matrix rooms.
<FromGitter>
<j8r> Plus: > Full two-way communication in channels and PMs are supported, along with a huge array of customisation options
<oprypin>
the only thing that's likely desirable at the moment is to bridge irc to the matrix-clone of the gitter room
<oprypin>
then the bridge from irc to gitter could be killed
<oprypin>
someone has to run that service though
<FromGitter>
<j8r> yes
<FromGitter>
<j8r> I don't don't how it looks, if the Gitter room admins have access to it
<FromGitter>
<j8r> it could be possible to create a new Matrix room otherwise
<FromGitter>
<j8r> oprypin: it may be possible with matrix.org, without installing anything
<FromGitter>
<j8r> nvm
<FromGitter>
<j8r> yes, one still have to run it indeed
<FromGitter>
<j8r> then, adding Discord and even Slack support (I've heard some are there) won't be much hard
<oprypin>
j8r, matrix.org runs a bridge freenode->matrix and gitter->matrix
<oprypin>
in both of those cases the matrix room has a freenode/gitter-specific name
<FromGitter>
<j8r> ha ok, that's what I thought
<FromGitter>
<erdnaxeli:cervoi.se> you can bridge any room with gitter, you have to use their official (and unique) bridge
<FromGitter>
<erdnaxeli:cervoi.se> to bridge other networks would require to host the bridges, are the provided ones won't allow bridging this current room already bridged to gitter
<FromGitter>
<erdnaxeli:cervoi.se> nothing impossible, but it needs a bit ot setup
<FromGitter>
<tenebrousedge> I kinda feel like spending a day just counting the number of ambulances that go by here <_<
<FromGitter>
<drum445> which mysql orm is recommended these days? I looked at granite but I don't really like orms that make the object responsible for its own persistence
<FromGitter>
<drum445> or is using raw sql the way to go?
<FromGitter>
<Blacksmoke16> but idk the current status of it
<FromGitter>
<drum445> n1 thanks @Blacksmoke16 (long time no see btw)
<FromGitter>
<Blacksmoke16> np
<FromGitter>
<drum445> Does Chris (rx14 I think) still work on Crystal?
<FromGitter>
<j8r> since a very long time I didn't see rx14 here
<FromGitter>
<j8r> last time I heard, busy with the Uni
<oprypin>
drum445, no
<Stephie>
no in... every way
<FromGitter>
<j8r> ... o/
<FromGitter>
<j8r> Stephie busy on the personal side, or have you moved to other projects?
<Stephie>
it's complicated, but lets just say i needed to step down after 3 years, everyone needs to take a break after so long
<FromGitter>
<drum445> Stephie is rx14?
<Stephie>
i guess
<FromGitter>
<drum445> anywho, that seems fair enough, crystal development did seem like a full time job?
<Stephie>
it's not so healthy to be so consumed by something for so long, especially when it's something you cant stop working on or you get a backlog of issues
<Stephie>
but yeah it was a lot of things, but that was most major
<Stephie>
I'm having fun working on stuff for myself though, which is nice
<FromGitter>
<drum445> 👍
<Stephie>
mostly electronics rather than software interestingly
<FromGitter>
<j8r> quite excited about RISC-V :)
<FromGitter>
<j8r> maybe one day we'll have Crystal running on this CPUs
<Stephie>
well...
<Stephie>
that was gonna be my next crystal PR
<FromGitter>
<j8r> O.O wow, nice. "was", you mean stale, or in progress?
<FromGitter>
<RespiteSage> @Stephie What electronics have you been enjoying working with?
<Stephie>
im working on a devboard for a risc-v processor, once thats done I might be making a custom stdlib for microcontrollers
<FromGitter>
<j8r> We can't talk about Rust, have you tried it?
<FromGitter>
<RespiteSage> Custom Crystal stdlib?
<FromGitter>
<j8r> I don't know if Crystal an micro-controllers can fit together... ⏎ What's the point of Crystal without GC and concurrency?
<Stephie>
and the constant questioning over validity and worth of ideas vs just having fun is a hell of a reason to never become an open source maintainer again
<Stephie>
i dont give a shit if nobody else uses it, in fact that'd be more confy
<FromGitter>
<tenebrousedge> huh
<FromGitter>
<j8r> Stephie I mean, they are not mutually exclusive. Open source commercial successes attest it.
teardown has joined #crystal-lang
<FromGitter>
<RespiteSage> I still think it's fair.
<FromGitter>
<tenebrousedge> actually I did part 1 differently, weird
<Stephie>
its hard to have fun when you have heavy expectations of you, is all
<FromGitter>
<RespiteSage> Yeah, for sure.
<FromGitter>
<j8r> indeed, but where come this expectations?
<Stephie>
whenever anyone else uses your work, you become a maintainer, their expectations are almost always placed on you
<Stephie>
this is usually fine, especially small projects, but can get incredibly tiring
<FromGitter>
<j8r> some users push this too far, there is no contract, no $$$ involved. Didn't see this behavior in Crystal, happily :)
<Stephie>
it doesnt have to be verbal
<Stephie>
your own perception of their expectations massively affects your mental health
<Stephie>
it's complicated, and sub-conscious, and there's so little awareness of the mental health effects of work like this
<Stephie>
i'm sure ary has felt something similar to this as well
<FromGitter>
<j8r> if we could look at the history of come/leave of the Crystal org members :D
<Stephie>
in fact i remember having your point of view when ary started burning out :)
<Stephie>
but yeah, it's real
<FromGitter>
<RespiteSage> I guess the lack of awareness makes sense. In practice, a very small number of people (with lots of real or perceived responsibility) maintain most of the packages that people rely on.
<FromGitter>
<j8r> I don't say otherwise, it happens to everyone wanting to do its best on a thing
<FromGitter>
<j8r> and this thing is long to do
<Stephie>
i didn't thyink it didn't expect, I just thought that the load would be lightened once you percieved the false expetations you set on yourself
<Stephie>
sadly, it is not that simple
<Stephie>
s/expect/exist/
<FromGitter>
<j8r> software improvements is infinite, really :/
<FromGitter>
<RespiteSage> Yeah. People (and therefore their feelings and mental health) are much messier than the stuff that most software developers like to deal with, and we often avoid dealing with those parts of ourselves until it's unavoidable. Not to say you were doing that, @Stephie; it sounds like stepping back was a huge mental health win for you.
remby has joined #crystal-lang
<FromGitter>
<RespiteSage> I mean, it's gotta be infinite. Whenever we make anything, it has flaws and/or limitations.
<Stephie>
yeah, I was dealing with a lot of other stuff at that time as well, and I'm glad i stepped down
<Stephie>
and well, i can relate very very much to people's mental landscape being far messier than anyone thinks, especially yourself
psydroid has quit [*.net *.split]
psydroid has joined #crystal-lang
<FromGitter>
<watzon> Same though
<FromGitter>
<ImAHopelessDev_gitlab> hi
<FromGitter>
<watzon> Hola
<FromGitter>
<ImAHopelessDev_gitlab> we talking about mental health? looks like i came in at the right time
<raz>
@Blacksmoke16: dabbling with athena, it's fun! but how can i override all the default responses (4xx, 5xx) and ideally also the default serializer (which seems be #to_json?). i want all my replies to conform with json:api
<FromGitter>
<Blacksmoke16> be sure to read that 2nd link page, goes over how things are designed and such
<raz>
yea nah, i learn by discovery. ;) starting from the hello world and bumping my way forward. your docs are fantastic! (i wouldn't have found that above page easily, but that code works as advertised, now i just need to massage it a bit for the different error-types)
<raz>
btw i mounted athena next to my own framework (for /api), one thing i wondered: how expensive is ADI::ServiceContainer.new? 😅
<FromGitter>
<Blacksmoke16> 👌
<FromGitter>
<Blacksmoke16> not free but not terrible either
<raz>
kk. was just surprised you seem to keep nothing across requests
<FromGitter>
<Blacksmoke16> i.e. slower than other frameworks but still fast enough
<FromGitter>
<Blacksmoke16> and ofc other lighter ones are above that
<raz>
yea perf is not gonna be an issue here anyway, was just a bit surprised by that. but for me it's a plus, so i could easily hook it in, no need to worry about initialization or keeping state around
<FromGitter>
<Blacksmoke16> exactly, this way each request has its own scope
<raz>
meh yea, that needs tuning. how am i gonna run my facebook on my raspberry :<
<FromGitter>
<Blacksmoke16> so service interactions are all reset on each new request
<raz>
yup, it's very pleasant so far, i could see this becoming the default api framework for crystal
<FromGitter>
<Blacksmoke16> 🚀 i try 😉
<raz>
it's a bit springy/javaesque, but easy enough to get started without learning all the ADIs and OUDIs :D
<raz>
and the param validation / annotations is shweet
<FromGitter>
<Blacksmoke16> its that part that makes it as flexible/customizable as it is
<FromGitter>
<Blacksmoke16> isn't required for simple setups, but as you get more complex it can make things much easier to manage
<FromGitter>
<Blacksmoke16> validation component is my fav so far :P
<raz>
yup, will take a while to get into it for me. but the ease of overriding those error handlers is already a good sign
<hightower3>
Blacksmoke16 what would be the likely cause of Crystal frameworks being 20ish or lower on the list?
<hightower3>
the performance of HTTP::Server itself, or?
<FromGitter>
<Blacksmoke16> dunno, prob a combination of many things
<FromGitter>
<Blacksmoke16> framework itself, the specific run when results were generated, etc
<FromGitter>
<Blacksmoke16> lucky is 3rd from last, dunno whats up with that :/
<FromGitter>
<Blacksmoke16> maybe a bunch of IO loggin?
<hightower3>
or how is a PHP thing first... strange as well unless I'm not aware of something...
remby has quit [Remote host closed the connection]
remby has joined #crystal-lang
remby has left #crystal-lang [#crystal-lang]
<FromGitter>
<Blacksmoke16> iirc there was a "results are not prod ready yet" thing in the readme
<raz>
look at those numbers tho... anything in top 100 is plenty fine unless you're facebook
<FromGitter>
<Blacksmoke16> mhm
<FromGitter>
<Blacksmoke16> also depends on what the hardware running it is and such
<hightower3>
yeah it only makes sense in comparison from one entry to another... it would probably be interesting to run the same test against HTTP::Server alone, without any framework
<raz>
for any framework in these spheres the db and external calls will be the bottleneck anyway
<FromGitter>
<Blacksmoke16> these ones dont have any db interaction, they're more so testing the router imo
<raz>
well, it's supposed to test the framework, i think
<hightower3>
"Measuring response times (routing times) for each framework (middleware)."
<raz>
it would be helpful if they mentioned what hardware they got those numbers from
<raz>
but on my macbook athena gives me ~7.5k/s with a naive `wrk -d 10 -c 20`
<FromGitter>
<Blacksmoke16> implementation for that uses all thread and `reuse_port`
<raz>
that's safely in i-dont-care territory ;)
<FromGitter>
<Blacksmoke16> ideally want to update it to use `MT` mode, but still waiting on that gc release so it can be linked statically in alpine :/
<raz>
yea well, i maintain some large'ish sites, and the app-server is very rarely the bottleneck (unless it's rails...). and even if it is, it's the most trivial part to scale out
<raz>
db connections (pg), db in general and concurrency limits (hello ruby) are the painful ones
<FromGitter>
<Blacksmoke16> easier to go wide than tall
<FromGitter>
<Blacksmoke16> more servers versus one beefer server
<raz>
yea the big problem with ruby is not the slowness but the RAM use + limited concurrency.
<raz>
that's actually the more interesting benchmark to do in any framework. how many sleep(rand(10)) can it sustain concurrently :)