<FromGitter>
<wyhaines> @didactic-drunk So, the nutshell version is that I have a server that will potentially have hundreds of concurrent socket connections coming into it, feeding a continuous stream of data into the server. What I want to do is to have a pool of fibers that will service the incoming data, since the vast majority of that data handling will itself be IO blocked -- database inserts or other IO activity will be the
<FromGitter>
... end result of most of that data. ⏎ ⏎ In my ideal world, my implementation will work great on single threaded Crystal, AND when the time comes, and I have dealt with the fiddly bits of thread safety, it will also work if I build it under multithreaded Crystal.
<FromGitter>
<didactic-drunk> All my code is tested MT daily. It also works single threaded.
<FromGitter>
<didactic-drunk> With IO heavy workloads.
<FromGitter>
<wyhaines> I'm refactoring some of the network internals tonight and tomorrow. I'll pull your code in and see if I run into issues.
<FromGitter>
<didactic-drunk> I'm using similar code for a non HTTP service with sqlite as the backend.
livcd has quit [Ping timeout: 265 seconds]
<FromGitter>
<wyhaines> That's fairly similar to what I will be writing. I just finished some other debugging, so I am looking at it right now.
<postmodern>
do you still have to install the crystal snap with --classic? appears that newer snaps are phasing out classic snaps and the /snap, ~/snap directories.
<postmodern>
also having trouble removing it once installed as a --classic
<FromGitter>
<wyhaines> @didactic-drunk Well, my reaction upon integrating `concurrent/channel` and testing? ⏎ ⏎ "Holy shit that ran fast!" ⏎ ⏎ I appreciate how easy it was to just drop that into the code in place of the single-fiber code, and it *dramatically* increased my throughput. [https://gitter.im/crystal-lang/crystal?at=5ef81bd5fa0c9221fc652a3b]
postmodern has quit [Quit: Leaving]
postmodern has joined #crystal-lang
<postmodern>
nevermind, i re-installed snapd, removed ~/snap, re-installed crystal --class and now the permission issues are fixed.
<postmodern>
what is the preferred way to send stop messages via Channels? I saw in the docs that Channel(Nil) or Channel(Type?) is considered a bad practice.
<FromGitter>
<didactic-drunk> `channel.close` ?
sagax has quit [Ping timeout: 246 seconds]
<FromGitter>
<didactic-drunk> @wyhaines Try with -Dpreview_mt and --release. Compare runtime. You may exceed the db speed.
deavmi has quit [Ping timeout: 256 seconds]
deavmi has joined #crystal-lang
<FromGitter>
<didactic-drunk> @wyhaines Beware of `serial`. Once you call that you're processing in the current fiber. If there's nothing feeding the stream it will hang.
alexherbo2 has joined #crystal-lang
deavmi has quit [Ping timeout: 264 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 256 seconds]
<oprypin>
postmodern: yes send whatever sentinel you want
deavmi has joined #crystal-lang
<oprypin>
send send send send close can lose the messages if the other side has not received them
<oprypin>
send send send send send(nil) is reliable
<oprypin>
cc @didactic-drunk
Nekka has quit [Quit: zzz]
Nekka has joined #crystal-lang
alexherbo26 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo26 is now known as alexherbo2
sagax has joined #crystal-lang
<FromGitter>
<bararchy> we really need a `--no-cache` option for build :)
alexherbo2 has quit [Read error: Connection reset by peer]
<FromGitter>
<bararchy> Is there a way to see how many Fibers running at a given time?
<FromGitter>
<Daniel-Worrall> that's not what you're asking
<FromGitter>
<bararchy> yeha :)
<postmodern>
oprypin, how do you do the type signature for `Type | literal-sentinel-only`?
oddp has joined #crystal-lang
<yxhuvud>
if your sentinel is nil it would be Type | Nil. If your sentinel is something else the general answer would replace nil with the output of typeof(whatever you use as sentinel value)
deavmi has quit [Ping timeout: 246 seconds]
deavmi has joined #crystal-lang
<oprypin>
postmodern, using Nil is totally fine. or `record Sentinel; x : Int32 | Sentinel = Sentinel.new`
<oprypin>
lbarasti, it's being expanded within the context of macro included, not within the destination. add slash https://play.crystal-lang.org/#/r/9c5k
<FromGitter>
<lbarasti> uh, I see, but isn't it weird that it resolves `V` correctly
<oprypin>
lbarasti, damn dude i dont know,, i have only guesses
<oprypin>
so *actually* seems like what i said is wrong
<oprypin>
so it gets expanded in the destination but if u dont add the slash, it's expanded immediately and theres no instance var yet
<FromGitter>
<lbarasti> well, your solution takes me out of my misery, at least :D
<oprypin>
but if u add the slash, it's executed in the context *of that method*
<FromGitter>
<lbarasti> 🙏
<FromGitter>
<j8r> I'm thinking back of the infamous case of enums, uppercase or camecalse :P?
<FromGitter>
<j8r> strange I found that using the symbol shortband on a camelcased enum, like`HTTP::WebSocket::CloseCode::GoingAway` is `:going_away`
<oprypin>
whats strange
<FromGitter>
<j8r> I thought to be `:goingaway`, but it makes sense
<FromGitter>
<j8r> to have the underscore
<FromGitter>
<j8r> Now I will favor enum with upper case, more consistent with snake case
<FromGitter>
<j8r> nvm `:GoingAway` is also valid O.o
<FromGitter>
<j8r> I will use this then, I didn't know tha(
<sorcus>
Where i can find examples for `asm` in Crystal?
<sorcus>
:-D
<FromGitter>
<asterite> @lbarasti instance var information is macros inside methods, never in top-level macros
<oprypin>
i suppose you're right with this example. i'm a bit confused, i must have been thinking of some different scenario
<FromGitter>
<didactic-drunk> Multiple senders? If one closes the remaining can't send.
<FromGitter>
<wyhaines> I can't get it to not behave as expected, either. My version was similar.
<yxhuvud>
I can see closing it from the receiver side would be troublesome though.
masterdonx2 has joined #crystal-lang
MasterdonX has quit [Ping timeout: 246 seconds]
DTZUZU_ is now known as DTZUZU
yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
yxhuvud has joined #crystal-lang
<sorcus>
No one knows how to use an assembler in crystal?
<FromGitter>
<naqvis> sorcus, is that a question or a comment to some message in this channel?
<sorcus>
naqvis: a question.
<FromGitter>
<naqvis> so if your question is how to write assembler code in crystal, then I will doubt it
<FromGitter>
<naqvis> you can write that in C and then do the linkage in Crystal
<sorcus>
naqvis: I'm interested in trying the assembler inserts in crystal.
postmodern has quit [Quit: Leaving]
<FromGitter>
<naqvis> sounds like a plan. Its good you can proceed with PoC then go with RFC
<sorcus>
naqvis: RFC for what? o_O
<FromGitter>
<naqvis> if I understand your intention correctly, then I was suggesting that once you have PoC ready, you can raise an RFC to add assembler support in crystal
<sorcus>
naqvis: And i apologize for my English. X-)
<FromGitter>
<naqvis> 🌹 , sorry don't have knowledge of this `asm` keyword
<FromGitter>
<naqvis> let's wait for someone else to jump in and provide some insights
rocx has joined #crystal-lang
Human_G33k has quit [Ping timeout: 260 seconds]
HumanG33k has joined #crystal-lang
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 265 seconds]
HumanG33k has joined #crystal-lang
Human_G33k has quit [Read error: Connection reset by peer]
<raz>
is there any way to get usable backtraced out of a --static build nowadays?
<raz>
tried with libunwind and such, but the most i could achieve is random segfaults at compile time (and still no backtraces when it doesn't fault) :(
<FromGitter>
<Blacksmoke16> did you build with `--debug`?
<raz>
Error: undefined method 'hexfinal' for Sodium::Digest::Blake2b
<raz>
neither hexfinal, hexdigest nor final.hexstring works in my build for some reason
<FromGitter>
<watzon> @bararchy there may be a way that doesn't require copying the `#initialize` function line for line, but this works https://carc.in/#/r/9c9h
<FromGitter>
<dscottboggs_gitlab> if I were working on a project that had methods called that I might feel compelled to rename them like `#hex_final`..
<FromGitter>
<dscottboggs_gitlab> Does Crystal have small-string optimization?
<oprypin>
dscottboggs_gitlab, no
<oprypin>
but hey there's a pretty good any-string optimization that it doesnt go through two pointers
<oprypin>
in memory it's [length,bytesize,char,char,char,char,char] rather than [length,bytesize,pointer]
<FromGitter>
<dscottboggs_gitlab> oh cool
<FromGitter>
<dscottboggs_gitlab> I'm surprised but I did not think of that, that's a really cool way to handle that
deavmi has quit [Ping timeout: 265 seconds]
<FromGitter>
<didactic-drunk> @raz New sodium release.
<raz>
ha! right after i switched out my blake for ol'sha256 :D
<raz>
gonna switch back tomorrow and will let ya know if it still bugs (gonna call it a night for now, but fwiw/fyi, all my other sodium stuff looks fine - was only blake that had a problem here)
<FromGitter>
<didactic-drunk> @dscottboggs_gitlab `hexfinal` is an optimization of `hexdigest` which came from ruby. Me thinks maybe I should have left it as `hexdigest` for compatibility and let the programmer fix their code if it's called twice.
<FromGitter>
<didactic-drunk> `hexfinal` is missing because I expected #9292 to be in 0.35.1.
<FromGitter>
<didactic-drunk> Sodium was the testing ground for the 2 crystal PR's. Eventually I moved `hexfinal` to crystal after months of use. Sodium + the 2 PR's were meant to work together and partial backward compatible methods are available in sodium. They were all meant to work together, but upgraded in any order (upgrade sodium, or crystal or both). Not merging 9292 threw that off a bit.