These are chat archives for dry-rb/chat

12th
Jan 2016
Piotr Solnica
@solnic
Jan 12 2016 10:57
       user     system      total        real
DV: 1 thread 10.610000   0.170000  10.780000 (  3.519302)
AM: 1 thread 18.670000   0.240000  18.910000 (  7.975311)
DV: 2 threads  3.280000   0.050000   3.330000 (  0.911350)
AM: 2 threads  7.950000   0.090000   8.040000 (  3.307048)
multi-threaded validation of 10k hashes on jruby O_O
Tim Riley
@timriley
Jan 12 2016 10:58
nice!
Piotr Solnica
@solnic
Jan 12 2016 10:58
3 x faster on dry-v with 1 thread vs 2 threads
and 1 thread is faster than 2 threads on MRI
...
lemme gist it
Oskar Szrajer
@gotar
Jan 12 2016 10:59
it's quite normal i guess -- java
Piotr Solnica
@solnic
Jan 12 2016 10:59
yeah it is
but I always go through a little shock every time I see this :joy:
Oskar Szrajer
@gotar
Jan 12 2016 11:00
not sure why jruby is not so popular (not as mri), load is a little longer but everything works just better after
but last time I use it on production it was just before 9000
maybe now its even better
Piotr Solnica
@solnic
Jan 12 2016 11:05
doesn’t change the fact mri runs it gazillion times faster
full gist ^
Oskar Szrajer
@gotar
Jan 12 2016 11:05
jruby with --dev flag start almost as fast as mri
did you try it?
not sure it's relevant in 9000 but helps a lot in prev one
Piotr Solnica
@solnic
Jan 12 2016 11:17
I meant that mri runs the validations faster
way faster
see the gist
Oskar Szrajer
@gotar
Jan 12 2016 11:17
hmm thats strange
Hannes Nevalainen
@kwando
Jan 12 2016 11:58
@solnic I bet @headius and @enebo would be interested in this =)
ping them on twitter or github, and they would probably figure out why it slow and fix it
Did you give jruby time to warm up?
Piotr Solnica
@solnic
Jan 12 2016 12:12
@kwando I’m not talking about start up time
and yeah I might ping headius
Hannes Nevalainen
@kwando
Jan 12 2016 12:29
startup time != warm up time
jruby have a JIT compiler which needs to run for a while
Piotr Solnica
@solnic
Jan 12 2016 12:30
right, haven’t thought about doing that
Hannes Nevalainen
@kwando
Jan 12 2016 12:30
jruby in interpreted mode is slightly slower than mri
Piotr Solnica
@solnic
Jan 12 2016 12:32
I was mostly curious to see multi-threading
not so much to compare the vms
Hunter Madison
@hmadison
Jan 12 2016 12:32
also if your using jruby check out https://github.com/jruby/jruby/wiki/Truffle
Hannes Nevalainen
@kwando
Jan 12 2016 12:32
@hmadison yeah, that is a cool project
I run the same benchmark within a 5.times{ <benchmark> } block
and only kept the last run
Piotr Solnica
@solnic
Jan 12 2016 12:46
that’s really really cool
AM: 1 thread: 0.2 i/s - 13.06x slower
:joy:
Hannes Nevalainen
@kwando
Jan 12 2016 12:51
jruby is 3x faster in the 2 thread mode and ~1.5x faster then MRI in single threaded mode
(on DV)
Andy Holland
@AMHOL
Jan 12 2016 12:58
Been a couple of talks at my local Ruby user group about jruby Truffle by Chris Seaton
Hunter Madison
@hmadison
Jan 12 2016 13:04
nice.
Hannes Nevalainen
@kwando
Jan 12 2016 14:50
Is there a way of manually inject rules to a schema?
Piotr Solnica
@solnic
Jan 12 2016 14:51
use-case?
Hannes Nevalainen
@kwando
Jan 12 2016 14:51
I'm defining rules as an AST and now I basically want to construct a schema from the compiled rules
I have a soft schema and need to generate a validator
Piotr Solnica
@solnic
Jan 12 2016 14:52
soft schema?
Hannes Nevalainen
@kwando
Jan 12 2016 14:53
bad wording, schema defined at runtime is better
Hannes Nevalainen
@kwando
Jan 12 2016 15:07
This message was deleted
Andy Holland
@AMHOL
Jan 12 2016 15:18
dynamic schema?
Piotr Solnica
@solnic
Jan 12 2016 15:21
we can generalize the implementation to make that possible
for now you can workaround it through a monkey-patch or something
Hannes Nevalainen
@kwando
Jan 12 2016 15:29
my_schema.instance_variable_set(:@rules, my_compiled_rules) did the trick :joy:
I need to wash my hands now =P
Piotr Solnica
@solnic
Jan 12 2016 15:34
yes please
:joy:
Hannes Nevalainen
@kwando
Jan 12 2016 15:36
this is going to be lovely :heart:
Peter Leitzen
@splattael
Jan 12 2016 15:42
@solnic which jruby version did you use for the threaded benchmarks?
Piotr Solnica
@solnic
Jan 12 2016 15:43
@kwando how come you need a dynamic validator?
@splattael jruby 9.0.0.0 (2.2.2) 2015-07-21 e10ec96 Java HotSpot(TM) 64-Bit Server VM 25.0-b70 on 1.8.0-b132 +jit [darwin-x86_64]
Hannes Nevalainen
@kwando
Jan 12 2016 15:47
we store user defined entities in a document store, the schema for those entities is defined in our own schema-format and stored in a database. atm we have a homegrown validator that validates a given document with its corresponding schema.
Piotr Solnica
@solnic
Jan 12 2016 15:47
sounds lovely
nice use case
Peter Leitzen
@splattael
Jan 12 2016 15:48
@solnic thanks, will test :D
Hannes Nevalainen
@kwando
Jan 12 2016 15:50
so instead of building on our own validator we can just translate our schema to dry-v rule AST and then yeah, you get the point
Piotr Solnica
@solnic
Jan 12 2016 15:52
fantastic, another sweet use cases for ast
Peter Leitzen
@splattael
Jan 12 2016 16:41
@solnic can I remove these DRY_ST_RESULT and friends? we know that it works like expected ;)
@solnic it's easier to do a benchmark warmup then... which changes the results for jruby drastically
Piotr Solnica
@solnic
Jan 12 2016 16:42
sure
Peter Leitzen
@splattael
Jan 12 2016 16:45
Rehearsal -------------------------------------------------
DV: 1 thread   10.560000   0.090000  10.650000 (  2.824798)
AM: 1 thread   23.530000   0.140000  23.670000 ( 10.074928)
DV: 2 threads   3.970000   0.000000   3.970000 (  0.950222)
AM: 2 threads   8.030000   0.000000   8.030000 (  3.928952)
--------------------------------------- total: 46.320000sec

                    user     system      total        real
