Files
scylladb/frozen_schema.hh
Avi Kivity 8eb5d6ed31 frozen_schema: avoid allocating contiguous memory
A frozen schema can be quite large (in #10071 we measured 500 bytes per
column, and there can be thousands of columns in extreme tables). This
can cause large contiguous allocations and therefor memory stalls or
even failures to allocate.

Switch to bytes_ostream as the internal representation. Fortunately
frozen_schema is internally implemented as bytes_ostream, so the
change is minimal.

Ref #10071.

Test: unit (dev)

Closes #10105
2022-02-21 01:39:02 +01:00

33 lines
793 B
C++

/*
* Copyright 2015-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#pragma once
#include "schema_fwd.hh"
#include "frozen_mutation.hh"
#include "bytes_ostream.hh"
namespace db {
class schema_ctxt;
}
// Transport for schema_ptr across shards/nodes.
// It's safe to access from another shard by const&.
class frozen_schema {
bytes_ostream _data;
public:
explicit frozen_schema(bytes_ostream);
frozen_schema(const schema_ptr&);
frozen_schema(frozen_schema&&) = default;
frozen_schema(const frozen_schema&) = default;
frozen_schema& operator=(const frozen_schema&) = default;
frozen_schema& operator=(frozen_schema&&) = default;
schema_ptr unfreeze(const db::schema_ctxt&) const;
const bytes_ostream& representation() const;
};