Optimization idea: avoid serialize and compress if we've shaved nothing
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 44
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
Per @springmeyer 's thoughts:
A potential optimization to look into would be:
- Track if we don't ever shave any data off a tile
- In that case, return early without serializing the newly created tile
The early return would save the call to `finalvt.serialize` and to compression (if compression is requested). The largest performance gain would likely come from skipping compression (if it is requested) since we've learned from profiling in api-maps[citation needed] that compression of large tiles can be more expensive than the vtile encoding of layers+features.
So, we'd be able to skip these calls in the case that we've not actually been able to shave any data https://github.com/mapbox/vtshaver/blob/809ba394821fc243bba308be0ed079d4c5743147/src/shave.cpp#L405-L410. In this case we could return nothing for the resultant buffer as an indication that the caller should simply re-use the data passed into the shaver for that tile.
I'm basing this optimization idea on the assumption that, while potentially uncommon or rare, it is possible (and frequent enough to matter for large scale performance) that you might have a vector tileset with some tiles which get a lot shaved off and some tiles that get nothing shaved off.
Before ever moving on this feature however we should do some research to figure out of this "did not shave anything" scenario actually happens in reality and if it does whether it happens with data the is large enough to have measurable cost to `serialize` and `compress`. If these things don't happen then this optimization would likely have no benefit.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at src/shave.cpp around lines 405-410 and inspect how tile data reaches serialization and compression. First determine whether tiles commonly have no data shaved and whether those tiles are large enough for skipping serialize or compression to matter. Done means the scenario and performance impact are measured well enough to decide whether this optimization is worthwhile.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100