Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 20:55
    straight-shoota milestoned #12814
  • 20:55
    straight-shoota milestoned #12814
  • 19:40
    straight-shoota closed #12812
  • 19:35
    straight-shoota closed #12782
  • 19:34
    straight-shoota closed #12818
  • 19:34
    straight-shoota closed #12824
  • 13:49
    Blacksmoke16 labeled #12825
  • 07:05
    naqvis labeled #12825
  • 07:05
    naqvis opened #12825
  • 02:47
    Blacksmoke16 reopened #8468
  • 02:45
    Blacksmoke16 closed #8468
  • Dec 06 13:16
    straight-shoota milestoned #12824
  • Dec 06 13:16
    straight-shoota milestoned #12824
  • Dec 06 13:07
    straight-shoota edited #11555
  • Dec 06 11:30
    straight-shoota milestoned #12782
  • Dec 06 11:30
    straight-shoota milestoned #12782
  • Dec 06 09:51
    BlobCodes synchronize #12687
  • Dec 06 09:34
    caspiano labeled #12824
  • Dec 06 09:34
    caspiano opened #12824
  • Dec 06 09:34
    caspiano labeled #12824
From IRC (bridge bot)
@FromIRC
<straight-shoota> > Would a binary cross compiled result in the same binary compiled locally assuming they're both static/release/etc/source version/target version
<straight-shoota> Yes, should have the same result AFAIK
<straight-shoota> Code is generated by LLVM and that should operate the same way, whether it's building for the native architecture or a different one
Daniel Worrall
@Daniel-Worrall
So, I had an answer in the crystal discord. Reproducability (byte-for-byte) is a complicated issue, but the programs will be "the same"
Isaac Sloan
@elorest
Is there a better way to do line 2 of this? A way to take advantage of the fact that the compiler already knows what type the value is supposed to be.
https://carc.in/#/r/bb91
Kirk Haines
@wyhaines

@elorest: I don't know if this qualifies as "better"....

class Array
  def t
    T
  end
end

arr = Array(Hash(String, String | UInt64 | Int64 | Float64)).new
arr << arr.t.new

It's shorter, but calling the method that was added to Array #t is not particularly clear, and it is dependent on implementation details, but it does take advantage of the type of the array already being known. It could maybe be made less objectionable with:

class Array
  def add_new_value(*args)
    self << T.new(*args)
  end
end

arr = Array(Hash(String, String | UInt64 | Int64 | Float64)).new
arr.add_new_value

Or something kind of similar to that.

Generally, reopening standard lib types to add things is risky business, especially when they depend on other implementation details.
Isaac Sloan
@elorest
@wyhaines Yeah I generally try to avoid that. I was hoping there was something more general with types and aliases. Thanks though.
Sung-Chul Lee
@sclee15
Will CrystalConf unvail videos on YouTube? I am a Crystal user from South Korea. Since the event time starts up at 12AM in my timezone. I cannot attend the live event.
Kirk Haines
@wyhaines

I don't know of any standard method that gives you the type that an array stores, unless you go and create one yourself as above.

You could finagle something with a macro and typeof, which might also be reasonable if you are repeating the above pattern A LOT, but it also won't be particularly pretty in implementation).

Ali Naqvi
@naqvis
1 reply
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