ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.33.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
gangstacat has quit [Quit: ฤœis!]
gangstacat has joined #crystal-lang
postmodern has joined #crystal-lang
_whitelogger has joined #crystal-lang
_ht has joined #crystal-lang
postmodern has quit [Quit: Leaving]
ur5us has quit [Ping timeout: 240 seconds]
_ht has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 256 seconds]
Stephie has quit [Quit: Fuck this shit, I'm out!]
Stephie has joined #crystal-lang
<FromGitter> <j8r> Hum, I didn't know an object can inherit from class methods
alexherbo2 has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <j8r> Horrible to run https://github.com/the-benchmarker/web-frameworks
<FromGitter> <j8r> The instructions are very sparse
woodruffw has quit [Ping timeout: 265 seconds]
<FromGitter> <j8r> I just want to run benchmarks, not set up a PG instance and spent time in sql commands :(
woodruffw has joined #crystal-lang
ravenx has quit [Ping timeout: 240 seconds]
darkstardevx has quit [Ping timeout: 256 seconds]
<FromGitter> <Blacksmoke16> should just have to follow the readme
<FromGitter> <Blacksmoke16> main things being like `docker-compose up` and then export the database url
ravenx has joined #crystal-lang
darkstardevx has joined #crystal-lang
<FromGitter> <j8r> doesn't work
<FromGitter> <Blacksmoke16> oh?
<FromGitter> <j8r> Postgres wants a password
<FromGitter> <j8r> Then I have to install psql, etc etc
<FromGitter> <Blacksmoke16> :thinking:
<FromGitter> <j8r> Would be great if the docker compose can also import the sql dump
<FromGitter> <Blacksmoke16> i just have start the container and do a `export DATABASE_URL="postgresql://postgres@localhost/benchmark"`
<FromGitter> <Blacksmoke16> ahh yea, for that the compose file mounts the dump into the container
<FromGitter> <Blacksmoke16> so you can do like `docker exec -it postgres sh`
<FromGitter> <Blacksmoke16> then run the command in the readme within the container
<FromGitter> <Blacksmoke16> it gets mounted to `/usr/src/db/dump.sql`
<FromGitter> <j8r> yep, that's meh :(
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <j8r> have you tried on a new directory?
<FromGitter> <j8r> It takes the pre-existing database for me, can't get how to start from scratch again
<FromGitter> <j8r> one other point is the containers still run, never stops
<FromGitter> <j8r> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e678928cc10be22a079394b]
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Blacksmoke16> could try clearing all your images/volumes (assuming there isnt anything you have locally you want to keep)
<FromGitter> <Blacksmoke16> that would make it have to recreate the db
<FromGitter> <j8r> it is a celaned
<FromGitter> <j8r> that was the very first time, I got this error
<FromGitter> <j8r> ho, will add `POSTGRES_HOST_AUTH_METHOD=trust`
<FromGitter> <Blacksmoke16> okey dokey
<FromGitter> <j8r> I will make a PR then - waiting the results against the faster Crystal router: `router.cr`
<FromGitter> <Blacksmoke16> howd your thing do?
<FromGitter> <j8r> ...? `Unhandled exception: Missing hash key: "concurrency_1024" (KeyError)`
<FromGitter> <Blacksmoke16> ๐Ÿ˜
flaviodesousa has joined #crystal-lang
alexherbo28 has joined #crystal-lang
<FromGitter> <j8r> another fix to send :/
alexherbo2 has quit [Ping timeout: 258 seconds]
alexherbo28 is now known as alexherbo2
<FromGitter> <wout> In many specs I am initializing the same object. In RSpec we have `subject { object = Object.new }`. Is there something similar in Crystal's Spec?
<FromGitter> <wout> Or should I just use a method? Like:
<FromGitter> <wout> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e67992002dbe022a17adaee]
<FromGitter> <Blacksmoke16> a method, or just do it inline
<FromGitter> <wout> ๐Ÿ‘ Thanks!
<FromGitter> <j8r> @Blacksmoke16 it looks like my web framework is slower, but there is room for speed up
<FromGitter> <j8r> I can use Bytes instead of Strings
<FromGitter> <Blacksmoke16> slower compared to what?
<FromGitter> <j8r> athena and router.cr
<FromGitter> <Blacksmoke16> ah
<FromGitter> <Blacksmoke16> by how much? i wouldnt go sacrificing too much just for performance
<FromGitter> <j8r> 1) 5
<FromGitter> <j8r> I'm pretty confident about to make it faster
<FromGitter> <Blacksmoke16> ๐Ÿ‘ sounds like a plan
<FromGitter> <Blacksmoke16> doesnt look like that macro PR is going to make it into `0.34.0` :sad:
<FromGitter> <Blacksmoke16> isnt*
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#6774221 (master - Merge pull request #8885 from waj/feature/no-errno-exceptions): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/660661907
<DeBot> https://github.com/crystal-lang/crystal/pull/8885 (Getting rid of Errno and WinError)
<FromGitter> <j8r> Tried with slices, same perf
<FromGitter> <j8r> I think that the use of a Hash is not as efficient as a Radix tree
gangstacat has quit [Quit: ฤœis!]
<FromGitter> <j8r> I wonder how can I change that... I could use an array
<FromGitter> <Blacksmoke16> are routes immutable?
<FromGitter> <Blacksmoke16> could build the route tree out using a named tuple
<FromGitter> <Blacksmoke16> also could try only instantiating the hash once versus on each request (if thats something you're not already doing)
gangstacat has joined #crystal-lang
<FromGitter> <j8r> routes are added at runtime :/
<FromGitter> <j8r> and yes no hash is created (only one to store params)
<FromGitter> <Blacksmoke16> hmm, could profile it to see whats being slow
<FromGitter> <Blacksmoke16> also could prob run it with the debug PR branch and use https://github.com/RX14/coz.cr to identity things that would bring the biggest boost
<FromGitter> <j8r> Maybe, but here I don't see anything that can slow down except hashing the slice/string
<FromGitter> <stronny> does this even matter? how often are routes being read?
<FromGitter> <j8r> if `/a/b/c` is sent, `a`, `b` and `c` will be hashed
<FromGitter> <stronny> why is this a problem?
<FromGitter> <j8r> hashing is notoriously not very fast
<FromGitter> <j8r> matching chars like Radix would be faster
<FromGitter> <stronny> are you doing a premature optimization?
<FromGitter> <j8r> not really, the base of the framework is now done
<FromGitter> <stronny> I think you should profile an organic application
<FromGitter> <stronny> comparing hello worlds is a sport, not something useful
<FromGitter> <Blacksmoke16> i didnt look too much into it but i assume the thing that slows down athena is the service container
<FromGitter> <Blacksmoke16> newing up n objects on every request
gangstacat has quit [Quit: ฤœis!]
gangstacat has joined #crystal-lang
<FromGitter> <kinxer> Does the Crystal standard library have anything for making byte counts more human readable (like `ls -lh`)?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Int.html#humanize_bytes(io:IO,precision:Int=3,separator=&#39;.&#39;,*,significant:Bool=true,format:BinaryPrefixFormat=:IEC):Nil-instance-method
<FromGitter> <Blacksmoke16> `#humanize_bytes` seems link is broke
<FromGitter> <kinxer> Perfect. Thank you.
_ht has joined #crystal-lang
dannyAAM has quit [Ping timeout: 240 seconds]
<FromGitter> <j8r> @Blacksmoke16 classes or struct?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <j8r> For the service container?
<FromGitter> <Blacksmoke16> ah, its a struct
<FromGitter> <Blacksmoke16> but the objects inside of it can be either
<FromGitter> <j8r> @stronny may be right, it is a bit unfair to compare basic routers with more powerful ones
<FromGitter> <Blacksmoke16> i mean yea
<FromGitter> <j8r> Which does casting and stuff
flaviodesousa has quit [Quit: KVIrc 4.9.3 Aria http://www.kvirc.net/]
<FromGitter> <Blacksmoke16> is a balance between speed and convenience/features
<FromGitter> <j8r> Yep, and at the end if the real application needs to cast โ€“ there won't be much change
<FromGitter> <j8r> minus less safety
<FromGitter> <Blacksmoke16> mhm
<FromGitter> <Blacksmoke16> rails on the list is like 2500/sec
<FromGitter> <Blacksmoke16> im at like 130k/sec, not going to put in so much effort trying to make something that is already well fast enough
<FromGitter> <j8r> Right
<FromGitter> <Blacksmoke16> try and be top of the list
<FromGitter> <Blacksmoke16> rather be focusing on QoL and core framework improvements
<FromGitter> <j8r> Maybe, that's also a way to promote a project
<FromGitter> <j8r> Like Crystal
<FromGitter> <j8r> I will spend a bit of time, learn new things
<FromGitter> <Blacksmoke16> IMO it comes down to the ecosystem of the framework versus how fast it is most of the time
<FromGitter> <j8r> You're right, not too much :)
<FromGitter> <Blacksmoke16> one thing i thought of, might not be a bad idea to provide test utilities
<FromGitter> <Blacksmoke16> i.e. `require "athena/spec"`, which would provide methods and mocks to make testing stuff easier. In future this could include like integration test logic etc
<FromGitter> <Blacksmoke16> one thing i thought of, might not be a bad idea to provide test utilities
<FromGitter> <j8r> Good idea!
<FromGitter> <Blacksmoke16> i dont really recall seeing much about how to test an amber/lucky controller for example
<FromGitter> <Blacksmoke16> outside of E2E tests at least
<FromGitter> <dburnsii> Is there an easy way to send a GET request to a unix socket? Currently using the `HTTP::Server.bind_unix` to create the server and that seems to work, but `HTTP::Client` doesn't accept the `unix://` path
<FromGitter> <Blacksmoke16> `HTTP::Client.get "unix://path/goes/here"`?
<FromGitter> <Blacksmoke16> idk if that would work but worth a shot :p
<FromGitter> <stronny> `@socket : TCPSocket | OpenSSL::SSL::Socket | Nil`
<FromGitter> <stronny> however you may forego HTTP::Client and use `HTTP::Request` and `HTTP::Client::Response` directly
<FromGitter> <dburnsii> @Blacksmoke16 , Tried that, it gives me `Unsupported scheme: unix`
<FromGitter> <Blacksmoke16> rip
<FromGitter> <Blacksmoke16> worth a shot
<FromGitter> <Blacksmoke16> the whole `HTTP::Client` needs a refactor anyway
<FromGitter> <dburnsii> @stronny , so I should open a TCP socket and send a `HTTP::Request` across?
<FromGitter> <stronny> a UnixSocket
<FromGitter> <stronny> basically yes, `HTTP::Request.new(...).to_io(unix_socket)`
<FromGitter> <stronny> and then `HTTP::Client::Response.from_io(unix_socket)`
postmodern has joined #crystal-lang
sagax has quit [Read error: Connection reset by peer]
<FromGitter> <dburnsii> Cool, so that works. I'll keep an eye out for the `HTTP::Client` refactor, but it works just fine for now. Thanks guys!
sagax has joined #crystal-lang
<FromGitter> <drum445> Why does the Time API keep changing?
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#9385051 (master - Deprecate top-level with_color. Add Colorize.with (#8892)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/660775365
<DeBot> https://github.com/crystal-lang/crystal/pull/8892 (Deprecate top-level with_color. Add Colorize.with)
<FromGitter> <j8r> Why String is a class, while Bytes (Slice(UInt8)) is a struct?
<FromGitter> <stronny> Slice does not hold data
<FromGitter> <stronny> it's just a pointer and a size
<FromGitter> <stronny> String has internal buffer
<FromGitter> <j8r> Right, it is just a safe abstraction on to of a Pointer
<FromGitter> <stronny> pointer points to a single byte, slice has size
<FromGitter> <stronny> if you mean safety as a buffer overrun then yes
<FromGitter> <j8r> Typycally a `*UInt8`?
<FromGitter> <j8r> I see
<FromGitter> <stronny> Slice is a generic, as is pointer
ur5us has joined #crystal-lang
<FromGitter> <j8r> Oops i deleted
<FromGitter> <j8r> It is a generic, an Bytes would be internally a `*UInt8`
<FromGitter> <dscottboggs_gitlab> yes
<FromGitter> <stronny> `alias Bytes = Slice(UInt8)`
<FromGitter> <j8r> I will refactor my node tree as a Radix tree, good time to learn more about it
<FromGitter> <dscottboggs_gitlab> well, a struct that contains a `Pointer(UInt8)` and UInt32 noting the size of the struct
<FromGitter> <stronny> trees are O(log N) on access, while hashes are O(N + k)
<FromGitter> <stronny> you may see even less speed
<FromGitter> <j8r> but the operation to hash is huge, compared to match integers
<FromGitter> <dscottboggs_gitlab> only one way to find out
<FromGitter> <j8r> And note the hashing is done for each path segment
<FromGitter> <stronny> depends on a hash function
<FromGitter> <stronny> also does not depend on element count, unlike a tree
<FromGitter> <stronny> what's the usecase?
<FromGitter> <dscottboggs_gitlab> if it's O(log n) then wouldn't it be less expensive for larger datasets and matter less for smaller datasets? that sounds ideal to me
<FromGitter> <stronny> of course there is no one universally best data structure
<FromGitter> <stronny> for larger datasets that would be less expensive than brute force search like O(N), but much more expensive than O(1)
<FromGitter> <dscottboggs_gitlab> In the words of Bjarne Stroustrup, โŽ โŽ > If your reason is โ€œefficiency,โ€ measure. Our intuition is most fallible in matters of the performance of container uses.
<FromGitter> <stronny> well, Bjarne is no authority to me, but that's exactly what I've said to Julien: you are wasting your time on a premature optimisation that would matter nothing in a real application
<FromGitter> <dscottboggs_gitlab> Idk even though it was a footnote, that line really struck me when I read *A Tour of C++*. I don't make un-hedged claims about performance since then
<FromGitter> <dscottboggs_gitlab> I'm saying something different though. I'm saying he should try it and test which implementation is faster under which circumstances
<FromGitter> <stronny> why?
<FromGitter> <stronny> I say do what's easier, performance means nothing here
<FromGitter> <dscottboggs_gitlab> It depends on the use-case?
<FromGitter> <stronny> he needs a Routes storage
<FromGitter> <dscottboggs_gitlab> that's what I thought it was. How is performance not critical?
<FromGitter> <stronny> in a typical http request a route lookup is negligible
<FromGitter> <stronny> it's unnoticable even comparing to HTTP parsing
<FromGitter> <stronny> saying nothing about an actual payload
<FromGitter> <wout> I'm getting a strange error installing a shard: `Failed git ls-tree -r --full-tree --name-only v1.0.0 -- shard.yml (). Maybe a commit, branch or file doesn't exist?`. Adding `branhc: master` to the dependency in shards.yml fixes the issue. But why am I seeing this?
<FromGitter> <bew> which shard is it?
<FromGitter> <stronny> there is no tag `v1.0.0`
<FromGitter> <stronny> only `1.0.0`
<FromGitter> <wout> OK, that explains it. Thanks!
<FromGitter> <wout> @stronny Should tags for shards always be prefixed with `v`?
<FromGitter> <stronny> I've somewhere that it's indeed the current convention
<FromGitter> <wout> Good to know. :)
<FromGitter> <dscottboggs_gitlab> > Should tags for shards always be prefixed with v?
<FromGitter> <dscottboggs_gitlab> yes
<FromGitter> <dscottboggs_gitlab> > in a typical http request a route lookup is negligible โŽ โŽ that's a fair point, but I'm not sure that I agree that an efficiently written HTTP parser that reuses the source buffer would necessarily take less time
alexherbo2 has quit [Ping timeout: 268 seconds]
_ht has quit [Remote host closed the connection]
<FromGitter> <j8r> I have to say the router is not the bottleneck
<FromGitter> <j8r> I hard-coded the resolution
<FromGitter> <j8r> for testing purposes
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 265 seconds]
<FromGitter> <Blacksmoke16> did that help?
<FromGitter> <j8r> I end up commenting everything, and the performance is still near the same...
<FromGitter> <Blacksmoke16> ๐Ÿ˜ฎ
<FromGitter> <Blacksmoke16> hm
<FromGitter> <j8r> it improved by 10%, only
<FromGitter> <j8r> not sure what's the reason
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <j8r> ho, I forgot reuse_port - may be that?
<FromGitter> <Blacksmoke16> are you doing like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e681911a2897318a99e8cb6]
<FromGitter> <Blacksmoke16> then `sleep` at the end
<FromGitter> <j8r> Kind of yes, I missed the reuse_port ๐Ÿ˜…
<FromGitter> <Blacksmoke16> that would do it
<FromGitter> <Blacksmoke16> but would ofc result in better perf not related to what you were doing tho
<FromGitter> <Blacksmoke16> essentially would be perf of 1 core * #cores
<FromGitter> <j8r> I did no gain a lot, 10%
<FromGitter> <j8r> I may miss something...
<FromGitter> <Blacksmoke16> Hmm
ur5us has quit [Ping timeout: 256 seconds]
<FromGitter> <j8r> I'll double check, then move one because perf is good-enough
HumanG33k has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> Sounds like a plan
antoszka has quit [Ping timeout: 252 seconds]
antoszka has joined #crystal-lang
ur5us has joined #crystal-lang
renich has joined #crystal-lang