Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/attribute_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ const AttributePair& AttributePairStore::getPairUnsafe(uint32_t i) const {
thread_local uint64_t tlsPairLookups = 0;
thread_local uint64_t tlsPairLookupsUncached = 0;

thread_local std::vector<const AttributePair*> cachedAttributePairPointers(64);
thread_local std::vector<uint32_t> cachedAttributePairIndexes(64);
thread_local std::vector<const AttributePair*> cachedAttributePairPointers(256);
thread_local std::vector<uint32_t> cachedAttributePairIndexes(256);
uint32_t AttributePairStore::addPair(AttributePair& pair, bool isHot) {
if (isHot) {
{
Expand Down Expand Up @@ -300,8 +300,8 @@ void AttributeSet::finalize() {

// Remember recently queried/added sets so that we can return them in the
// future without taking a lock.
thread_local std::vector<const AttributeSet*> cachedAttributeSetPointers(64);
thread_local std::vector<AttributeIndex> cachedAttributeSetIndexes(64);
thread_local std::vector<const AttributeSet*> cachedAttributeSetPointers(256);
thread_local std::vector<AttributeIndex> cachedAttributeSetIndexes(256);

thread_local uint64_t tlsSetLookups = 0;
thread_local uint64_t tlsSetLookupsUncached = 0;
Expand Down
22 changes: 20 additions & 2 deletions src/osm_lua_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "node_store.h"
#include "polylabel.h"
#include <signal.h>
#include <unordered_map>

using namespace std;

Expand All @@ -18,6 +19,8 @@ thread_local kaguya::State *g_luaState = nullptr;
thread_local OsmLuaProcessing* osmLuaProcessing = nullptr;

std::mutex vectorLayerMetadataMutex;
thread_local const LayerDefinition* vectorLayerMetadataCacheLayers = nullptr;
thread_local std::vector<std::unordered_map<std::string, uint>> vectorLayerMetadataCache;
std::unordered_map<std::string, std::string> OsmLuaProcessing::dataStore;
std::mutex OsmLuaProcessing::dataStoreMutex;

Expand Down Expand Up @@ -1032,8 +1035,23 @@ std::string OsmLuaProcessing::FindInRelation(const std::string &key) {

// Record attribute name/type for vector_layers table
void OsmLuaProcessing::setVectorLayerMetadata(const uint_least8_t layer, const string &key, const uint type) {
std::lock_guard<std::mutex> lock(vectorLayerMetadataMutex);
layers.layers[layer].attributeMap[key] = type;
if (vectorLayerMetadataCacheLayers != &layers) {
vectorLayerMetadataCache.clear();
vectorLayerMetadataCacheLayers = &layers;
}
if (vectorLayerMetadataCache.size() <= layer)
vectorLayerMetadataCache.resize(layer + 1);

auto &metadataCache = vectorLayerMetadataCache[layer];
const auto it = metadataCache.find(key);
if (it != metadataCache.end() && it->second == type)
return;

{
std::lock_guard<std::mutex> lock(vectorLayerMetadataMutex);
layers.layers[layer].attributeMap[key] = type;
}
metadataCache[key] = type;
}

// Scan relation (but don't write geometry)
Expand Down
Loading