faster_path 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +43 -2
- data/ext/faster_path/extconf.rb +2 -2
- data/lib/faster_path/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a936694d9f749570e5cc36ef77d191463d76012
|
4
|
+
data.tar.gz: 48b762449beb96a05a019079b3b72a8cdd82a53a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e01d2a339da0a848c696410dd975e84063dc4c5e59b8ef910c6e1f7657e949cdf3ae32770cba6ba801d4c54908bb9beb35e242e0ca1a5d7be619baaa227a20e2
|
7
|
+
data.tar.gz: f3cbba7d7249fce672035d7964d913d393c5ef090a0915ad083f7c7ac6d5218ae1f952d3a502c34def28135388142612d52857f27af2b5548e9a834e8732b5c9
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# FasterPath
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/faster_path.svg)](https://badge.fury.io/rb/faster_path)
|
3
3
|
[![Build Status](https://travis-ci.org/danielpclark/faster_path.svg?branch=master)](https://travis-ci.org/danielpclark/faster_path)
|
4
|
-
[![Tweet This](https://raw.githubusercontent.com/danielpclark/faster_path/master/assets/tweet.png)](https://twitter.com/share?url=https%3A%2F%2Fgithub.com%2Fdanielpclark%2Ffaster_path&via=6ftdan&hashtags=Ruby&text=You%20could%20save%2015%25%20or%20more%20on%20website%20load%20time%20by%20switching%20to%20the%20FasterPath%20gem.)
|
4
|
+
[![Tweet This](https://raw.githubusercontent.com/danielpclark/faster_path/master/assets/tweet.png)](https://twitter.com/share?url=https%3A%2F%2Fgithub.com%2Fdanielpclark%2Ffaster_path&via=6ftdan&hashtags=Ruby&text=You%20could%20save%2015%25%20or%20more%20on%20website%20page%20load%20time%20by%20switching%20to%20the%20FasterPath%20gem.)
|
5
5
|
|
6
6
|
#### This gem shaves off more than 30% of my Rails application page load time.
|
7
7
|
|
@@ -16,7 +16,7 @@ be a sledge hammer ;-)
|
|
16
16
|
|
17
17
|
## Why
|
18
18
|
|
19
|
-
I did a check on Rails on what methods were being called the most and where the application
|
19
|
+
I read a blog post about the new Sprockets 3.0 series being faster than the 2.0 series so I tried it out. It was not faster but rather it made my website take 31.8% longer to load. So I reverted back to the 2.0 series and I did a check on Rails on what methods were being called the most and where the application spends
|
20
20
|
most of its time. It turns out roughly 80% _(as far as I can tell)_ of the time spent and calls made
|
21
21
|
are file Path handling. This is shocking, but it only gets worse when handling assets. **That is
|
22
22
|
why we need to deal with these load heavy methods in the most efficient manner!**
|
@@ -48,6 +48,45 @@ Running `stackprof tmp/2016-06-09T00:42:10-04:00-stackprof-cpu-myapp.dump`. Exec
|
|
48
48
|
108 (1.5%) 14 (0.2%) ActionView::Helpers::AssetUrlHelper#asset_path
|
49
49
|
```
|
50
50
|
|
51
|
+
Here are some addtional stats. From Rails loading to my home page, these methods are called _(not directly, Rails & gems call them)_ this many times. And the home page has minimal content.
|
52
|
+
```ruby
|
53
|
+
Pathname#to_s called 29172 times.
|
54
|
+
Pathname#<=> called 24963 times.
|
55
|
+
Pathname#chop_basename called 24456 times
|
56
|
+
Pathname#initialize called 23103 times.
|
57
|
+
File#initialize called 23102 times.
|
58
|
+
Pathname#absolute? called 4840 times.
|
59
|
+
Pathname#+ called 4606 times.
|
60
|
+
Pathname#plus called 4606 times.
|
61
|
+
Pathname#join called 4600 times.
|
62
|
+
Pathname#extname called 4291 times.
|
63
|
+
Pathname#hash called 4207 times.
|
64
|
+
Pathname#to_path called 2706 times.
|
65
|
+
Pathname#directory? called 2396 times.
|
66
|
+
Pathname#entries called 966 times.
|
67
|
+
Dir#each called 966 times.
|
68
|
+
Pathname#basename called 424 times.
|
69
|
+
Pathname#prepend_prefix called 392 times.
|
70
|
+
Pathname#cleanpath called 392 times.
|
71
|
+
Pathname#cleanpath_aggressive called 392 times.
|
72
|
+
Pathname#split called 161 times.
|
73
|
+
Pathname#open called 153 times.
|
74
|
+
Pathname#exist? called 152 times.
|
75
|
+
Pathname#sub called 142 times.
|
76
|
+
```
|
77
|
+
|
78
|
+
After digging further I've found that Pathname is heavily used in Sprockets 2 but in Sprockets 3 they switched to calling Ruby's faster methods from `File#initialize` and `Dir#each`. It appears they've written all of the path handling on top of these themselves in Ruby. They achieved some performance gain by switching to rawer code methods, but then they lost more than that in performance by the **many** method calls built on top of that.
|
79
|
+
|
80
|
+
If you want to see the best results in Rails with this gem you will likely need to be using the Sprockets 2.0 series. Otherwise this library would need to rewrite Sprockets itself.
|
81
|
+
|
82
|
+
I've said this about Sprockets but this required two other gems to be updated as well. These are the gems and versions I upgraded and consider group 1 (Sprockets 2) and group 2 (Sprockets 3). My data is based on method calls rather than source code.
|
83
|
+
|
84
|
+
|Sprockets 2 Group|Sprockets 3 Group|
|
85
|
+
|:---:|:---:|
|
86
|
+
|sprockets 2.12.4|sprockets 3.6|
|
87
|
+
|sass 3.2.19|sass 5.0.4|
|
88
|
+
|bootstrap-sass 3.3.4.1|bootstrap-sass 3.3.6|
|
89
|
+
|
51
90
|
## Status
|
52
91
|
|
53
92
|
* Rust compilation is working
|
@@ -77,6 +116,8 @@ And then execute:
|
|
77
116
|
Or install it yourself as:
|
78
117
|
|
79
118
|
$ gem install faster_path
|
119
|
+
|
120
|
+
**MAC USERS:** At the moment Mac users need to install the extension manualy. Go to the gem directory and run `cargo build --release` . There is an issue opened for this and I'm looking for people who have Macs to help on this.
|
80
121
|
|
81
122
|
## Usage
|
82
123
|
|
data/ext/faster_path/extconf.rb
CHANGED
@@ -12,8 +12,8 @@ unless find_executable('cargo')
|
|
12
12
|
end
|
13
13
|
|
14
14
|
Dir.chdir(File.expand_path("../../", File.dirname(__FILE__))) do
|
15
|
-
|
16
|
-
|
15
|
+
%x(rake build_src)
|
16
|
+
%x(rake clean_src)
|
17
17
|
end
|
18
18
|
|
19
19
|
create_makefile('faster_path/dummy')
|
data/lib/faster_path/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faster_path
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel P. Clark
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
163
|
version: '0'
|
164
164
|
requirements: []
|
165
165
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.
|
166
|
+
rubygems_version: 2.5.1
|
167
167
|
signing_key:
|
168
168
|
specification_version: 4
|
169
169
|
summary: Reimplementation of Pathname for better performance
|