move pool reservation out of static init
parent
5385740516
commit
3ff986d90c
7
notes
7
notes
|
@ -35,13 +35,6 @@ TODO {
|
||||||
about-license info
|
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 {
|
more ui options for laptop stuff {
|
||||||
invert scrollwheel (knobs)
|
invert scrollwheel (knobs)
|
||||||
maybe scroll sensitivity
|
maybe scroll sensitivity
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include "data/graph.h"
|
#include "data/graph.h"
|
||||||
#include "fileops.h"
|
#include "fileops.h"
|
||||||
|
|
||||||
|
#include "util/mem.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -111,6 +113,8 @@ int main(int argc, char *argv[]) {
|
||||||
Xybrid::Config::PluginRegistry::init();
|
Xybrid::Config::PluginRegistry::init();
|
||||||
Xybrid::Audio::AudioEngine::init();
|
Xybrid::Audio::AudioEngine::init();
|
||||||
|
|
||||||
|
Xybrid::Util::reserveInitialPool(); // reserve arena pool ahead of time
|
||||||
|
|
||||||
bool opn = false;
|
bool opn = false;
|
||||||
|
|
||||||
for (auto& fn : args) {
|
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);
|
decltype(Xybrid::Util::ralloc) Xybrid::Util::ralloc(&rpool);
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
static bool _____ = [] { // static init hackery to force pre-reservation of a certain chunk size
|
static bool reserved = false;
|
||||||
const constexpr size_t rsize = 1024*1024*128;
|
}
|
||||||
auto r = rpool.allocate(rsize);
|
|
||||||
rpool.deallocate(r, rsize);
|
void Xybrid::Util::reserveInitialPool() {
|
||||||
return false;
|
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::synchronized_pool_resource rpool;
|
||||||
extern std::pmr::polymorphic_allocator<std::max_align_t> ralloc;
|
extern std::pmr::polymorphic_allocator<std::max_align_t> ralloc;
|
||||||
|
|
||||||
|
void reserveInitialPool();
|
||||||
|
|
||||||
template<typename T, size_t PSIZE = 16>
|
template<typename T, size_t PSIZE = 16>
|
||||||
class ResourcePool {
|
class ResourcePool {
|
||||||
typedef char slot[sizeof(T)];
|
typedef char slot[sizeof(T)];
|
||||||
|
|
Loading…
Reference in New Issue