mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-10-24 06:23:06 +08:00
Memory management: - Vendor mimalloc v2.1.9 as global allocator (MI_OVERRIDE=1 in prod) - New mem.h/mem.c: RSS-based budget tracking via mi_process_info() - Remove vmem.c/vmem.h (mmap-based budget tracking) - Remove slab tier2 bump allocator (~300 LOC); >64B goes to mimalloc - Slab tier1 pages from malloc (= mimalloc) instead of vmem - Arena blocks from malloc instead of vmem - Budget raised from 35% to 50% RAM (no more untracked C++ heap) Extraction-phase prescan (eliminates disk re-reads): - HTTP call sites: keyword check + URL extraction during extraction - HTTP routes: decorator + source-based extraction during extraction - Config file refs: regex scan during extraction - httplinks: 41.8s → 13ms on Linux kernel (3,212x faster) - configlink: 41.4s → 0.8s on Linux kernel (54x faster) - Linux kernel fast-mode total: 2m38s → 1m18s Bug fixes: - __init__.py Module QN no longer collides with Folder QN - index.ts same fix for JS/TS packages - 13 regression tests for QN collision at FQN + extraction layers - search_graph/search_code default limit raised from 10 to 500k - Resolve all clang-tidy, cppcheck, and clang-format warnings Repo cleanup: - tree-sitter-form, tree-sitter-magma moved to tools/ - .gitignore: build/, node_modules/, graph-ui/dist/, TEST_PLAN.md
67 lines
3.9 KiB
C++
67 lines
3.9 KiB
C++
/* ----------------------------------------------------------------------------
|
|
Copyright (c) 2018-2020 Microsoft Research, Daan Leijen
|
|
This is free software; you can redistribute it and/or modify it under the
|
|
terms of the MIT license. A copy of the license can be found in the file
|
|
"LICENSE" at the root of this distribution.
|
|
-----------------------------------------------------------------------------*/
|
|
#pragma once
|
|
#ifndef MIMALLOC_NEW_DELETE_H
|
|
#define MIMALLOC_NEW_DELETE_H
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// This header provides convenient overrides for the new and
|
|
// delete operations in C++.
|
|
//
|
|
// This header should be included in only one source file!
|
|
//
|
|
// On Windows, or when linking dynamically with mimalloc, these
|
|
// can be more performant than the standard new-delete operations.
|
|
// See <https://en.cppreference.com/w/cpp/memory/new/operator_new>
|
|
// ---------------------------------------------------------------------------
|
|
#if defined(__cplusplus)
|
|
#include <new>
|
|
#include <mimalloc.h>
|
|
|
|
#if defined(_MSC_VER) && defined(_Ret_notnull_) && defined(_Post_writable_byte_size_)
|
|
// stay consistent with VCRT definitions
|
|
#define mi_decl_new(n) mi_decl_nodiscard mi_decl_restrict _Ret_notnull_ _Post_writable_byte_size_(n)
|
|
#define mi_decl_new_nothrow(n) mi_decl_nodiscard mi_decl_restrict _Ret_maybenull_ _Success_(return != NULL) _Post_writable_byte_size_(n)
|
|
#else
|
|
#define mi_decl_new(n) mi_decl_nodiscard mi_decl_restrict
|
|
#define mi_decl_new_nothrow(n) mi_decl_nodiscard mi_decl_restrict
|
|
#endif
|
|
|
|
void operator delete(void* p) noexcept { mi_free(p); };
|
|
void operator delete[](void* p) noexcept { mi_free(p); };
|
|
|
|
void operator delete (void* p, const std::nothrow_t&) noexcept { mi_free(p); }
|
|
void operator delete[](void* p, const std::nothrow_t&) noexcept { mi_free(p); }
|
|
|
|
mi_decl_new(n) void* operator new(std::size_t n) noexcept(false) { return mi_new(n); }
|
|
mi_decl_new(n) void* operator new[](std::size_t n) noexcept(false) { return mi_new(n); }
|
|
|
|
mi_decl_new_nothrow(n) void* operator new (std::size_t n, const std::nothrow_t& tag) noexcept { (void)(tag); return mi_new_nothrow(n); }
|
|
mi_decl_new_nothrow(n) void* operator new[](std::size_t n, const std::nothrow_t& tag) noexcept { (void)(tag); return mi_new_nothrow(n); }
|
|
|
|
#if (__cplusplus >= 201402L || _MSC_VER >= 1916)
|
|
void operator delete (void* p, std::size_t n) noexcept { mi_free_size(p,n); };
|
|
void operator delete[](void* p, std::size_t n) noexcept { mi_free_size(p,n); };
|
|
#endif
|
|
|
|
#if (__cplusplus > 201402L || defined(__cpp_aligned_new))
|
|
void operator delete (void* p, std::align_val_t al) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); }
|
|
void operator delete[](void* p, std::align_val_t al) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); }
|
|
void operator delete (void* p, std::size_t n, std::align_val_t al) noexcept { mi_free_size_aligned(p, n, static_cast<size_t>(al)); };
|
|
void operator delete[](void* p, std::size_t n, std::align_val_t al) noexcept { mi_free_size_aligned(p, n, static_cast<size_t>(al)); };
|
|
void operator delete (void* p, std::align_val_t al, const std::nothrow_t&) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); }
|
|
void operator delete[](void* p, std::align_val_t al, const std::nothrow_t&) noexcept { mi_free_aligned(p, static_cast<size_t>(al)); }
|
|
|
|
void* operator new (std::size_t n, std::align_val_t al) noexcept(false) { return mi_new_aligned(n, static_cast<size_t>(al)); }
|
|
void* operator new[](std::size_t n, std::align_val_t al) noexcept(false) { return mi_new_aligned(n, static_cast<size_t>(al)); }
|
|
void* operator new (std::size_t n, std::align_val_t al, const std::nothrow_t&) noexcept { return mi_new_aligned_nothrow(n, static_cast<size_t>(al)); }
|
|
void* operator new[](std::size_t n, std::align_val_t al, const std::nothrow_t&) noexcept { return mi_new_aligned_nothrow(n, static_cast<size_t>(al)); }
|
|
#endif
|
|
#endif
|
|
|
|
#endif // MIMALLOC_NEW_DELETE_H
|