<RX14>
but thats only because I havent done the boilerplate
<RX14>
get it working then get is usable
<RX14>
:)
<RX14>
it proves that it's possible
<RX14>
at least
<Papierkorb>
yeah, even with the boilerplate, the hard work is done
<RX14>
took me a good few minutes to work out that tap doesn't work with structs
<Papierkorb>
structs are pretty evil at times
<RX14>
yeah
<RX14>
eazy fix though
<RX14>
1 more line of code
<Papierkorb>
It's more often than not easily visible if it will work or not, sadly, as there's no reference type like in C++
<RX14>
hmm
<RX14>
maybe I should have made resume token an integer then use hash
<RX14>
we'll see what asterite thinks
<Papierkorb>
a mapping Hash?
<Papierkorb>
Sounds racey
<RX14>
no
<RX14>
Object#hash
<RX14>
hmm
mgarciaisaia has quit [Ping timeout: 260 seconds]
<Papierkorb>
If possible, maybe an abstract struct (or so) instead of Void* - or is the pointer size the culprit?
<RX14>
the current select impl does allocate
<Papierkorb>
To easily distinguish between incoming reads, whatever else, and the `gtfo` notification
<RX14>
Papierkorb, well you need something thats really easy for every resume point to work out
<RX14>
like
<RX14>
your "token" needs to be unique to the object, and easilly worked out
<RX14>
so that the resume point needs nothing more than the fiber handle
<RX14>
otherwise you end up storing Deque(Fiber | Action) which is just messy
<RX14>
I much prefer the resuming fiber just being logicless in that it always sets the resume token, without the knowledge that the resumed fiber will use it
mgarciaisaia has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<RX14>
i'll probably need some sort of mask though to differentiate between receive or send on the same object
<Papierkorb>
sure, simplicty above everything else. and I don't know your exact implementation, which makes it hard to reason about it too ;)
<RX14>
well
<RX14>
i'm committing it now
<RX14>
maybe I should do it in the morning...
<Papierkorb>
no need rushing it, these 10 hours won't change anything I guess
<RX14>
sure
mgarciaisaia has quit [Ping timeout: 268 seconds]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has quit [Read error: Connection reset by peer]
akwiatkowski has joined #crystal-lang
<RX14>
hmm
<RX14>
these spedns are going to need some work
<RX14>
specs*
<RX14>
like reproducing a blocking write is hard
<RX14>
you can set a pipe's buffer size
<RX14>
but only to a minimum of 1 page
vikaton has joined #crystal-lang
bjz has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
<crystal-gh>
[crystal] RX14 opened pull request #3595: [WIP] Generic Select for IO (master...feature/io-select) https://git.io/v1kZK
akwiatkowski has quit [Ping timeout: 264 seconds]
<RX14>
Papierkorb, ^
<Papierkorb>
neato
<RX14>
well i guess i'll see how that turns out in the morning
<Papierkorb>
Will take a look tomorrow too
hako has joined #crystal-lang
mgarciaisaia has quit [Read error: Connection reset by peer]
mgarciaisaia has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Read error: Connection reset by peer]
soveran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
soveran has joined #crystal-lang
mgarciaisaia has quit [Read error: Connection reset by peer]
<crystal-gh>
[crystal] lbguilherme opened pull request #3597: [performance] Change Fiber.yield to not generate a timer event and instead just add itself as the last runnable fiber (master...patch-9) https://git.io/v1krl
<crystal-gh>
[crystal] lbguilherme closed pull request #3597: [performance] Change Fiber.yield to not generate a timer event and instead just add itself as the last runnable fiber (master...patch-9) https://git.io/v1krl
hako has quit [Remote host closed the connection]
<Papierkorb>
RX14: Could the pollfds and fdmap be recycled? That'd still malloc data, but chances are good I think that the same select is run in a loop by the fiber, so the array and hash would need the same size, thus no additional mallocs in subsequent select's
<Papierkorb>
I like how much more flexible the whole `select` stuff is with that though. Also the rename of `(un)wait_for_x` to `activate_x` is a good one, much clearer what they actually do
vasilakisfil has joined #crystal-lang
<vasilakisfil>
is this allowed? SUBDOMAIN = ENV["SUBDOMAIN"]
<vasilakisfil>
because the value is not known compile time..
<vasilakisfil>
I guess not..
ome has quit [Quit: Connection closed for inactivity]
<crystal-gh>
[crystal] asterite pushed 1 new commit to master: https://git.io/v1kXM
<crystal-gh>
crystal/master bbc348c taicsuzu: add bin
<FromGitter>
<lbguilherme> @vasilakisfil it is totally allowed. constants don't have to be known at compile time
pawnbox has quit [Remote host closed the connection]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter>
<sdogruyol> I am not sure if it's for constants otherwise you can do that
vasilakisfil has quit [Ping timeout: 246 seconds]
Philpax has quit [Ping timeout: 260 seconds]
<RX14>
Papierkorb, pollfds are structs so essentially free
<RX14>
the cost of reusing a struct is probably greater than keeping it simple and just allocating it on the stack
x0f_ has joined #crystal-lang
x0f has quit [Ping timeout: 256 seconds]
x0f has joined #crystal-lang
<crystal-gh>
[crystal] splattael opened pull request #3598: Prefer new `lib` path over old `libs` (master...swap-libs-search_path) https://git.io/v1ky9
hako has joined #crystal-lang
x0f_ has quit [Ping timeout: 258 seconds]
Fichtenstein has quit [Ping timeout: 250 seconds]
Fichtenstein has joined #crystal-lang
<Papierkorb>
RX14: Was referring to the Array and Hash objects
<RX14>
oh yeah sorry
<RX14>
uhh i don't know if that would be particularly easy to cache
<RX14>
how do you verify you have equivalent cations
<RX14>
actions*
<RX14>
i think that elimination would be the best route to go down at first
<Papierkorb>
I only tried to avoid the malloc(), not the refilling of the array/hash. Though I'm not sure how expensive that even is
<RX14>
then if we're sure that they can't be eliminated, then try to optimize by caching
<RX14>
for example one route is to take the actions and perform a map to {action, pollfd?}
<RX14>
which gets rid of the fdmap
<RX14>
if actions is an array that'll malloc, but if it's a struct it won't
<Papierkorb>
I'm wondering right now if the compiler can't create the maps
<RX14>
for pollfds, we can just allocate an static-sized array with a good number of pollfds
<Papierkorb>
even if filling them in is done later in the code. Or a StaticArray with a generous size, 32 or so. would limit the case count per select to that size
<RX14>
i mean uninitialized Pollfd[100] or something
<RX14>
then just switch on the 100 mark
<Papierkorb>
I'm not even sure if that is needed, how likely is it to have that many cases in a single select?
<RX14>
well
<RX14>
it's 8 bytes per Pollfd
<RX14>
100 is only 800 bytes
<Papierkorb>
Not saying against the 100 mark (or whatever number)
<Papierkorb>
Was referring to > [16:22] <RX14> then just switch on the 100 mark
<RX14>
yes but 800 bytes is tiny compared to L1
<Papierkorb>
I read the `then just switch` as "fallback to a dynamically allocated data structure"
<RX14>
L1 cache is 32KB plus just for data
<Papierkorb>
I'm perfectly fine with that
<RX14>
maybe 64 or 128 would be a more round aligned number
<Papierkorb>
Now that I'm working on a small-ish tun/tap shard, I could also easily benchmark such code :P
<Papierkorb>
We're on the same page that a single pollfd equals a single `when io` in the select statement, right?
<RX14>
yes
<RX14>
but it won't just be just select in code
<RX14>
there's a reason select takes an array
<RX14>
not just a struct
<RX14>
there are cases when you do want to select on a large number of possible options
<RX14>
sorry, tuple not struct
<RX14>
select statement can't be dynamic size but select call can be
<Papierkorb>
select as in IO#select ?
<Papierkorb>
Which you thought about getting rid of?
<RX14>
and replacing it with Select.select
<RX14>
it's still a normal method call
<RX14>
I ahve every reason to believe that Select.select will be widely used outside of generated code
<Papierkorb>
as long it advocates using the statement version over the method version whenever possible in the docs, so people looking for `select()` find out about the statement version, and leave the method version for these cases where it's actually neede
<Papierkorb>
d
<RX14>
well yes raw select is a pain to use
<RX14>
thats why the statement was introduced
<RX14>
we had Channel.select in used for a long while before the select staement
<Papierkorb>
Sure, I'm just saying the docs should make a reader aware of it
<Papierkorb>
people new to crystal won't know about it
<crystal-gh>
[crystal] asterite closed pull request #3598: Prefer new `lib` path over old `libs` (master...swap-libs-search_path) https://git.io/v1ky9
<Papierkorb>
unrelated, is there anything against having `StaticArray#to_slice`? It's a pain to load a String into a lib struct's Char[x]
<BlaXpirit>
Papierkorb, yeah it's not even only StaticArray. i very often run into missing to_slice
<BlaXpirit>
probably not anyone familiar at the moment. i've ran into it but decided to reinvent the wheel instead
<FromGitter>
<agibralter> I can't seem to get `error!` to actually set the status to non-zero. I was wondering if anyone else came across the same issue?
<FromGitter>
<drosehn> Is there a way to declare an `@instance` variable such that it is initialized to `nil`, but after that it cannot be set to `nil`?
<BlaXpirit>
drosehn, you can simulate that easily with 2 variables and make it seamless to the user
<FromGitter>
<agibralter> Ok how about this one: what's the proper way to set the environment in Process.run ? Is it a hash?
<Papierkorb>
You may also like the `property!` version, depending on your use case
<FromGitter>
<agibralter> @BlaXpirit thank you
<RX14>
@drosehn, just use a raise-on-nil getter
<BlaXpirit>
agibralter, i've been looking at mosop/cli and i dont see an obvious bug there. but it's possible that you have to handle the exit yourself..?
<RX14>
or if possible ||=
<FromGitter>
<drosehn> I was looking for versions of `property` yesterday, but couldn't seem to find the documentation for `property`.
<FromGitter>
<agibralter> @BlaXpirit hmm, I have `error!(help: true)` in my `def run`, and it's display the help text correct... the return code is `0` though. Not a big deal, but I was wondering why that's happening
<FromGitter>
<drosehn> Thanks!
<FromGitter>
<agibralter> Actually when I get a `Parsing Error` it still gives me `0`...