Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Page load increase with YUI #14

Open
iurisilvio opened this issue Apr 23, 2012 · 8 comments
Open

Page load increase with YUI #14

iurisilvio opened this issue Apr 23, 2012 · 8 comments
Assignees
Labels
Milestone

Comments

@iurisilvio
Copy link
Contributor

I'm using LuckyAssetManager in a big site. I discovered it is really slow when any YUI compressors are enabled, even after files were cached. It increases page load to something like ~4s in all requests. Disabling YUI, it delay ~.8s in first load and ~80ms after that.

I don't know if I'm doing something wrong or if it is some caching bug. Configuration difference is only YUI compressors.

This difference is in page load, not in assets request, so I guess it is generating assets all the time, ignoring cache.

If you have any insight about that, I'm grateful to you. Thanks!

@luckyllama
Copy link
Owner

I'm noticing something similar. I'll be looking into it.

@ghost ghost assigned luckyllama Apr 23, 2012
@luckyllama
Copy link
Owner

I pushed a new RC (2). In it, I'm caching the YUI results so that library isn't being called excessively.

On a small project, this seemed to cut ~.2 seconds off of page load.

On a large project, this seemed to cut ~1.8 seconds off of page load.

Good catch, I didn't notice the drain YUI was having.

@iurisilvio
Copy link
Contributor Author

Awesome! I tested your changes here and the load time (after cache) reduced to ~80ms. Now it works like I expect. It saves me almost 4s per call. =)

Thanks! I'm closing the issue.

@iurisilvio
Copy link
Contributor Author

Oops, I just tested the page load, but I saw some weird bug.

I have something like this:

<%= Assets.RenderJavascript("cufon") %>
<%= Assets.RenderJavascript("master") %>
<%= Assets.RenderJavascript() %>

It adds the same group three times (the first group):

<!-- Assets:
F:\...\localhost\js\cufon.js
F:\...\localhost\js\museu300_400.font.js
F:\...\localhost\js\museu500_500.font.js
F:\...\localhost\js\cufon_exec.js
 -->
<script src="/assets.axd?type=Javascript&key=-1632755057" type="text/javascript"></script>

(I removed my physical path from the html above)

This code repeats three times, the other two groups are not printed.

I have other two renders in the same file (in head) and they work fine. These three are in the bottom (to increase performance).

It happens only with YUICompressor enabled, probably related with these cache changes.

@luckyllama
Copy link
Owner

Okay, try RC3. The cache wasn't being specific enough with what it cached and after assets are combined, they start to look the same.

@iurisilvio
Copy link
Contributor Author

With RC3, I got this exception in one of my environments.

[NullReferenceException: Object reference not set to an instance of an object.]
   Lucky.AssetManager.Assets.AssetReaders.FileSystemAssetReader.<GetHashCode>b__1(Int32 current, String path) in F:\LuckyAssetManager\Lucky.AssetManager\Assets\AssetReaders\FileSystemAssetReader.cs:41
   System.Linq.Enumerable.Aggregate(IEnumerable`1 source, TAccumulate seed, Func`3 func) +157
   Lucky.AssetManager.Assets.AssetReaders.FileSystemAssetReader.GetHashCode() in F:\LuckyAssetManager\Lucky.AssetManager\Assets\AssetReaders\FileSystemAssetReader.cs:41
   Lucky.AssetManager.Assets.JavascriptAsset.GetHashCode() in F:\LuckyAssetManager\Lucky.AssetManager\Assets\JavascriptAsset.cs:55
   Lucky.AssetManager.Processors.YuiMinimizeProcessor.<Process>b__0(IAsset a) in F:\LuckyAssetManager\Lucky.AssetManager\Processors\YuiMinimizeProcessor.cs:24
   System.Linq.WhereSelectListIterator`2.MoveNext() +110
   System.String.Join(String separator, IEnumerable`1 values) +81
   Lucky.AssetManager.Processors.YuiMinimizeProcessor.Process(IEnumerable`1 assets) in F:\LuckyAssetManager\Lucky.AssetManager\Processors\YuiMinimizeProcessor.cs:24
   Lucky.AssetManager.AssetOutputManager.<BuildHtml>b__0(IEnumerable`1 current, IProcessor processor) in F:\LuckyAssetManager\Lucky.AssetManager\AssetOutputManager.cs:36
   System.Linq.Enumerable.Aggregate(IEnumerable`1 source, TAccumulate seed, Func`3 func) +157
   Lucky.AssetManager.AssetOutputManager.BuildHtml(IEnumerable`1 assets) in F:\LuckyAssetManager\Lucky.AssetManager\AssetOutputManager.cs:36
   Lucky.AssetManager.AssetManager.Render(AssetType assetType, String assetGroup) in F:\LuckyAssetManager\Lucky.AssetManager\AssetManager.cs:105
   Lucky.AssetManager.Web.Assets.RenderAsset(AssetType type, String assetGroup) in F:\LuckyAssetManager\Lucky.AssetManager\Web\Assets.cs:33
   Lucky.AssetManager.Web.Assets.RenderJavascript(String assetGroup) in F:\LuckyAssetManager\Lucky.AssetManager\Web\Assets.cs:29

In my machine it worked fine, but in another machine it crashed. I'm not sure what happened.

@luckyllama
Copy link
Owner

I added some defensive code around the offending methods in my latest commit (not a package this time). I'm not sure how this error could have happened however. Any additional details would be appreciated.

@iurisilvio
Copy link
Contributor Author

Your workaround worked. Thanks!

I tried to get more information about the problem, it happens because of this asset:

Assets.MasterJavascript("http://html5shim.googlecode.com/svn/trunk/html5.js", "third").ForIE(IE.Equality.LessThan, IE.Version.IE9).Add();

When I remove it, assets works fine, even without your last change. The error happens on javascript rendering group="third".

Probably it is something with remote files.

EDIT: it happens in all my environments.

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

No branches or pull requests

2 participants