From 628ca3609252f35cea119917ddbdbf7a2e71950f Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 14 Nov 2025 19:03:25 +0000 Subject: [PATCH 1/2] Optimize MemPool: simplify space checks and use bit shifts - Replace pointer arithmetic with direct used byte check in makeShared/make - Use bit shift instead of division in getBlockIdx for power-of-2 blockSize - Remove unused #include header These changes reduce unnecessary calculations and improve performance for allocation checks and address-to-block index conversions. --- include/benpm/mempool.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/benpm/mempool.hpp b/include/benpm/mempool.hpp index a229199..4f64790 100644 --- a/include/benpm/mempool.hpp +++ b/include/benpm/mempool.hpp @@ -5,7 +5,6 @@ #include #include -#include #include #include @@ -23,6 +22,7 @@ namespace benpm { class MemPool { private: // ------------------------------------------------------------ static constexpr size_t blockSize = chunkSize * chunksPerBlock; + static constexpr size_t blockSizeLog2 = __builtin_ctzl(blockSize); struct Chunk { char* head; // Next free byte in chunk @@ -107,7 +107,7 @@ namespace benpm { // Returns the block index of a memory address size_t getBlockIdx(void* ptr) const { - return (size_t)(char*)ptr / blockSize; + return (size_t)(char*)ptr >> blockSizeLog2; } // Returns true if given memory address resides in this pool @@ -149,7 +149,7 @@ namespace benpm { #ifdef MEMPOOL_THREADSAFE std::lock_guard lock(mutex); #endif - if (this->curChunk->head - (char*)this->curChunk + sizeof(T) >= chunkSize) { + if (this->curChunk->used + sizeof(T) > chunkSize) { if (this->curChunk->next == nullptr) { this->allocBlock(); } else { @@ -174,7 +174,7 @@ namespace benpm { #ifdef MEMPOOL_THREADSAFE std::lock_guard lock(mutex); #endif - if (this->curChunk->head - (char*)this->curChunk + sizeof(T) >= chunkSize) { + if (this->curChunk->used + sizeof(T) > chunkSize) { if (this->curChunk->next == nullptr) { this->allocBlock(); } else { From 78b7dc0ebcef946536208f7c2a3ab833165d0ee7 Mon Sep 17 00:00:00 2001 From: Benjamin Mastripolito Date: Wed, 3 Dec 2025 05:59:14 -0700 Subject: [PATCH 2/2] ci: add Azure Static Web Apps workflow file on-behalf-of: @Azure opensource@microsoft.com --- ...-static-web-apps-gentle-pond-00fdf210f.yml | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/azure-static-web-apps-gentle-pond-00fdf210f.yml diff --git a/.github/workflows/azure-static-web-apps-gentle-pond-00fdf210f.yml b/.github/workflows/azure-static-web-apps-gentle-pond-00fdf210f.yml new file mode 100644 index 0000000..60fec16 --- /dev/null +++ b/.github/workflows/azure-static-web-apps-gentle-pond-00fdf210f.yml @@ -0,0 +1,46 @@ +name: Azure Static Web Apps CI/CD + +on: + push: + branches: + - claude/optimize-code-01GUptwf6hYkPd2myGBcakCZ + pull_request: + types: [opened, synchronize, reopened, closed] + branches: + - claude/optimize-code-01GUptwf6hYkPd2myGBcakCZ + +jobs: + build_and_deploy_job: + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') + runs-on: ubuntu-latest + name: Build and Deploy Job + steps: + - uses: actions/checkout@v3 + with: + submodules: true + lfs: false + - name: Build And Deploy + id: builddeploy + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GENTLE_POND_00FDF210F }} + repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) + action: "upload" + ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### + # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig + app_location: "/" # App source code path + api_location: "" # Api source code path - optional + output_location: "" # Built app content directory - optional + ###### End of Repository/Build Configurations ###### + + close_pull_request_job: + if: github.event_name == 'pull_request' && github.event.action == 'closed' + runs-on: ubuntu-latest + name: Close Pull Request Job + steps: + - name: Close Pull Request + id: closepullrequest + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GENTLE_POND_00FDF210F }} + action: "close"