Skip to content

Optimise locking when storing types per key#913

Open
systemed wants to merge 1 commit into
masterfrom
metadata_speedup
Open

Optimise locking when storing types per key#913
systemed wants to merge 1 commit into
masterfrom
metadata_speedup

Conversation

@systemed
Copy link
Copy Markdown
Owner

@systemed systemed commented Jun 4, 2026

In #877 @pa5cal identified a slowdown caused by locking when we write to attributeMap for a given layer, which we use to record the types for each attribute in the vector tile (eventually written into the vector_layers JSON).

We had some discussion of fixes in the thread, and then in true "you wait three months for a bus" fashion, we also have #912 which also provides a fix. This PR takes from those to provide the simplest possible solution:

  • We keep a record of what keys per layer have already been written in thread_local storage
  • We use an unordered_set, which means we can use count to avoid the find/end threading issue
  • We aren't worried about subsequently checking the type: first one always wins

I think this should achieve the issue while keeping the code compact and readable for what is a fairly marginal feature (the vector_layers JSON isn't used by most consumers). I've done some moderate testing on this but would be happy to see further reports.

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