From 6509f0cf50943a90b36b5c6802118b72124b1e7a Mon Sep 17 00:00:00 2001 From: Colin Dellow Date: Fri, 20 Sep 2024 12:20:48 -0400 Subject: [PATCH] Boost 186 (#759) --- .github/workflows/ci.yml | 4 ++-- action.yml | 4 ++-- include/mmap_allocator.h | 9 +++---- src/mmap_allocator.cpp | 50 --------------------------------------- src/sorted_node_store.cpp | 5 ---- src/sorted_way_store.cpp | 5 ---- src/tilemaker.cpp | 1 - 7 files changed, 7 insertions(+), 71 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 20909c42..0c8aff91 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: | @@ -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: | diff --git a/action.yml b/action.yml index 10e1dc13..eae15412 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/include/mmap_allocator.h b/include/mmap_allocator.h index 1130c80f..92be6751 100644 --- a/include/mmap_allocator.h +++ b/include/mmap_allocator.h @@ -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); }; @@ -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 diff --git a/src/mmap_allocator.cpp b/src/mmap_allocator.cpp index 2b5e26fd..42d2bf44 100644 --- a/src/mmap_allocator.cpp +++ b/src/mmap_allocator.cpp @@ -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) { @@ -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(reinterpret_cast(i.region.data()) + i.region.size())) { - allocator_t allocator(i.buffer.get_segment_manager()); - return allocator.destroy(reinterpret_cast(p)); - } - } - - if(mmap_file_thread_ptr != nullptr) { - auto &i = *mmap_file_thread_ptr; - if(p >= i.region.get_address() && p < reinterpret_cast(reinterpret_cast(i.region.get_address()) + i.region.get_size())) { - allocator_t allocator(i.buffer.get_segment_manager()); - allocator.destroy(reinterpret_cast(p)); - return; - } - } - - std::lock_guard lock(mmap_allocator_mutex); - for(auto &i: mmap_shm_regions) { - if(p >= (void const *)i->region.data() && p < reinterpret_cast(reinterpret_cast(i->region.data()) + i->region.size())) { - std::lock_guard lock(i->mutex); - allocator_t allocator(i->buffer.get_segment_manager()); - allocator.destroy(reinterpret_cast(p)); - return; - } - } - - for(auto &i: mmap_dir.files) { - if(p >= i->region.get_address() && p < reinterpret_cast(reinterpret_cast(i->region.get_address()) + i->region.get_size())) { - std::lock_guard lock(i->mutex); - allocator_t allocator(i->buffer.get_segment_manager()); - allocator.destroy(reinterpret_cast(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 | "; } } diff --git a/src/sorted_node_store.cpp b/src/sorted_node_store.cpp index 0e0c7a8a..6ea6e8af 100644 --- a/src/sorted_node_store.cpp +++ b/src/sorted_node_store.cpp @@ -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; @@ -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(); } diff --git a/src/sorted_way_store.cpp b/src/sorted_way_store.cpp index 302deab9..05785dc4 100644 --- a/src/sorted_way_store.cpp +++ b/src/sorted_way_store.cpp @@ -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; diff --git a/src/tilemaker.cpp b/src/tilemaker.cpp index c60a8fe9..8909e47c 100644 --- a/src/tilemaker.cpp +++ b/src/tilemaker.cpp @@ -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!) }