Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 14:55
    asterite synchronize #12574
  • 14:39
    asterite synchronize #12574
  • 14:26
    asterite synchronize #12574
  • 12:45
    asterite labeled #12574
  • 12:45
    asterite labeled #12574
  • 12:45
    asterite opened #12574
  • 10:33
    lbguilherme edited #12571
  • 10:33
    lbguilherme ready_for_review #12571
  • 10:31
    lbguilherme synchronize #12571
  • Oct 06 23:30
    lbguilherme synchronize #12571
  • Oct 06 23:25
    Blacksmoke16 labeled #12573
  • Oct 06 23:19
    robacarp labeled #12573
  • Oct 06 23:19
    robacarp opened #12573
  • Oct 06 22:34
    lbguilherme synchronize #12571
  • Oct 06 20:14
    beta-ziliani closed #12568
  • Oct 06 19:59
    beta-ziliani synchronize #12568
  • Oct 06 19:31
    lbguilherme synchronize #12571
  • Oct 06 19:09
    asterite synchronize #12524
  • Oct 06 18:52
    straight-shoota labeled #12572
  • Oct 06 18:43
    asterite synchronize #12524
From IRC (bridge bot)
@FromIRC
<yxhuvud> @wyhaines: typeof(array.first), but yes, it is not super pretty.
3 replies
From IRC (bridge bot)
@FromIRC
<yxhuvud> hrrm. Monkeypatching certain things would be easier if kernel.cr didn't execute as much directly in the top scope. :⁠(
ddd
@Dan-Do
Can we spawn fibers on GPU instead of CPU?
George Dietrich
@Blacksmoke16
no
i remember seeing a shard that allowed using GPU for stuff, but not sure if it's applicable here
ddd
@Dan-Do
:thought_balloon:
thinking :)
ddd
@Dan-Do
okay, can we do this?
done = Channel(Nil).new
spawn do
  call_next(context)
ensure
  done.send nil
end
select
when done.receive
  # print content
when timeout(34.seconds)
  # how to print stack trace to investigate which code causes long processing
  raise "Server could not process_request in 34 seconds"
end
George Dietrich
@Blacksmoke16
for what reason?
ddd
@Dan-Do
I don't know it is because of db, or pooling or business logic processing...
the call_next(context) is more or less like your Athena's Controller
Ali Naqvi
@naqvis
@Dan-Do there is no way, timeout will happen on channel, so it got no relation with any specific fiber
George Dietrich
@Blacksmoke16
not entirely, thats more of how the other frameworks work. I.e. an Array(HTTP::Handler)
Ali Naqvi
@naqvis
what you need is detailed logging inside your logic, so that you can capture detailed information and see what is happening or what is causing the delay
ddd
@Dan-Do
Ok I will go with logging. Can I narrow the log by just logging the fibers which has running time longer than ex 30.seconds
I don't see any method like Fiber.current.running_time
Ali Naqvi
@naqvis
no
simple approach would be
  1. start the timer before you call call_next
  2. Log fiber-id and other specific details like what work its doing
  3. after method returns, log the time it took to process the request
ddd
@Dan-Do
Yes, thanks.
Ali Naqvi
@naqvis
remember to use Time.monotonic
start = Time.monotonic
# do work
elapsed = Time.monotonic - start
ddd
@Dan-Do
:thumbsup:
George Dietrich
@Blacksmoke16
duration = Time.measure do
  # Do work
end
does literally the same thing, just via a built in method
Ali Naqvi
@naqvis
oh yeah ^
didactic-drunk
@didactic-drunk
How can i compare Pointer(UInt8)@0xffffffffffffffff with a platform type specific -1? mmap returns -1
From IRC (bridge bot)
@FromIRC
<yxhuvud> pointer.address.
<yxhuvud> and then go from there.
<yxhuvud> @didactic-drunk: btw, you are doing some fairly interesting stuff in concurrent.cr.
Ali Naqvi
@naqvis
@didactic-drunk Pointer(UInt8) with signed value? how can that happen?
From IRC (bridge bot)
@FromIRC
<yxhuvud> @naqvis: -1 would be the error code of mmap.
Ali Naqvi
@naqvis
point i'm making is unsigned int can't have signed values, so pointer type he is using is wrong
From IRC (bridge bot)
@FromIRC
<yxhuvud> I mean, it is pointing to an uint8. But the address ffffffffffffffff is clearly not a pointer as it isn't a valid address.
Ali Naqvi
@naqvis
in that case shouldn't the Pointer#null? be used to validate the pointer?
From IRC (bridge bot)
@FromIRC
<yxhuvud> but it isn't a null pointer.
<yxhuvud> (unless the machine is very weird and happen to define ffffffffffffffff to be null)
Ali Naqvi
@naqvis
true but 0xffffffffffffffff is normally segfault
so either that is a dangling pointer or some other issues
Quinton Miller
@HertzDevil
c libraries have this weird habit of casting special values to void* directly
From IRC (bridge bot)
@FromIRC
<yxhuvud> No, it is the return code from a syscall. It is very common to let negative result values indicate error status and positive be some other type.
Quinton Miller
@HertzDevil
including posix's c libraries
or should i say api
From IRC (bridge bot)
@FromIRC
<yxhuvud> Yes. And io_uring and a bunch of others.
Quinton Miller
@HertzDevil
so @naqvis it is not so much an "issue" as it is part of c's tradition
Ali Naqvi
@naqvis
:P , yeah and C do that for reference types
i mean for FFI where you know C is returning a reference then isn't out a better choice?
From IRC (bridge bot)
@FromIRC
<yxhuvud> Not really an option for mmap.
Ali Naqvi
@naqvis
just looked into mmap manpage :P
@didactic-drunk you can do a comparison against Pointer(Void).new(-1)
Quinton Miller
@HertzDevil
for the record, that constructor calls -1.to_u64!