Skip to content

Avoid redundant work when writing features - #931

Closed
geoneutrino wants to merge 1 commit into
systemed:masterfrom
geoneutrino:perf/avoid-redundant-work-when-writing-tiles
Closed

geoneutrino wants to merge 1 commit into
systemed:masterfrom
geoneutrino:perf/avoid-redundant-work-when-writing-tiles

Conversation

@geoneutrino

Copy link
Copy Markdown
Contributor

small performance improvement

Two pre-existing redundancies in the tile write path, neither of which changes what is written:

  • writeMultiLinestring() called scaleLatpLon() twice for every point, once to count the distinct points and once to emit them. Scale each point once into a reused buffer instead.
  • The multipoint vector was allocated per point feature. Reuse a thread_local buffer, as scaledMultiPolygon already does.

Verified byte-identical to the parent commit on a Bangladesh extract (93930 tiles, 25544140 features). The comparison has to run with --threads 1: with several threads tilemaker's own output varies by a feature or two between runs of the same binary, because addObjectToSmallIndex() falls back to a per-thread pending list under lock contention.

Two pre-existing redundancies in the tile write path, neither of which
changes what is written:

- writeMultiLinestring() called scaleLatpLon() twice for every point,
  once to count the distinct points and once to emit them. Scale each
  point once into a reused buffer instead.
- The multipoint vector was allocated per point feature. Reuse a
  thread_local buffer, as scaledMultiPolygon already does.

Verified byte-identical to the parent commit on a Bangladesh extract
(93930 tiles, 25544140 features). The comparison has to run with
--threads 1: with several threads tilemaker's own output varies by a
feature or two between runs of the same binary, because
addObjectToSmallIndex() falls back to a per-thread pending list under
lock contention.
@geoneutrino

Copy link
Copy Markdown
Contributor Author

Closing: after #939 the remaining two changes no longer make a measurable difference (tested on single-threaded extract: master vs. this branch). The validity-check part was superseded by #939 itself.

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.

1 participant