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

performance problems, loading speed #33

Open
emilyhobson opened this issue Jan 5, 2017 · 5 comments
Open

performance problems, loading speed #33

emilyhobson opened this issue Jan 5, 2017 · 5 comments
Assignees

Comments

@emilyhobson
Copy link

emilyhobson commented Jan 5, 2017

Current site is unacceptably slow and doesn't load on IE (required for OSE). We can address in greater depth in phase 2 but we need the pages to moderately function for phase 1.

Trouble areas:

  1. Initial load
  2. Metric panes - clicking on a pane generates a response after several seconds
  3. page freezing altogether

Thoughts around causes:

  • lots of javascript and css files, color ramps
  • large number of points (we'll need to support 100k+ ongoing)
  • lack of caching

Suggestions:
Change functionality of building comparison - since you can't see this section and the map at the same time (on a laptop), initiate load of comparison table upon scroll or button action.

@almccon
Copy link
Member

almccon commented Jan 12, 2017

Our temporary fix of removing the comparison view (9df25b7) seems to be causing the CARTO layers to stack up on each other, instead of removing and replacing the layer when you choose a different metric.

@almccon
Copy link
Member

almccon commented Jan 13, 2017

I tried making the building comparison display: none as default, but that doesn't speed up the loading. Still takes just as much time as if it were rendering the whole thing.

So we still have change it to actually delay the build of that table until the user clicks to show it. Proceeding with that plan.

@almccon almccon assigned almccon and unassigned sconnelley Jan 17, 2017
@almccon
Copy link
Member

almccon commented Jan 18, 2017

I narrowed down the slowness to this part of the code:

buildings.forEach(function(building, i){
var id = building.get(this.buildingId);
var currentMetricHash = this.lookup[id].metrichash;
if (currentMetricHash === metrichash) return;
var metrics = _.map(metricFields, function(field) {
var value = building.get(field),
color = this.gradientCalculators[field].toColor(value);
return {
value: value,
color: color,
isYear: (field == 'yearbuilt'), // TODO: don't hardcode this. Use isYear attribute instead.
undefined: (value ? 'defined' : 'undefined')
};
}, this);
this.lookup[id].metrics = metrics;
this.lookup[id].metrichash = metrichash;
}, this);

Or at least that's one cause of the slowness on initial load. Continuing that thread in issue #39. Keeping this issue open in case there are other cases to slowness to address.

@almccon
Copy link
Member

almccon commented Jan 24, 2017

Loading time is much improved, thanks @sconnelley. Looks like this commit did it: eac0925

@sconnelley
Copy link
Contributor

yes, the toColor method in BuildingColorBucketCalculator was taking ~4ms to complete. Each building calls that method, so for 3k buildings that equals a lot of time.

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

No branches or pull requests

3 participants