Skip to content

Commit

Permalink
Boost 186 (#759)
Browse files Browse the repository at this point in the history
  • Loading branch information
cldellow authored Sep 20, 2024
1 parent eab08d1 commit 6509f0c
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 71 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
${{ github.workspace }}\build\RelWithDebInfo\tilemaker.exe ${{ env.AREA }}.osm.pbf --config=resources/config-openmaptiles.json --process=resources/process-openmaptiles.lua --output=${{ env.AREA }}.mbtiles --store osm_store --verbose
- name: 'Upload compiled executable'
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: tilemaker-windows
path: |
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
${{ github.workspace }}/build/${{ matrix.executable }} ${{ env.AREA }}.osm.pbf --config=resources/config-openmaptiles.json --process=resources/process-openmaptiles.lua --output=${{ env.AREA }}.mbtiles --verbose --store /tmp/store
- name: 'Upload compiled executable'
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: tilemaker-${{ matrix.os }}
path: |
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ inputs:
config:
description: 'A JSON file listing each layer, and the zoom levels at which to apply it'
required: false
default: '/resources/config-openmaptiles.json'
default: 'config.json'
process:
description: "A Lua program that looks at each node/way's tags, and places it into layers accordingly"
required: false
default: '/resources/process-openmaptiles.lua'
default: 'process.lua'
output:
description: 'Could be directory of tiles, or a .mbtiles files'
required: true
Expand Down
9 changes: 3 additions & 6 deletions include/mmap_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ class void_mmap_allocator
typedef std::size_t size_type;

static void *allocate(size_type n, const void *hint = 0);
static void deallocate(void *p, size_type n);
static void destroy(void *p);
static void shutdown();
static void reportStoreSize(std::ostringstream &str);
static void openMmapFile(const std::string& mmapFilename);
};
Expand Down Expand Up @@ -47,15 +44,15 @@ class mmap_allocator

void deallocate(pointer p, size_type n)
{
void_mmap_allocator::deallocate(p, n);
// This is a no-op. Most usage of tilemaker should never deallocate
// an mmap_allocator resource. On program termination, everything gets
// freed.
}

void construct(pointer p, const_reference val)
{
new((void *)p) T(val);
}

void destroy(pointer p) { void_mmap_allocator::destroy(p); }
};

template<typename T1, typename T2>
Expand Down
50 changes: 0 additions & 50 deletions src/mmap_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,6 @@ void mmap_shm::close()
mmap_shm_thread_region_ptr.reset();
}

bool void_mmap_allocator_shutdown = false;

void void_mmap_allocator::shutdown() { void_mmap_allocator_shutdown = true; }

void * void_mmap_allocator::allocate(size_type n, const void *hint)
{
while(true) {
Expand Down Expand Up @@ -211,52 +207,6 @@ void * void_mmap_allocator::allocate(size_type n, const void *hint)
}
}

void void_mmap_allocator::deallocate(void *p, size_type n)
{
destroy(p);
}

void void_mmap_allocator::destroy(void *p)
{
if(void_mmap_allocator_shutdown) return;

if(mmap_shm_thread_region_ptr != nullptr) {
auto &i = *mmap_shm_thread_region_ptr;
if(p >= (void const *)i.region.data() && p < reinterpret_cast<void const *>(reinterpret_cast<uint8_t const *>(i.region.data()) + i.region.size())) {
allocator_t allocator(i.buffer.get_segment_manager());
return allocator.destroy(reinterpret_cast<uint8_t *>(p));
}
}

if(mmap_file_thread_ptr != nullptr) {
auto &i = *mmap_file_thread_ptr;
if(p >= i.region.get_address() && p < reinterpret_cast<void const *>(reinterpret_cast<uint8_t const *>(i.region.get_address()) + i.region.get_size())) {
allocator_t allocator(i.buffer.get_segment_manager());
allocator.destroy(reinterpret_cast<uint8_t *>(p));
return;
}
}

std::lock_guard<std::mutex> lock(mmap_allocator_mutex);
for(auto &i: mmap_shm_regions) {
if(p >= (void const *)i->region.data() && p < reinterpret_cast<void const *>(reinterpret_cast<uint8_t const *>(i->region.data()) + i->region.size())) {
std::lock_guard<std::mutex> lock(i->mutex);
allocator_t allocator(i->buffer.get_segment_manager());
allocator.destroy(reinterpret_cast<uint8_t *>(p));
return;
}
}

for(auto &i: mmap_dir.files) {
if(p >= i->region.get_address() && p < reinterpret_cast<void const *>(reinterpret_cast<uint8_t const *>(i->region.get_address()) + i->region.get_size())) {
std::lock_guard<std::mutex> lock(i->mutex);
allocator_t allocator(i->buffer.get_segment_manager());
allocator.destroy(reinterpret_cast<uint8_t *>(p));
return;
}
}
}

void void_mmap_allocator::reportStoreSize(std::ostringstream &str) {
if (mmap_dir.mmap_file_size>0) { str << "Store size " << (mmap_dir.mmap_file_size / 1000000000) << "G | "; }
}
Expand Down
5 changes: 0 additions & 5 deletions src/sorted_node_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ SortedNodeStore::SortedNodeStore(bool compressNodes): compressNodes(compressNode

void SortedNodeStore::reopen()
{
for (const auto entry: allocatedMemory)
void_mmap_allocator::deallocate(entry.first, entry.second);
allocatedMemory.clear();

totalNodes = 0;
Expand All @@ -86,9 +84,6 @@ void SortedNodeStore::reopen()
}

SortedNodeStore::~SortedNodeStore() {
for (const auto entry: allocatedMemory)
void_mmap_allocator::deallocate(entry.first, entry.second);

s(this) = ThreadStorage();
}

Expand Down
5 changes: 0 additions & 5 deletions src/sorted_way_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,10 @@ SortedWayStore::SortedWayStore(bool compressWays, const NodeStore& nodeStore): c
}

SortedWayStore::~SortedWayStore() {
for (const auto entry: allocatedMemory)
void_mmap_allocator::deallocate(entry.first, entry.second);

s(this) = ThreadStorage();
}

void SortedWayStore::reopen() {
for (const auto entry: allocatedMemory)
void_mmap_allocator::deallocate(entry.first, entry.second);
allocatedMemory.clear();

totalWays = 0;
Expand Down
1 change: 0 additions & 1 deletion src/tilemaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,5 @@ int main(const int argc, const char* argv[]) {
#endif

cout << endl << "Filled the tileset with good things at " << sharedData.outputFile << endl;
void_mmap_allocator::shutdown(); // this clears the mmap'ed nodes/ways/relations (quickly!)
}

0 comments on commit 6509f0c

Please sign in to comment.