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

[WIP] Allow throwing error on max vtile size + logging large tiles #92

Merged
merged 8 commits into from
Sep 14, 2017

Conversation

springmeyer
Copy link
Contributor

@springmeyer springmeyer commented Aug 30, 2017

Adds the ability to:

  • set, via environment variable, the max vtile size allowed, in bytes.
  • log, via environment variable, tiles that are over a given size

Downstream consumers can opt into either of these options.

In the case of the max size error, the buffer is still passed in the callback. This allows downstream consumers to decide on the logic they want to use when this happens.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 94.141% when pulling 90aec8d on max-vtile-size into c0d85f2 on master.

@springmeyer springmeyer changed the title [WIP] Allow throwing error on max vtile size [WIP] Allow throwing error on max vtile size + logging large tiles Aug 30, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 93.846% when pulling bea737d on max-vtile-size into c0d85f2 on master.

@springmeyer springmeyer requested a review from mapsam September 11, 2017 23:29
stats.max = pbfz.length;
}
}
if (source.BRIDGE_MAX_VTILE_BYTES_COMPRESSED > 0 && pbfz.length > source.BRIDGE_MAX_VTILE_BYTES_COMPRESSED) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@springmeyer do we want to error here right away? Perhaps we can comment this out for now until we are ready to return an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mapsam - totally okay to comment, however this is harmless currently because it is a different environment variable. Note BRIDGE_MAX_VTILE_BYTES_COMPRESSED vs BRIDGE_LOG_MAX_VTILE_BYTES_COMPRESSED

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I didn't notice that. Thanks for pointing it out - keeping it here works for me!

index.js Outdated

process.on('exit',function() {
stats.avg = stats.total/stats.count;
fs.writeFileSync('tilelive-bridge-stats.json',JSON.stringify(stats,null,1));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirming the location this will write to - it be where the function was executed from, rather than within this module, correct? @springmeyer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, not going to write into the module path. That will currently log to the current working directory. So the directory of the user running mapbox-tile-copy.

index.js Outdated
@@ -8,10 +8,21 @@ var immediate = global.setImmediate || process.nextTick;
var mapnik_pool = require('mapnik-pool');
var Pool = mapnik_pool.Pool;
var os = require('os');
var bytes = require('bytes');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we aren't using this any longer @springmeyer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please feel free to remove.

@mapsam
Copy link
Contributor

mapsam commented Sep 12, 2017

Just left a few comments @springmeyer! Not sure why some of the tests are failing, perhaps just a blip?

@springmeyer
Copy link
Contributor Author

Not sure why some of the tests are failing, perhaps just a blip?

Looks like the rendering benchmarks are failing - either a blip or a legit slowdown. 🤔

@springmeyer
Copy link
Contributor Author

Looks like the rendering benchmarks are failing - either a blip or a legit slowdown.

I can't pick up a meaningful difference in speeds locally with and without this branch, so it may be on travis's end. Running benchmarks on travis is dubious.

@springmeyer
Copy link
Contributor Author

so it may be on travis's end. Running benchmarks on travis is dubious.

It is, looks like these have been failing in master for some time: https://travis-ci.org/mapbox/tilelive-bridge/jobs/242849687#L1344

@mapsam
Copy link
Contributor

mapsam commented Sep 12, 2017

@springmeyer happy to let them continue to fail here or remove assertions on benchmarks from tests. Your call!

@springmeyer
Copy link
Contributor Author

@mapsam I'd like to let them fail here. Have ticketed fixing at #93

@mapsam
Copy link
Contributor

mapsam commented Sep 13, 2017

@springmeyer myself and @GretaCB were working with this and noticed by using process.on('exit'.. globally in the module means that any module requiring this will perform the action. This meant non-omnivore/bridge files via mapbox-tile-copy were creating the stats object with zeros. We've added an extra conditional to only create the stats object if count > 0 which will only happen within tilelive-bridge.

@springmeyer
Copy link
Contributor Author

👍 @mapsam @GretaCB

@mapsam
Copy link
Contributor

mapsam commented Sep 14, 2017

@springmeyer @GretaCB I just updated the README to reflect the environment variable changes. Will plan on merging this in and releasing as 2.5.0.

@mapsam mapsam merged commit 2f589b2 into master Sep 14, 2017
@mapsam mapsam deleted the max-vtile-size branch September 14, 2017 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants