move pool reservation out of static init
parent
5385740516
commit
3ff986d90c
7
notes
7
notes
|
@ -35,13 +35,6 @@ TODO {
|
|||
about-license info
|
||||
}
|
||||
|
||||
- rework RegisterPlugin slightly to automatically give a file-scope access to the PluginInfo
|
||||
- ^ use in graph
|
||||
|
||||
- pool I guess
|
||||
|
||||
? implement dlmalloc as backend for some things
|
||||
|
||||
more ui options for laptop stuff {
|
||||
invert scrollwheel (knobs)
|
||||
maybe scroll sensitivity
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "data/graph.h"
|
||||
#include "fileops.h"
|
||||
|
||||
#include "util/mem.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <QDebug>
|
||||
|
@ -111,6 +113,8 @@ int main(int argc, char *argv[]) {
|
|||
Xybrid::Config::PluginRegistry::init();
|
||||
Xybrid::Audio::AudioEngine::init();
|
||||
|
||||
Xybrid::Util::reserveInitialPool(); // reserve arena pool ahead of time
|
||||
|
||||
bool opn = false;
|
||||
|
||||
for (auto& fn : args) {
|
||||
|
|
|
@ -6,10 +6,18 @@ std::pmr::synchronized_pool_resource Xybrid::Util::rpool; // instantiate
|
|||
decltype(Xybrid::Util::ralloc) Xybrid::Util::ralloc(&rpool);
|
||||
|
||||
namespace {
|
||||
static bool _____ = [] { // static init hackery to force pre-reservation of a certain chunk size
|
||||
const constexpr size_t rsize = 1024*1024*128;
|
||||
auto r = rpool.allocate(rsize);
|
||||
rpool.deallocate(r, rsize);
|
||||
return false;
|
||||
}();
|
||||
static bool reserved = false;
|
||||
}
|
||||
|
||||
void Xybrid::Util::reserveInitialPool() {
|
||||
if (reserved) return;
|
||||
reserved = true;
|
||||
|
||||
const constexpr size_t rsize = 1024*1024*128;
|
||||
size_t bsize = rpool.options().largest_required_pool_block;
|
||||
std::vector<void*> allocs;
|
||||
for (size_t ts = 0; ts < rsize; ts += bsize) {
|
||||
allocs.push_back(rpool.allocate(bsize));
|
||||
}
|
||||
for (auto r : allocs) rpool.deallocate(r, bsize);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ namespace Xybrid::Util {
|
|||
extern std::pmr::synchronized_pool_resource rpool;
|
||||
extern std::pmr::polymorphic_allocator<std::max_align_t> ralloc;
|
||||
|
||||
void reserveInitialPool();
|
||||
|
||||
template<typename T, size_t PSIZE = 16>
|
||||
class ResourcePool {
|
||||
typedef char slot[sizeof(T)];
|
||||
|
|
Loading…
Reference in New Issue