mirror of
https://github.com/matrix-construct/construct
synced 2024-11-25 16:22:35 +01:00
ircd::db: Optimize away one of the row ctor's vector heap allocations.
This commit is contained in:
parent
e03d36aa48
commit
cbbfbcac72
1 changed files with 16 additions and 10 deletions
26
ircd/db.cc
26
ircd/db.cc
|
@ -7720,19 +7720,25 @@ ircd::db::row::row(database &d,
|
|||
return &d[name];
|
||||
});
|
||||
|
||||
//TODO: allocator
|
||||
std::vector<ColumnFamilyHandle *> handles(column_count);
|
||||
std::transform(colptr, colptr + column_count, begin(handles), []
|
||||
(database::column *const &ptr)
|
||||
{
|
||||
return ptr->handle.get();
|
||||
});
|
||||
|
||||
//TODO: does this block?
|
||||
std::vector<Iterator *> iterators;
|
||||
{
|
||||
const ctx::uninterruptible ui;
|
||||
// The goal here is to optimize away the heap allocation incurred by
|
||||
// having to pass RocksDB the specific std::vector type which doesn't
|
||||
// have room for an allocator. We use a single thread_local vector
|
||||
// and reserve() it with one worst-case size of all possible columns.
|
||||
// Then we resize it to this specific call's requirements and copy the
|
||||
// column pointers. On sane platforms only one allocation ever occurs.
|
||||
const ctx::critical_assertion ca;
|
||||
thread_local std::vector<ColumnFamilyHandle *> handles;
|
||||
assert(column_count <= d.columns.size());
|
||||
handles.reserve(d.columns.size());
|
||||
handles.resize(column_count);
|
||||
std::transform(colptr, colptr + column_count, begin(handles), []
|
||||
(database::column *const &ptr)
|
||||
{
|
||||
return ptr->handle.get();
|
||||
});
|
||||
|
||||
throw_on_error
|
||||
{
|
||||
d.d->NewIterators(options, handles, &iterators)
|
||||
|
|
Loading…
Reference in a new issue