Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 06:23
    matthewmcgarvey labeled #12831
  • 06:23
    matthewmcgarvey opened #12831
  • 00:44
    straight-shoota unlabeled #11647
  • 00:43
    straight-shoota milestoned #11647
  • 00:43
    straight-shoota milestoned #11647
  • 00:24
    straight-shoota assigned #12534
  • Dec 09 18:24
    Blacksmoke16 labeled #12830
  • Dec 09 18:16
    FnControlOption labeled #12830
  • Dec 09 18:16
    FnControlOption opened #12830
  • Dec 09 14:39
    Blacksmoke16 synchronize #10648
  • Dec 09 12:23
    straight-shoota assigned #12740
  • Dec 09 12:23
    straight-shoota synchronize #12740
  • Dec 09 11:28
    straight-shoota closed #11409
  • Dec 09 11:28
    straight-shoota labeled #11409
  • Dec 09 11:28
    straight-shoota labeled #11409
  • Dec 09 11:25
    straight-shoota labeled #12829
  • Dec 09 11:25
    straight-shoota labeled #12829
  • Dec 09 11:25
    straight-shoota closed #7532
  • Dec 09 11:24
    straight-shoota labeled #7532
  • Dec 09 11:24
    straight-shoota labeled #7532
G. Gibson
@mistergibson:matrix.org
[m]
is there a source build path for the arm64 arch?
I've got a Raspberry Pi 400 running Ubuntu and would like to add crystal
From IRC (bridge bot)
@FromIRC
<straight-shoota> You can cross compile from a x86 system
<straight-shoota> @mistergibson ^
Daniel Worrall
@Daniel-Worrall
I've got a docker image of arm64 alpine https://hub.docker.com/r/danielworrall/crystal
Daniel Worrall
@Daniel-Worrall
Can either use it in rpi docker, or use it to build for ubuntu without cross compile
Daniel Worrall
@Daniel-Worrall
Okay, I don't have a Comp Sci background, so hopefully this isn't a dumb question. Would a binary cross compiled result in the same binary compiled locally assuming they're both static/release/etc/source version/target version
G. Gibson
@mistergibson:matrix.org
[m]
the arm procedure didn't work for me -- I'll keep trying. Any idea when an official arm64 build will be forthcoming?
Daniel Worrall
@Daniel-Worrall
If you check out the dockerfile, you can see the usual hardships with cross-compiling, specifically the compiler. libcrystal.a for example, which is being removed in future crystal builds
Also uses alpine to avoid problems with dynamic linking
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.