Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.x super #507

Closed
wants to merge 19 commits into from
Closed

3.x super #507

wants to merge 19 commits into from

Conversation

janbiedermann
Copy link

@janbiedermann janbiedermann commented Oct 14, 2017

for #504
also see #503

you have to set:

Sprockets.check_modified_root = Rails.root.join('app')

3.x
tests:
Finished in 29.491941s, 27.0582 runs/s, 116.6081 assertions/s.
798 runs, 3439 assertions, 0 failures, 0 errors, 2 skips

first
o_jit:   0.520000   0.080000   0.600000 (  0.598037)
o_jit:   3.860000   0.570000   4.430000 (  4.425943)
second:
o_jit:   0.400000   0.020000   0.420000 (  0.422710)
o_jit:   2.510000   0.090000   2.600000 (  2.602424)
recompile first:
o_jit:   0.420000   0.020000   0.440000 (  0.440247)
o_jit:  10.140000   2.850000  12.990000 ( 13.115074)
recompile second:
o_jit:   0.400000   0.020000   0.420000 (  0.419903)
o_jit:   9.200000   2.840000  12.040000 ( 12.052266)

combined asset:
o_jit_c_first:   4.970000   0.790000   5.760000 (  5.802336)
o_jit_c_second:   3.220000   0.110000   3.330000 (  3.345740)
o_jit_c_recomp_first:  12.120000   3.290000  15.410000 ( 15.490749)
o_jit_c_recomp_second: o_jit:  11.320000   3.300000  14.620000 ( 14.694551)

assets.debug = true:
o_jit_c_second: 9.060000   2.820000  11.880000 ( 11.878011)
o_jit_c_recomp_second: 12.600000   3.830000  16.430000 ( 16.469606)

assets:precompile: real	2m55.506s
3.x super
first page load:
o_jit:   0.220000   0.060000   0.280000 (  0.287661)
o_jit:   1.520000   0.510000   2.030000 (  2.062707)
second page load:
o_jit:   0.110000   0.000000   0.110000 (  0.112850)
o_jit:   0.580000   0.020000   0.600000 (  0.599017)
recompile first:
o_jit:   0.110000   0.010000   0.120000 (  0.113966)
o_jit:   6.400000   1.590000   7.990000 (  8.013996)
recompile second:
o_jit:   0.110000   0.010000   0.120000 (  0.116643)
o_jit:   3.490000   0.710000   4.200000 (  4.204570)

combined asset:
o_jit_c_first:  1.970000   0.640000   2.610000 (  2.620856)
o_jit_c_second:   0.740000   0.040000   0.780000 (  0.774238)
o_jit_c_recomp_first:  7.400000   1.820000   9.220000 (  9.213632)
o_jit_c_recomp_second:   4.350000   0.860000   5.210000 (  5.236790)

assets.debug = true:
o_jit_c_second: 3.150000   0.610000   3.760000 (  3.781371)
o_jit_c_recomp_second:  5.750000   1.280000   7.030000 (  7.023071)

assets:precompile: real	2m44.417s

with cache adjustment:

assets.debug = true:
o_jit_c_second:  1.080000   0.020000   1.100000 (  1.102717), ~10x fasta
o_jit_c_recomp_second:   1.980000   0.040000   2.020000 (  2.040249), ~8x fasta

gorilla patches

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rafaelfranca (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@@ -153,6 +153,12 @@ def parse_accept_options(mime_type, types)
end

def path_matches(load_path, logical_name, logical_basename)
@@gorilla_djungle_banana_cache ||= {}
app_root = Sprockets.check_modified_root
is_in_app = load_path[0...app_root.size] == app_root

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might make sense to stringify app_root here. That config option can be nil.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, that method call is used in several places. Might make sense to always return a string from it instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_in_app = load_path.start_with?(app_root.to_s)

@@ -84,6 +84,39 @@ def detect_digest_class(bytes)
}
private_constant :ADD_VALUE_TO_DIGEST

def a_v_t_d(c, v, d)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't significantly faster, only 10% on ruby 2.4 and even slower on older versions

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, interesting, it makes the digest completely disappear from my callgraph,
what os, cpu are did you try on?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, if 10% is not significant ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10% improvement looks nice, but if this call takes for instance only 5% of the entire compilation process, than it's only a microoptimization without any significant effect.

I was wondering how fast this digest optimization is, so I tested it on our pipeline (big project) and here're my numbers (spent time in this method, same hw)
ruby 2.4.2 windows 29,4% faster
ruby 2.4.2 linux 17,1% faster
ruby 2.1.9 windows 8,6% slower
ruby 2.1.9 linux 17.6% faster
jruby 9.1.13.0 windows 10,3% slower
jruby 9.1.13.0 linux 11,1% slower

I didn't have time to dig deeper. In my opinion your implementation should be faster, but optimizations are sometimes tricky :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the numbers, terrific :)
With the compilation time going down 10 times, the digest became very well visible in the call graph, therefore i looked at it, because that small improvement became more significant with overall times going down that much.

ruby 2.1.* is obsolete since spring 2017

jruby only supports rails 4, which is, except for severe security issues, out of support too
And if a case is slower on jruby, and if this project really wants to support jruby, this may be a good case for opening a 'performance: case' ticket over at jruby. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally I optimized this using refinements, it's even faster than what we ended up with in MRI. But it made it way slower on jruby.

If you're going to do microbenchmarks, please use benchmark-ips as in

Last time we looked at this the hash method was faster than the case method. A big improvement was added when we started using compare with identity https://github.com/rails/sprockets/pull/439/files.

@janbiedermann
Copy link
Author

i close this, i created a opal-webpack-loader instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants