Jump to content

n-squared algorithm blocking startup

The Leftover

Recommended Posts

I had a huge loading performance a couple days ago.  I have gotten past it now but it seems like something you should know about.

I was trying to load a *lot* of meshes, say up to 20,000, and ran into a serious wall below that.  The time for the first render completion was over a minute.  I did the most practical thing, hit pause a few times to see what the system was doing.  My system was spending all of its time in a FOR loop in Material.prototype._markAllSubMeshesAsDirty.  (Attach 1)  getScene().meshes is all of my meshes, so this was a long FOR loop.

The plot thickens because it was a downstream side-effect of another FOR loop Scene._evaluateActiveMeshes.  This FOR loop was also the length of all of my meshes.  So, my first render was blocked by an n-squared algorithm that evaluating dirtiness.  Lots and lots of dirtiness.

I got past this with a hack, initially.  I disabled Material.prototype._markAllSubMeshesAsDirty for the *first* *render* only.  No ill effects.  Later, I started merging meshes.  Let me tell you, the mesh merging is the bomb!  It changed everything for my application.  Instances, yawn.  Clone, snore.  Merging killed it.

I do 3-d graphs and there are a lot of similar meshes (everything is a hexagon, for starters).  In my tests, I could reduce independent mesh count by a factor of twenty.  Now I am loading 150K hexes fast and with good frame rate.   :D

I archived the original problem child at http://www.brianbutton.com/chart3d/carthagevirgin.html



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...