Closed doits closed 11 years ago
Not enough details / 120ms is not that slow depending on the number of assets.
If you need performance for production env, you should build assets or use a cdn.
We're having performance issues too when the html is rendered. I think I've tracked it down to a performance problem with Sinatra::AssetPack::Options#glob.
I used MethodProfiler to get the following information when the application was running in the production
environment using rackup -E production
. Note this running on Windows.
Tracing from Sinatra::AssetPack::Package#paths_and_files ends up in Sinatra::AssetPack::Options#glob
MethodProfiler results for: Sinatra::AssetPack::Package
+---------------------+------------+-------------+--------------+-------------+-------------+
| Method | Min Time | Max Time | Average Time | Total Time | Total Calls |
+---------------------+------------+-------------+--------------+-------------+-------------+
| #to_production_html | 643.064 ms | 2077.208 ms | 1247.375 ms | 4989.499 ms | 4 |
| #production_path | 641.064 ms | 2076.208 ms | 1246.374 ms | 4985.498 ms | 4 |
| #files | 640.064 ms | 2071.207 ms | 1243.624 ms | 4974.497 ms | 4 |
| #paths_and_files | 640.064 ms | 2071.207 ms | 1243.624 ms | 4974.497 ms | 4 |
| #link_tag | 0.000 ms | 1.000 ms | 0.500 ms | 2.000 ms | 4 |
| #add_path_prefix | 0.000 ms | 0.000 ms | 0.000 ms | 0.000 ms | 4 |
| #css? | 0.000 ms | 0.000 ms | 0.000 ms | 0.000 ms | 2 |
| #js? | 0.000 ms | 0.000 ms | 0.000 ms | 0.000 ms | 4 |
+---------------------+------------+-------------+--------------+-------------+-------------+
MethodProfiler results for: Sinatra::AssetPack::Options
+-----------------+------------+-------------+--------------+-------------+-------------+
| Method | Min Time | Max Time | Average Time | Total Time | Total Calls |
+-----------------+------------+-------------+--------------+-------------+-------------+
| #glob | 640.064 ms | 2070.207 ms | 1243.374 ms | 4973.497 ms | 4 |
| #files | 303.030 ms | 396.039 ms | 331.433 ms | 4971.497 ms | 15 |
| #ignored? | 0.000 ms | 1.000 ms | 0.067 ms | 1.000 ms | 15 |
| #to_uri | 0.000 ms | 20.002 ms | 0.018 ms | 719.071 ms | 39780 |
| #packages | 0.000 ms | 0.000 ms | 0.000 ms | 0.000 ms | 4 |
| #served | 0.000 ms | 0.000 ms | 0.000 ms | 0.000 ms | 4 |
| #app | 0.000 ms | 0.000 ms | 0.000 ms | 0.000 ms | 8 |
| #local_file_for | 0.000 ms | 0.000 ms | 0.000 ms | 0.000 ms | 4 |
| #asset_hosts | 0.000 ms | 0.000 ms | 0.000 ms | 0.000 ms | 8 |
+-----------------+------------+-------------+--------------+-------------+-------------+
MethodProfiler results for: Sinatra::AssetPack::BusterHelpers
+--------------------+----------+----------+--------------+------------+-------------+
| Method | Min Time | Max Time | Average Time | Total Time | Total Calls |
+--------------------+----------+----------+--------------+------------+-------------+
| #cache_buster_hash | 0.000 ms | 5.001 ms | 1.250 ms | 10.001 ms | 8 |
| #add_cache_buster | 0.000 ms | 5.001 ms | 1.250 ms | 10.001 ms | 8 |
+--------------------+----------+----------+--------------+------------+-------------+
i have the following asset configured:
To render the following haml, it takes about 280ms:
Removing the
js :global
, it cuts down the time to about 80ms:It does not matter if I am in production mode or test mode.
Reducing the number of assets help, about 120ms with this:
So I assume looking up the files is causing it to slow down. Any chance to make this faster or at least have it in production mode fast?