16#include <unordered_map>
27 template <
class Compose>
static auto make_merge(std::shared_ptr<native_type const> older,
28 std::shared_ptr<native_type const> newer, Compose compose) {
29 return std::make_unique<merge_type<Compose>>(std::move(older), std::move(newer), std::move(compose));
33 template <
class Node>
static auto make_index(std::shared_ptr<native_type const>
native,
34 typename Node::pair_type
main = {}, std::shared_ptr<native_type const>
secondary = {}) {
35 return std::make_unique<index_type<Node>>(std::move(
native), std::move(
main), std::move(
secondary));
44 for (
auto const & record : records) writer.
append(record);
49 template <
class P,
class Storage = profile_runtime_storage<P>>
struct redundant_node {
54 using pair_type = std::shared_ptr<redundant_node const>;
60 if (!value)
throw std::invalid_argument(
"null redundant built head");
64 if (!head) error_detail::raise<std::invalid_argument>(
"null redundant mapped head");
65 std::vector<std::shared_ptr<typename Storage::mapped_pair_type const>> chain;
66 std::unordered_set<typename Storage::mapped_pair_type const *> seen;
67 for (
auto p = head; p; p = p->main_target()) {
68 if (!seen.insert(p.get()).second) error_detail::raise<std::invalid_argument>(
"cyclic redundant main chain");
72 for (
auto i = chain.rbegin(); i != chain.rend(); ++i) result =
pair_type(
new redundant_node(*i, std::move(result)));
79 if (!value || !
native ||
native->mapped() != value->native_object() ||
80 bool(
main) !=
bool(value->main_target()) || (
main &&
main->mapped() != value->main_target()) ||
82 error_detail::raise<std::invalid_argument>(
"inexact mapped redundant parts");
92 std::shared_ptr<built_type const>
built() const noexcept {
return built_; }
93 std::shared_ptr<typename Storage::mapped_pair_type const>
mapped() const noexcept {
return mapped_; }
104 if (!binding || !binding->mapped || !
native || binding->mapped->identity() != binding->identity ||
105 native->size() != binding->mapped->native_object()->size() ||
106 bool(
main) !=
bool(binding->mapped->main_target()) ||
bool(
secondary) !=
bool(binding->mapped->secondary_target()))
107 throw std::invalid_argument(
"inexact sealed redundant parts");
108 auto result = std::shared_ptr<redundant_node>(
new redundant_node(binding->mapped,
110 result->bindings_.get_or_create(binding->catalog, root, [&] { return binding; });
117 std::shared_ptr<built_type const>
built_;
118 std::shared_ptr<typename Storage::mapped_pair_type const>
mapped_;
135 template <
class P,
class Storage = profile_runtime_storage<P>>
struct redundant_object;
153 template <
class P,
class Storage = profile_runtime_storage<P>>
struct redundant_slot {
155 std::shared_ptr<redundant_object<P, Storage>
const>
object;
173 template <
class P,
class Storage = profile_runtime_storage<P>>
struct redundant_level {
174 std::array<redundant_slot<P, Storage>, 3>
slots{};
175 std::optional<redundant_job_recipe<P, Storage>>
job;
182 std::vector<redundant_level<P, Storage>>
levels;
202 std::span<object_pointer const>
runs() const && = delete;
212 auto reject = [](
bool value,
char const * why) {
if (!value) error_detail::raise<std::invalid_argument>(why); };
215 std::unordered_map<std::uint64_t, object_pointer> objects;
217 reject(!route.secondary ||
bool(route.main),
"secondary without main");
218 if (route.main) reject(route.main->level == level &&
bool(route.main->pair) &&
bool(route.main->native),
"invalid main level/role");
219 if (route.secondary) reject(route.secondary->level == level && route.secondary->secondary() &&
bool(route.secondary->native),
"invalid secondary level/role");
222 reject(
bool(pair),
"missing redundant pair");
225 auto view = pair->view();
226 auto count = route.secondary ? route.secondary->native->size() : 0;
227 reject(view.borrowed(0).size() == (route.main ? route.main->pair->group_count() : 0) &&
228 view.borrowed(1).size() == count / P::group_size + (count % P::group_size != 0),
"redundant target cardinality");
230 std::uint64_t unsafe = 0;
231 for (
unsigned i = 0; i != height; ++i) {
234 for (
unsigned position = 0; position != 3; ++position) {
235 auto const & slot = level.slots[position];
237 reject(level.job && level.job->carrier_slot == position,
"orphan building carrier");
243 target(slot.route, i + 1);
245 auto const &
object = slot.object;
246 reject(object->identity && object->identity <
frontier.
next_identity && object->level == i &&
bool(object->native) &&
247 objects.emplace(object->identity,
object).second,
"invalid/repeated redundant object");
248 reject(object->last >= object->first && object->last <=
frontier.
admissions,
"invalid redundant interval");
250 reject(!i && object->first == 0 && object->last == 0 && !object->native->size() &&
bool(object->pair),
"invalid root carrier");
251 else reject(object->mass() == (std::uint64_t{1} << i) && object->native->size() <= object->mass(),
"invalid redundant object mass");
252 target(object->next, i + 1);
253 if (object->pair) { reject(object->pair->native_owner() == object->native,
"inexact redundant native owner"); pair_targets(object->pair, object->next); }
254 else reject(!object->next.main && !object->next.secondary,
"recursive redundant secondary");
256 switch (slot.state) {
258 reject(!slot.object && !slot.route.main && !slot.route.secondary && !slot.carrier && !slot.ever_visible,
"nonempty vacant slot");
break;
260 reject(
bool(slot.object) && !slot.route.main && !slot.route.secondary && !slot.carrier,
"invalid occupied slot");
break;
262 reject(!slot.object && !slot.route.main && !slot.route.secondary && !slot.carrier,
"invalid building carrier");
break;
264 reject(!slot.object &&
bool(slot.route.main),
"invalid ready carrier");
265 pair_targets(slot.carrier, slot.route); reject(!slot.carrier->native_owner()->size(),
"carrier has natives");
break;
267 reject(
bool(slot.object) && !slot.carrier,
"invalid root carrier slot");
268 pair_targets(slot.object->pair, slot.route);
break;
270 default: reject(
false,
"unknown redundant slot state");
273 reject(
active <= 2 && carriers <= 1 && staging <= 1,
"invalid redundant slot populations");
274 if (
active == 2 || level.job) unsafe |= std::uint64_t{1} << i;
276 auto const & job = *level.job;
277 reject(i + 1 < height && job.inputs[0] < 3 && job.inputs[1] < 3 && job.inputs[0] != job.inputs[1] &&
278 job.destination < 3 && job.carrier_slot < 3,
"invalid redundant job slots");
279 auto const & a = level.slots[job.inputs[0]], & b = level.slots[job.inputs[1]];
283 target(job.destination_route, i + 2);
284 reject(job.new_main ? !job.existing_main : (job.existing_main && job.existing_main->level == i + 1 && bool(job.existing_main->pair)),
"invalid destination main");
285 auto const & destination =
frontier.
levels[i + 1].slots[job.destination];
286 reject(destination.route.main == job.destination_route.main && destination.route.secondary == job.destination_route.secondary,
287 "inexact destination reservation route");
289 reject(!destination.object,
"premature reserved output");
291 reject(job.merged && job.merged->size() <= b.object->last - a.object->first,
"invalid merged native");
295 reject(job.output && job.output ==
frontier.
levels[i + 1].slots[job.destination].object &&
296 job.output->native == job.merged && job.output->first == a.object->first && job.output->last == b.object->last &&
297 job.output->secondary() != job.new_main,
"invalid destination artifact");
300 pair_targets(job.carrier, route); reject(!job.carrier->native_owner()->size(),
"nonempty lookahead carrier");
305 reject(!(unsafe & (unsafe << 1)),
"adjacent unsafe checkpoint levels");
310 auto owned = [&](
object_pointer const & value) {
if (value) reject(objects.contains(value->identity) && objects.at(value->identity) == value,
"dependency escaped redundant slots"); };
311 for (
auto const & [
id, value] : objects) { (void)
id; owned(value->next.main); owned(value->next.secondary); }
313 for (
auto const & slot : level.slots) { owned(slot.route.main); owned(slot.route.secondary); }
314 if (level.job) {
auto const & job = *level.job; owned(job.existing_main); owned(job.output); owned(job.destination_route.main); owned(job.destination_route.secondary); }
322 while (p !=
frontier.
root.
main->pair) { reject(p && !p->native_owner()->size() && !p->secondary_target(),
"checkpoint root differs from frontier"); p = p->main_target(); }
325 reject(!p->native_owner()->size() && !p->secondary_target(),
"checkpoint root differs from frontier"); p = p->main_target();
327 reject(p && !p->native_owner()->size(),
"missing two-root entry carrier");
330 std::vector<object_pointer>
runs; std::unordered_set<std::uint64_t> visible;
331 auto walk = [&](
auto && self,
object_pointer const & value) ->
void {
333 reject(visible.insert(value->identity).second,
"repeated visible checkpoint object");
334 self(self, value->next.main); self(self, value->next.secondary);
335 if (value->mass())
runs.push_back(value);
338 std::uint64_t next = 0;
339 for (
auto const & run :
runs) { reject(run->first == next,
"checkpoint chronology gap"); next = run->last; }
341 for (
auto const & level :
frontier.
levels)
for (
auto const & slot : level.slots)
342 if (slot.object && visible.contains(slot.object->identity)) reject(slot.ever_visible,
"visible object lacks visibility history");
350 std::vector<object_pointer>
runs;
362 template <
class P,
class Compose = replace_native_value,
class Storage = profile_runtime_storage<P>>
struct redundant_runtime {
376 static_assert(P::group_size <= (std::numeric_limits<std::uint64_t>::max() - 2240) / 32,
"redundant policy charge is not representable");
380 std::bit_width(admissions) + 2);
385 return from_snapshot(std::move(source), Storage{}, std::move(compose));
404 catch (...) { e.poison();
throw; }
407 bool pending() const noexcept {
return e_ && (
e_->unsafe ||
e_->checkpoint_pending); }
414 std::uint64_t
admission_cost()
const {
auto const & e =
active(); e.require_ready();
return e.admission_price(); }
420 std::uint64_t depth_limit)
421 requires requires (Storage &
storage) {
storage.sorted_native(records); } {
423 auto count =
static_cast<std::uint64_t
>(records.size());
424 if (!e.initializable() || count < 2 || !std::has_single_bit(count))
return false;
425 auto height =
static_cast<unsigned>(std::bit_width(count) - 1);
427 for (std::size_t i = 0; i != records.size(); ++i) {
429 if (i && compare_bits<typename P::architecture>(records[i - 1].key.
view(), records[i].key.view()) >= 0)
430 error_detail::raise<std::invalid_argument>(
"initial records must be strictly sorted");
432 auto prior = e.published;
433 try { e.initialize_sorted(records, allowance, depth_limit); }
434 catch (...) { e.published = std::move(prior); e.poison();
throw; }
439 if (!budget || !
pending())
return e.published;
440 try { e.grant(budget); e.service_due -= std::min(e.service_due, budget); e.serve(); }
441 catch (...) { e.poison();
throw; }
446 if (!e.ready())
return std::nullopt;
448 auto prior = e.published;
449 try { e.admit(record);
if (budget) { e.grant(budget); e.service_due -= std::min(e.service_due, budget); e.serve(); } }
450 catch (...) { e.published = std::move(prior); e.poison();
throw; }
456 if (!e.ready())
advance(allowance);
457 if (!e.ready()) error_detail::raise<std::logic_error>(
"redundant admission needs additional recovery service");
462 static std::uint64_t
ceil(std::uint64_t n, std::uint64_t d) {
return n / d + (n % d != 0); }
463 static void require(
bool value,
char const * message) {
if (!value) error_detail::raise<std::logic_error>(message); }
466 if ((key.size() & (P::bits_per_unit - 1)) || (value.size() & (P::bits_per_unit - 1)) ||
467 (P::value_width && value.size() / P::bits_per_unit != *P::value_width))
468 error_detail::raise<std::invalid_argument>(
"invalid encoded redundant contribution");
470 using merge_compose = std::conditional_t<std::is_same_v<Compose, replace_native_value>, Compose, std::reference_wrapper<Compose>>;
486 std::array<level_type, maximum_levels>
levels{};
497 if constexpr (
requires { {
storage.poison() }
noexcept; })
storage.poison();
503 return snapshot_type(std::make_shared<typename snapshot_type::state const>(
typename snapshot_type::state{
504 std::move(f), query_type::adopt_prepared(std::move(pair)), {}}));
511 require(!f.levels.empty() && f.levels.size() <=
maximum_levels,
"invalid redundant checkpoint height");
513 for (
unsigned i = 0; i !=
height; ++i) {
516 workers[i] = std::make_unique<worker>();
517 auto stage =
levels[i].job->stage;
537 for (
unsigned s = 0; s != 3; ++s)
if (
levels[i].slots[s].state == state)
return s;
553 for (
auto const & slot :
levels[0].slots)
555 slot.route.secondary || slot.carrier || slot.ever_visible)
return false;
559 auto flag = std::uint64_t{1} << i;
568 add(
ceil(a, P::codec_block_size),
ceil(b, P::codec_block_size)));
572 std::uint64_t result = 0;
576 }
while (
main > P::group_size);
583 auto h =
static_cast<unsigned>(std::bit_width(count) - 1);
584 std::uint64_t result = 0,
main = 0;
585 for (
unsigned i =
static_cast<unsigned>(h); i--;) {
586 auto size = std::uint64_t{1} << i;
593 result =
add(result,
add(8 * h + 16, 64 * (h + 1) + 64));
597 return add(result, 2 * (8 * (h + 1) + 16));
605 next.*field =
add(next.*field, amount);
work = next;
610 std::uint64_t depth_limit) {
612 auto count =
static_cast<std::uint64_t
>(records.size());
613 height =
static_cast<unsigned>(std::bit_width(count) - 1);
615 auto spend = [&](std::uint64_t amount,
category kind) {
616 require(
credit >= amount,
"initial construction exhausted its allowance");
620 std::uint64_t first = 0;
622 auto build_native = [&](std::uint64_t size) {
624 auto native =
storage.sorted_native(records.subspan(
static_cast<std::size_t
>(first),
static_cast<std::size_t
>(size)));
629 for (
unsigned i =
height; i--;) {
630 auto size = std::uint64_t{1} << i;
631 auto native = build_native(size);
634 auto last =
add(first, size);
635 auto value =
object(std::move(
native), std::move(pair), next, i, first, last);
637 first = last; next = {std::move(value), {}};
644 require(
unsafe == 1,
"initial frontier has more than one unsafe level");
648 require(
query.head()->depth() <= depth_limit,
"initial root exceeds depth limit");
655 "initial carry chain exhausted its allowance");
656 require(
query.head()->depth() <= depth_limit,
"initialized root exceeds depth limit");
660 return std::make_shared<object_type const>(
object_type{id, first, last, level, std::move(
native), std::move(pair), std::move(next)});
663 auto builder =
storage.template make_index<node_type>(std::move(
native),
676 }
while (
main->virtual_size() > P::group_size);
682 visit(value->next.main, fn);
visit(value->next.secondary, fn);
685 std::array<unsigned char, maximum_levels> visible{};
687 require(value->level <
height,
"visible redundant level out of range");
688 auto & level =
levels[value->level];
bool found =
false;
689 for (
unsigned s = 0; s != 3; ++s)
if (level.slots[s].object == value) {
690 require(!(visible[value->level] & (1u << s)),
"repeated visible redundant object");
691 visible[value->level] |=
static_cast<unsigned char>(1u << s);
692 level.slots[s].ever_visible =
true; found =
true;
694 require(found,
"visible redundant object escaped slots");
695 if (level.last_destination == value->identity) level.last_destination_visible =
true;
698 for (
unsigned i = 0; i !=
height; ++i)
for (
unsigned s = 0; s != 3; ++s) {
699 auto & slot =
levels[i].slots[s];
703 query = query_type::adopt_prepared(std::move(prepared));
changed =
true;
709 std::vector<object_pointer> runs;
710 auto walk = [&](
auto && self,
object_pointer const & value) ->
void {
712 self(self, value->next.main); self(self, value->next.secondary);
713 if (value->mass()) runs.push_back(value);
716 std::uint64_t next = 0;
717 for (
auto const & value : runs) {
require(value->first == next,
"redundant history gap or overlap"); next = value->last; }
719 auto state = std::make_shared<typename snapshot_type::state const>(
typename snapshot_type::state{std::move(f),
query, std::move(runs)});
738 if (entries.count) pos =
vacant(0);
741 if (c) route =
levels[0].slots[pos].route;
753 auto const & r = *
levels[i].job;
755 return r.new_main ?
routes{r.output, {}} :
routes{r.existing_main, r.output};
761 if (!
levels[i].job)
return 8;
762 auto const & r = *
levels[i].job;
auto const & w = *
workers[i];
777 error_detail::raise<std::logic_error>(
"invalid redundant worker action");
783 auto stage =
levels[i].job->stage;
788 auto input =
active(i);
require(input.count == 2,
"redundant merge needs two active inputs");
791 require(!(
unsafe & (std::uint64_t{1} << (i + 1))),
"adjacent unsafe redundant levels");
792 auto & destination =
levels[i + 1];
793 require(!destination.last_destination || destination.last_destination_visible,
"destination reused before visibility");
796 auto present =
active(i + 1);
require(present.count <= 1 && (!
carrier || !present.count),
"invalid destination occupancy");
797 auto older =
levels[i].slots[input.positions[0]].object, newer =
levels[i].slots[input.positions[1]].object;
798 auto mass = std::uint64_t{1} << i;
799 require(older->last == newer->first && older->mass() == mass && newer->mass() == mass,
"nonadjacent redundant merge history");
805 recipe.
existing_main = destination.slots[present.positions[0]].object;
808 auto worker = std::make_unique<typename redundant_runtime::worker>();
816 r.merged = std::move(
native);
819 auto older =
levels[i].slots[r.inputs[0]].object;
820 auto newer =
levels[i].slots[r.inputs[1]].object;
821 r.output =
object(r.merged, {}, {}, i + 1, older->first, newer->last);
822 levels[i + 1].slots[r.destination].object = r.output;
830 auto source = [&](
unsigned which) {
return levels[i].slots[r.inputs[which]].object; };
833 if constexpr (
requires {
storage.template reuse_merge<merge_compose>(source(0)->
native, source(1)->
native); }) {
834 if (
auto result =
storage.template reuse_merge<merge_compose>(source(0)->
native, source(1)->
native)) {
842 auto done = w.merge->step(1);
848 auto result =
storage.finish_merge(*w.merge); w.merge.reset();
865 r.output =
object(r.merged, std::move(pair), r.destination_route, i + 1, source(0)->first, source(1)->last);
866 levels[i + 1].slots[r.destination].object = r.output;
876 auto recipe = r;
auto charge = w.charged;
auto mass = std::uint64_t{1} << i;
880 auto target = recipe.new_main ?
routes{recipe.output, {}} :
routes{recipe.existing_main, recipe.output};
882 auto & destination =
levels[i + 1];
884 destination.last_destination = recipe.output->identity; destination.last_destination_visible =
false;
888 auto value =
object(
empty, recipe.carrier, target, 0, 0, 0);
898 auto amount =
price();
899 if (
credit < amount)
break;
911 std::unique_ptr<execution>
e_;
913 execution const &
active()
const {
if (!
e_) error_detail::raise<std::logic_error>(
"moved-from redundant runtime");
return *
e_; }
Executes charged encoded COLA carries behind immutable queryable snapshots.
std::uint64_t add(std::uint64_t a, std::uint64_t b)
Definition profile.h:39
std::uint64_t multiply(std::uint64_t a, std::uint64_t b)
Definition profile.h:44
Definition active_engine.h:18
redundant_slot_state
Definition redundant_runtime.h:151
redundant_stage
Definition redundant_runtime.h:152
encoded_sections< P > encode_native_sections(profile_array< P, stream_role::native > const &native)
Definition sections.h:405
bit_view view() const &
Definition profile.h:178
Definition catalog_bindings.h:25
Definition cola_index.h:496
auto finish()
Definition cola_index.h:581
Definition cola_index.h:114
std::uint64_t virtual_size() const noexcept
Definition cola_index.h:144
std::uint64_t group_count() const noexcept
Definition cola_index.h:145
Definition cola_index.h:315
static cola_query_root adopt_prepared(pair_type source)
Definition cola_query.h:47
pair_type head() const noexcept
Definition cola_query.h:63
cola_query_cursor< P, Blob > cursor(bit_view query) const
Definition cola_query.h:64
Definition cola_runtime.h:31
static std::shared_ptr< cola_runtime_native const > from_owned(profile_array< P > value)
Definition cola_runtime.h:33
Definition mapped_cola.h:33
Definition sections.h:442
Definition native_merge.h:174
Definition runtime_seal.h:36
Definition profile.h:1168
Definition native_writer.h:158
void append(bit_view key, bit_view value, std::optional< std::uint64_t > retained_limit_bits={})
Definition native_writer.h:181
profile_array< P > finish()
Definition native_writer.h:208
bit_string key
Definition profile.h:295
bit_string value
Definition profile.h:296
Definition redundant_runtime.h:21
static auto singleton(profile_record const &record)
Definition redundant_runtime.h:39
static auto finish_index(index_type< Node > &index)
Definition redundant_runtime.h:37
static auto finish_merge(Merge &merge)
Definition redundant_runtime.h:31
static auto sorted_native(std::span< profile_record const > records)
Definition redundant_runtime.h:42
static auto make_merge(std::shared_ptr< native_type const > older, std::shared_ptr< native_type const > newer, Compose compose)
Definition redundant_runtime.h:27
static auto empty()
Definition redundant_runtime.h:38
static auto make_index(std::shared_ptr< native_type const > native, typename Node::pair_type main={}, std::shared_ptr< native_type const > secondary={})
Definition redundant_runtime.h:33
static auto encode_native(profile_array< P > const &value)
Definition redundant_runtime.h:25
Definition redundant_runtime.h:179
redundant_routes< P, Storage > root
Definition redundant_runtime.h:181
std::uint64_t next_identity
Definition redundant_runtime.h:180
std::uint64_t admissions
Definition redundant_runtime.h:180
std::uint64_t service_due
Definition redundant_runtime.h:180
std::vector< redundant_level< P, Storage > > levels
Definition redundant_runtime.h:182
Definition redundant_runtime.h:163
std::shared_ptr< redundant_object< P, Storage > const > existing_main
Definition redundant_runtime.h:168
redundant_routes< P, Storage > destination_route
Definition redundant_runtime.h:167
redundant_stage stage
Definition redundant_runtime.h:171
redundant_node< P, Storage >::native_pointer merged
Definition redundant_runtime.h:169
unsigned destination
Definition redundant_runtime.h:165
std::array< unsigned, 2 > inputs
Definition redundant_runtime.h:164
bool new_main
Definition redundant_runtime.h:166
redundant_node< P, Storage >::pair_type carrier
Definition redundant_runtime.h:170
unsigned carrier_slot
Definition redundant_runtime.h:165
std::shared_ptr< redundant_object< P, Storage > const > output
Definition redundant_runtime.h:168
Definition redundant_runtime.h:173
std::array< redundant_slot< P, Storage >, 3 > slots
Definition redundant_runtime.h:174
std::optional< redundant_job_recipe< P, Storage > > job
Definition redundant_runtime.h:175
bool last_destination_visible
Definition redundant_runtime.h:177
std::uint64_t last_destination
Definition redundant_runtime.h:176
Definition redundant_runtime.h:49
built_type::view_type view() const
Definition redundant_runtime.h:85
catalog_bindings< pair_binding< typename Storage::mapped_pair_type > > bindings_
Definition redundant_runtime.h:113
bool canonical_mapped() const noexcept
Definition redundant_runtime.h:94
std::uint64_t virtual_size() const
Definition redundant_runtime.h:89
static pair_type from_built(built_type value)
Definition redundant_runtime.h:56
std::shared_ptr< typename Storage::mapped_pair_type const > mapped() const noexcept
Definition redundant_runtime.h:93
static pair_type from_mapped_parts(std::shared_ptr< typename Storage::mapped_pair_type const > value, native_pointer native, pair_type main={}, native_pointer secondary={})
Definition redundant_runtime.h:77
std::shared_ptr< typename Storage::mapped_pair_type const > mapped_
Definition redundant_runtime.h:118
std::shared_ptr< redundant_node const > pair_type
Definition redundant_runtime.h:54
std::uint64_t group_count() const
Definition redundant_runtime.h:90
Storage storage_type
Definition redundant_runtime.h:51
static pair_type from_mapped(std::shared_ptr< typename Storage::mapped_pair_type const > head)
Definition redundant_runtime.h:63
pair_type main_target() const noexcept
Definition redundant_runtime.h:88
std::shared_ptr< built_type const > built() const noexcept
Definition redundant_runtime.h:92
std::uint64_t depth() const noexcept
Definition redundant_runtime.h:91
redundant_node(std::shared_ptr< typename Storage::mapped_pair_type const > value, native_pointer native, pair_type main, native_pointer secondary)
Definition redundant_runtime.h:124
redundant_node(std::shared_ptr< built_type const > value)
Definition redundant_runtime.h:121
bool canonical_mapped_
Definition redundant_runtime.h:120
std::shared_ptr< built_type const > built_
Definition redundant_runtime.h:117
native_pointer secondary_target() const noexcept
Definition redundant_runtime.h:87
static pair_type from_sealed_parts(std::shared_ptr< pair_binding< typename Storage::mapped_pair_type > const > binding, std::filesystem::path const &root, native_pointer native, pair_type main, native_pointer secondary)
Definition redundant_runtime.h:102
std::uint64_t depth_
Definition redundant_runtime.h:119
native_pointer native_owner() const noexcept
Definition redundant_runtime.h:86
native_pointer native_
Definition redundant_runtime.h:115
native_pointer secondary_
Definition redundant_runtime.h:115
catalog_bindings< redundant_node > mapped_owners_
Definition redundant_runtime.h:114
pair_type main_
Definition redundant_runtime.h:116
std::shared_ptr< native_type const > native_pointer
Definition redundant_runtime.h:53
static pair_type from_built(std::shared_ptr< built_type const > value)
Definition redundant_runtime.h:59
typename Storage::native_type native_type
Definition redundant_runtime.h:52
redundant_node(std::shared_ptr< typename Storage::mapped_pair_type const > value, pair_type main)
Definition redundant_runtime.h:128
P policy_type
Definition redundant_runtime.h:50
Definition redundant_runtime.h:139
native_pointer native
Definition redundant_runtime.h:144
std::uint64_t last
Definition redundant_runtime.h:142
redundant_routes< P, Storage > next
Definition redundant_runtime.h:146
unsigned level
Definition redundant_runtime.h:143
typename redundant_node< P, Storage >::pair_type pair_type
Definition redundant_runtime.h:141
std::uint64_t first
Definition redundant_runtime.h:142
std::uint64_t identity
Definition redundant_runtime.h:142
bool secondary() const noexcept
Definition redundant_runtime.h:147
std::uint64_t mass() const noexcept
Definition redundant_runtime.h:148
pair_type pair
Definition redundant_runtime.h:145
std::uint64_t augmented() const
Definition redundant_runtime.h:149
typename redundant_node< P, Storage >::native_pointer native_pointer
Definition redundant_runtime.h:140
Definition redundant_runtime.h:136
std::shared_ptr< redundant_object< P, Storage > const > main
Definition redundant_runtime.h:137
std::shared_ptr< redundant_object< P, Storage > const > secondary
Definition redundant_runtime.h:137
Definition redundant_runtime.h:526
unsigned count
Definition redundant_runtime.h:526
std::array< unsigned, 2 > positions
Definition redundant_runtime.h:526
Definition redundant_runtime.h:481
std::uint64_t admissions
Definition redundant_runtime.h:489
void perform(unsigned i)
Definition redundant_runtime.h:827
static std::uint64_t root_price(std::uint64_t main, std::uint64_t secondary)
Definition redundant_runtime.h:570
active_slots active(unsigned i) const
Definition redundant_runtime.h:527
std::uint64_t checkpoint_price() const
Definition redundant_runtime.h:599
void direct(std::uint64_t amount, category kind)
Definition redundant_runtime.h:607
snapshot_type published
Definition redundant_runtime.h:492
unsigned vacant(unsigned i) const
Definition redundant_runtime.h:540
static std::uint64_t initialization_price(std::uint64_t count)
Definition redundant_runtime.h:582
static std::uint64_t index_price(std::uint64_t native, std::uint64_t main, std::uint64_t secondary)
Definition redundant_runtime.h:564
static snapshot_type initial(pair_type pair)
Definition redundant_runtime.h:501
native_pointer make_empty()
Definition redundant_runtime.h:499
std::uint64_t visibility_price() const
Definition redundant_runtime.h:600
bool recovery
Definition redundant_runtime.h:494
void refresh(unsigned i)
Definition redundant_runtime.h:558
std::uint64_t price() const
Definition redundant_runtime.h:757
std::array< level_type, maximum_levels > levels
Definition redundant_runtime.h:486
routes root
Definition redundant_runtime.h:490
std::uint64_t admission_price() const
Definition redundant_runtime.h:724
std::optional< unsigned > find(unsigned i, redundant_slot_state state) const
Definition redundant_runtime.h:536
native_pointer empty
Definition redundant_runtime.h:484
static std::uint64_t initial_native_price(std::uint64_t count)
Definition redundant_runtime.h:579
std::uint64_t credit
Definition redundant_runtime.h:489
execution(snapshot_type source, Storage context, Compose value)
Definition redundant_runtime.h:508
merge_compose merger()
Definition redundant_runtime.h:562
void grant(std::uint64_t amount)
Definition redundant_runtime.h:608
std::array< std::unique_ptr< worker >, maximum_levels > workers
Definition redundant_runtime.h:487
bool initializable() const noexcept
Definition redundant_runtime.h:548
redundant_work work
Definition redundant_runtime.h:493
pair_type build_index(native_pointer native, routes target)
Definition redundant_runtime.h:662
void checkpoint()
Definition redundant_runtime.h:705
query_type query
Definition redundant_runtime.h:491
static std::uint64_t augmented(object_pointer const &object)
Definition redundant_runtime.h:563
void begin(unsigned i)
Definition redundant_runtime.h:787
unsigned selected() const
Definition redundant_runtime.h:751
static pair_type make_empty_pair(native_pointer native)
Definition redundant_runtime.h:500
unsigned height
Definition redundant_runtime.h:488
object_pointer object(native_pointer native, pair_type pair, routes next, unsigned level, std::uint64_t first, std::uint64_t last)
Definition redundant_runtime.h:658
void poison() noexcept
Definition redundant_runtime.h:495
std::uint64_t next_identity
Definition redundant_runtime.h:489
std::uint64_t unsafe
Definition redundant_runtime.h:489
void visibility()
Definition redundant_runtime.h:684
void admit(profile_record const &record)
Definition redundant_runtime.h:733
void serve()
Definition redundant_runtime.h:896
static void visit(object_pointer const &value, F &fn)
Definition redundant_runtime.h:679
routes index_targets(unsigned i) const
Definition redundant_runtime.h:752
bool checkpoint_pending
Definition redundant_runtime.h:494
Storage storage
Definition redundant_runtime.h:482
bool ready() const noexcept
Definition redundant_runtime.h:541
std::uint64_t service_due
Definition redundant_runtime.h:489
pair_type empty_pair
Definition redundant_runtime.h:485
pair_type prepare_root(pair_type main, native_pointer secondary={})
Definition redundant_runtime.h:668
category charge_kind(unsigned i) const
Definition redundant_runtime.h:779
execution(Storage context, Compose value)
Definition redundant_runtime.h:506
void tally(std::uint64_t amount, category kind)
Definition redundant_runtime.h:601
bool changed
Definition redundant_runtime.h:494
void initialize_sorted(std::span< profile_record const > records, std::uint64_t allowance, std::uint64_t depth_limit)
Definition redundant_runtime.h:609
void complete_native(unsigned i, native_pointer native)
Definition redundant_runtime.h:814
Compose compose
Definition redundant_runtime.h:483
bool failed
Definition redundant_runtime.h:494
void require_ready() const
Definition redundant_runtime.h:547
Definition redundant_runtime.h:475
std::uint64_t charged
Definition redundant_runtime.h:479
std::unique_ptr< index_type > index
Definition redundant_runtime.h:478
action next
Definition redundant_runtime.h:476
std::unique_ptr< merge_type > merge
Definition redundant_runtime.h:477
Definition redundant_runtime.h:918
typename Storage::native_type native_type
Definition redundant_runtime.h:929
Storage storage_type
Definition redundant_runtime.h:920
P policy_type
Definition redundant_runtime.h:919
Definition redundant_runtime.h:362
bool try_initialize_sorted(std::span< profile_record const > records, std::uint64_t allowance, std::uint64_t depth_limit)
Definition redundant_runtime.h:419
bool admission_ready() const noexcept
Definition redundant_runtime.h:410
static redundant_runtime from_snapshot(snapshot_type source, Storage storage, Compose compose={})
Definition redundant_runtime.h:387
redundant_work work() const
Definition redundant_runtime.h:397
snapshot_type advance(std::uint64_t budget)
Definition redundant_runtime.h:437
bool pending() const noexcept
Definition redundant_runtime.h:407
Storage const & storage() const &
Definition redundant_runtime.h:390
typename Storage::template merge_type< merge_compose > merge_type
Definition redundant_runtime.h:471
redundant_runtime(std::unique_ptr< execution > value)
Definition redundant_runtime.h:912
static redundant_runtime from_snapshot(snapshot_type source, Compose compose={})
Definition redundant_runtime.h:384
category
Definition redundant_runtime.h:474
void poison() noexcept
Definition redundant_runtime.h:409
execution & writable()
Definition redundant_runtime.h:914
snapshot_type contribute(profile_record const &record)
Definition redundant_runtime.h:453
std::uint64_t service_due() const
Definition redundant_runtime.h:398
std::optional< snapshot_type > try_contribute(profile_record const &record, std::uint64_t budget=0)
Definition redundant_runtime.h:444
static std::uint64_t ceil(std::uint64_t n, std::uint64_t d)
Definition redundant_runtime.h:462
static void require(bool value, char const *message)
Definition redundant_runtime.h:463
typename node_type::native_type native_type
Definition redundant_runtime.h:366
std::uint64_t next_service_cost() const
Definition redundant_runtime.h:413
redundant_runtime(Storage storage, Compose compose={})
Definition redundant_runtime.h:383
Storage storage_type
Definition redundant_runtime.h:364
redundant_runtime(Compose compose={})
Definition redundant_runtime.h:382
redundant_snapshot< P, Storage > snapshot_type
Definition redundant_runtime.h:369
bool recovering() const noexcept
Definition redundant_runtime.h:411
bool failed() const noexcept
Definition redundant_runtime.h:408
static std::uint64_t service_budget(std::uint64_t admissions)
Definition redundant_runtime.h:378
Storage const & storage() const &&=delete
typename node_type::native_pointer native_pointer
Definition redundant_runtime.h:367
static constexpr unsigned maximum_levels
Definition redundant_runtime.h:375
snapshot_type snapshot() const
Definition redundant_runtime.h:396
std::shared_ptr< object_type const > object_pointer
Definition redundant_runtime.h:372
typename snapshot_type::query_type query_type
Definition redundant_runtime.h:370
execution const & active() const
Definition redundant_runtime.h:913
static std::uint64_t add(std::uint64_t a, std::uint64_t b)
Definition redundant_runtime.h:461
snapshot_type checkpoint()
Definition redundant_runtime.h:401
std::conditional_t< std::is_same_v< Compose, replace_native_value >, Compose, std::reference_wrapper< Compose > > merge_compose
Definition redundant_runtime.h:470
static void validate(profile_record const &record)
Definition redundant_runtime.h:464
std::uint64_t credit() const
Definition redundant_runtime.h:412
P policy_type
Definition redundant_runtime.h:363
std::uint64_t admission_cost() const
Definition redundant_runtime.h:414
typename node_type::pair_type pair_type
Definition redundant_runtime.h:368
action
Definition redundant_runtime.h:473
typename Storage::template index_type< node_type > index_type
Definition redundant_runtime.h:472
std::unique_ptr< execution > e_
Definition redundant_runtime.h:911
static constexpr std::uint64_t local_charge_bound
Definition redundant_runtime.h:377
Definition redundant_runtime.h:153
std::shared_ptr< redundant_object< P, Storage > const > object
Definition redundant_runtime.h:155
redundant_slot_state state
Definition redundant_runtime.h:154
bool ever_visible
Definition redundant_runtime.h:158
redundant_routes< P, Storage > route
Definition redundant_runtime.h:156
redundant_node< P, Storage >::pair_type carrier
Definition redundant_runtime.h:157
Definition redundant_runtime.h:347
redundant_frontier< P, Storage > frontier
Definition redundant_runtime.h:348
query_type query
Definition redundant_runtime.h:349
std::vector< object_pointer > runs
Definition redundant_runtime.h:350
Definition redundant_runtime.h:193
Storage storage_type
Definition redundant_runtime.h:195
std::span< object_pointer const > runs() const &noexcept
Definition redundant_runtime.h:201
query_type const & query_root() const &&=delete
std::shared_ptr< redundant_object< P, Storage > const > object_pointer
Definition redundant_runtime.h:197
redundant_snapshot(std::shared_ptr< state const > value)
Definition redundant_runtime.h:353
P policy_type
Definition redundant_runtime.h:194
query_type const & query_root() const &noexcept
Definition redundant_runtime.h:203
static redundant_snapshot restore(redundant_frontier< P, Storage > frontier, typename redundant_node< P, Storage >::pair_type head)
Definition redundant_runtime.h:211
std::span< object_pointer const > runs() const &&=delete
redundant_frontier< P, Storage > const & frontier() const &noexcept
Definition redundant_runtime.h:199
std::uint64_t admissions() const noexcept
Definition redundant_runtime.h:198
auto cursor(bit_view key) const
Definition redundant_runtime.h:205
std::shared_ptr< state const > state_
Definition redundant_runtime.h:352
bool same_layout(redundant_snapshot const &other) const noexcept
Definition redundant_runtime.h:207
cola_query_root< P, redundant_node< P, Storage > > query_type
Definition redundant_runtime.h:196
auto cursor_owned(bit_string key) const
Definition redundant_runtime.h:206
redundant_frontier< P, Storage > const & frontier() const &&=delete
Definition redundant_runtime.h:184
std::uint64_t charged
Definition redundant_runtime.h:185
std::uint64_t native_reuses
Definition redundant_runtime.h:188
std::uint64_t native_inputs
Definition redundant_runtime.h:188
std::uint64_t metadata_work
Definition redundant_runtime.h:187
std::uint64_t checkpoints
Definition redundant_runtime.h:189
std::uint64_t granted
Definition redundant_runtime.h:185
std::uint64_t native_outputs
Definition redundant_runtime.h:188
std::uint64_t merges
Definition redundant_runtime.h:189
std::uint64_t index_occurrences
Definition redundant_runtime.h:188
std::uint64_t carriers
Definition redundant_runtime.h:189
std::uint64_t root_work
Definition redundant_runtime.h:187
std::uint64_t carrier_work
Definition redundant_runtime.h:186
std::uint64_t native_work
Definition redundant_runtime.h:186
std::uint64_t max_job_charge_per_mass
Definition redundant_runtime.h:190
std::uint64_t admissions
Definition redundant_runtime.h:189
std::uint64_t indexes
Definition redundant_runtime.h:189
std::uint64_t index_work
Definition redundant_runtime.h:186
Definition runtime_graph_sealer.h:22
Definition runtime_store.h:58
Definition sort_runtime_context.h:33