DV: 1 thread    1.760000   0.010000   1.770000 (  1.268773)
AM: 1 thread    7.270000   0.010000   7.280000 (  7.221729)
DV: 2 threads   1.320000   0.000000   1.320000 (  0.639469)
AM: 2 threads   7.570000   0.000000   7.570000 (  3.734775)
jruby 9.0.0.0 (2.2.2) 2015-07-21 e10ec96 Java HotSpot(TM) 64-Bit Server VM 25.60-b23 on 1.8.0_60-b27 +jit [linux-amd64]
Peter Leitzen
@splattael
Jan 12 2016 16:51

jruby 1.7.23 seems to be faster than 9k...

jruby 1.7.23 (2.0.0p598) 2015-11-24 f496dd5 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_60-b27 +jit [linux-amd64]

 Rehearsal -------------------------------------------------
DV: 1 thread    9.320000   0.050000   9.370000 (  2.252000)
AM: 1 thread   16.950000   0.070000  17.020000 (  6.885000)
DV: 2 threads   2.860000   0.000000   2.860000 (  0.758000)
AM: 2 threads   6.910000   0.010000   6.920000 (  3.031000)
--------------------------------------- total: 36.170000sec

                    user     system      total        real
DV: 1 thread    1.370000   0.000000   1.370000 (  0.957000)
AM: 1 thread    5.190000   0.000000   5.190000 (  5.062000)
DV: 2 threads   1.010000   0.010000   1.020000 (  0.467000)
AM: 2 threads   5.470000   0.010000   5.480000 (  2.667000)
Peter Leitzen
@splattael
Jan 12 2016 16:58

Dry::Validation::ErrorCompiler#visit* seems to be the hotspots (zoom out):

https://rawgit.com/splattael/f9f05cc49565e414c79c/raw/08b7f52c352c312840ab679de81c5e9f294a3eec/profile.svg

Piotr Solnica
@solnic
Jan 12 2016 16:58
yup, not surprised
Peter Leitzen
@splattael
Jan 12 2016 17:02
AM hotspot is I18n, right?
Piotr Solnica
@solnic
Jan 12 2016 17:04
yes
Peter Leitzen
@splattael
Jan 12 2016 17:05
I have to run :running: cu :D
Kris Leech
@krisleech
Jan 12 2016 19:14
I'm really enjoying all the dry-* stuff. So thanks to all involved. Currently trying out dry-compontent.
Piotr Solnica
@solnic
Jan 12 2016 19:19
@krisleech thanks, that's so nice to know :)
Tim Riley
@timriley
Jan 12 2016 21:54
Interesting task for the morning: try and merge 2 ASTs :grimacing:
Piotr Solnica
@solnic
Jan 12 2016 21:54
Deep water mate!
Tim Riley
@timriley
Jan 12 2016 21:54
(dry-v’s rules AST, which I’ve compiled down to something a little more simplified, and Formalist’s existing form AST)
haha
I want to place the dry-v rules on their respective form fields
Piotr Solnica
@solnic
Jan 12 2016 21:55
This is exciting stuff
Tim Riley
@timriley
Jan 12 2016 22:19
@solnic putting a bin/console inside your gem’s repo is a great idea. I’m copying it from rom-rb/rom-repository#14 :)
Hunter Madison
@hmadison
Jan 12 2016 22:31
afaik bundler does it by default for the bundle gem command.
Piotr Solnica
@solnic
Jan 12 2016 22:47
It does although it is a pretty old idea that was before bundler
Tim Riley
@timriley
Jan 12 2016 22:52
Ah, cool.
I think we might end up hitting naming conflicts with dry-auto_inject as used within our rodakase apps. @solnic, would you be open to having this somehow work with kwargs or something so we could Main::Import(local_name: “different.container.name”) ?
Piotr Solnica
@solnic
Jan 12 2016 22:53
Oh yeah it is on my list. It has been on my list for a long time actually
Tim Riley
@timriley
Jan 12 2016 22:54
yeah, I thought it might’ve been something you’d thought of
given it seemed like an obvious next step
Piotr Solnica
@solnic
Jan 12 2016 22:54
I want to extend auto inject and make it use dry-constructor (not released yet)
Tim Riley
@timriley
Jan 12 2016 22:54
ah, nice.
I think we’ve found a way to avoid this name collision in our particular case right now, anyway :)