libfoedus-core
FOEDUS Core Library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
foedus::storage::PageHeader Struct Referencefinal

Just a marker to denote that a memory region represents a data page. More...

Detailed Description

Just a marker to denote that a memory region represents a data page.

Each storage page class contains this at the beginning to declare common properties. In other words, we can always reinterpret_cast a page pointer to this object and get/set basic properties.

Definition at line 184 of file page.hpp.

#include <page.hpp>

Collaboration diagram for foedus::storage::PageHeader:

Public Member Functions

 PageHeader ()=delete
 
 PageHeader (const PageHeader &other)=delete
 
PageHeaderoperator= (const PageHeader &other)=delete
 
PageType get_page_type () const
 
uint8_t get_in_layer_level () const
 
void set_in_layer_level (uint8_t level)
 
void init_volatile (VolatilePagePointer page_id, StorageId storage_id, PageType page_type) __attribute__((always_inline))
 
void init_snapshot (SnapshotPagePointer page_id, StorageId storage_id, PageType page_type) __attribute__((always_inline))
 
void increment_key_count () __attribute__((always_inline))
 
void set_key_count (uint8_t key_count) __attribute__((always_inline))
 
bool contains_hot_records (thread::Thread *context)
 

Public Attributes

uint64_t page_id_
 Page ID of this page. More...
 
StorageId storage_id_
 ID of the storage this page belongs to. More...
 
Checksum checksum_
 Checksum of the content of this page to detect corrupted pages. More...
 
uint8_t page_type_
 Actually of PageType. More...
 
bool snapshot_
 Whether this page image is of a snapshot page. More...
 
uint16_t key_count_
 physical key count (those keys might be deleted) in this page. More...
 
uint8_t masstree_layer_
 used only in masstree. More...
 
uint8_t masstree_in_layer_level_
 used only in masstree. More...
 
uint8_t stat_last_updater_node_
 A loosely maintained statistics for volatile pages. More...
 
assorted::ProbCounter hotness_
 Loosely maintained statistics on data temperature. More...
 
PageVersion page_version_
 Used in several storage types as concurrency control mechanism for the page. More...
 

Friends

std::ostream & operator<< (std::ostream &o, const PageHeader &v)
 

Constructor & Destructor Documentation

foedus::storage::PageHeader::PageHeader ( )
delete
foedus::storage::PageHeader::PageHeader ( const PageHeader other)
delete

Member Function Documentation

bool foedus::storage::PageHeader::contains_hot_records ( thread::Thread context)

Definition at line 81 of file page.cpp.

References foedus::thread::Thread::get_current_xct(), foedus::xct::Xct::get_hot_threshold_for_this_xct(), hotness_, and foedus::assorted::ProbCounter::value_.

Referenced by foedus::xct::RwLockableXctId::is_hot().

81  {
82  return hotness_.value_ >= context->get_current_xct().get_hot_threshold_for_this_xct();
83 }
uint8_t value_
Log arithmic counter of aborts.
assorted::ProbCounter hotness_
Loosely maintained statistics on data temperature.
Definition: page.hpp:268

Here is the call graph for this function:

Here is the caller graph for this function:

uint8_t foedus::storage::PageHeader::get_in_layer_level ( ) const
inline
void foedus::storage::PageHeader::increment_key_count ( )
inline

Definition at line 318 of file page.hpp.

References key_count_.

Referenced by foedus::storage::hash::ReserveRecords::append_record_to_page(), foedus::storage::hash::HashDataPage::create_record_in_snapshot(), foedus::storage::masstree::MasstreePage::increment_key_count(), and foedus::storage::hash::HashDataPage::reserve_record().

318 { ++key_count_; }
uint16_t key_count_
physical key count (those keys might be deleted) in this page.
Definition: page.hpp:219

Here is the caller graph for this function:

void foedus::storage::PageHeader::init_snapshot ( SnapshotPagePointer  page_id,
StorageId  storage_id,
PageType  page_type 
)
inline

Definition at line 301 of file page.hpp.

References foedus::storage::extract_numa_node_from_snapshot_pointer(), foedus::assorted::ProbCounter::reset(), and foedus::storage::PageVersion::reset().

Referenced by foedus::storage::masstree::MasstreePage::initialize_snapshot_common(), foedus::storage::array::ArrayPage::initialize_snapshot_page(), foedus::storage::hash::HashIntermediatePage::initialize_snapshot_page(), foedus::storage::sequential::SequentialPage::initialize_snapshot_page(), foedus::storage::hash::HashDataPage::initialize_snapshot_page(), and foedus::storage::sequential::SequentialRootPage::initialize_snapshot_page().

304  {
305  page_id_ = page_id;
306  storage_id_ = storage_id;
307  checksum_ = 0;
308  page_type_ = page_type;
309  snapshot_ = true;
310  key_count_ = 0;
311  masstree_layer_ = 0;
314  hotness_.reset();
316  }
uint8_t page_type_
Actually of PageType.
Definition: page.hpp:205
uint8_t masstree_layer_
used only in masstree.
Definition: page.hpp:226
StorageId storage_id_
ID of the storage this page belongs to.
Definition: page.hpp:196
void reset() __attribute__((always_inline))
used only while page initialization
Definition: page.hpp:133
uint8_t masstree_in_layer_level_
used only in masstree.
Definition: page.hpp:243
uint16_t key_count_
physical key count (those keys might be deleted) in this page.
Definition: page.hpp:219
PageVersion page_version_
Used in several storage types as concurrency control mechanism for the page.
Definition: page.hpp:272
uint8_t extract_numa_node_from_snapshot_pointer(SnapshotPagePointer pointer)
Definition: storage_id.hpp:95
Checksum checksum_
Checksum of the content of this page to detect corrupted pages.
Definition: page.hpp:202
uint8_t stat_last_updater_node_
A loosely maintained statistics for volatile pages.
Definition: page.hpp:251
assorted::ProbCounter hotness_
Loosely maintained statistics on data temperature.
Definition: page.hpp:268
bool snapshot_
Whether this page image is of a snapshot page.
Definition: page.hpp:211
uint64_t page_id_
Page ID of this page.
Definition: page.hpp:191

Here is the call graph for this function:

Here is the caller graph for this function:

void foedus::storage::PageHeader::init_volatile ( VolatilePagePointer  page_id,
StorageId  storage_id,
PageType  page_type 
)
inline

Definition at line 284 of file page.hpp.

References foedus::assorted::ProbCounter::reset(), and foedus::storage::PageVersion::reset().

Referenced by foedus::xct::McsMockDataPage::init(), foedus::storage::masstree::MasstreePage::initialize_volatile_common(), foedus::storage::array::ArrayPage::initialize_volatile_page(), foedus::storage::hash::HashIntermediatePage::initialize_volatile_page(), foedus::storage::sequential::SequentialPage::initialize_volatile_page(), and foedus::storage::hash::HashDataPage::initialize_volatile_page().

287  {
288  page_id_ = page_id.word;
289  storage_id_ = storage_id;
290  checksum_ = 0;
291  page_type_ = page_type;
292  snapshot_ = false;
293  key_count_ = 0;
294  masstree_layer_ = 0;
296  stat_last_updater_node_ = page_id.get_numa_node();
297  hotness_.reset();
299  }
uint8_t page_type_
Actually of PageType.
Definition: page.hpp:205
uint8_t masstree_layer_
used only in masstree.
Definition: page.hpp:226
StorageId storage_id_
ID of the storage this page belongs to.
Definition: page.hpp:196
void reset() __attribute__((always_inline))
used only while page initialization
Definition: page.hpp:133
uint8_t masstree_in_layer_level_
used only in masstree.
Definition: page.hpp:243
uint16_t key_count_
physical key count (those keys might be deleted) in this page.
Definition: page.hpp:219
PageVersion page_version_
Used in several storage types as concurrency control mechanism for the page.
Definition: page.hpp:272
Checksum checksum_
Checksum of the content of this page to detect corrupted pages.
Definition: page.hpp:202
uint8_t stat_last_updater_node_
A loosely maintained statistics for volatile pages.
Definition: page.hpp:251
assorted::ProbCounter hotness_
Loosely maintained statistics on data temperature.
Definition: page.hpp:268
bool snapshot_
Whether this page image is of a snapshot page.
Definition: page.hpp:211
uint64_t page_id_
Page ID of this page.
Definition: page.hpp:191

Here is the call graph for this function:

Here is the caller graph for this function:

PageHeader& foedus::storage::PageHeader::operator= ( const PageHeader other)
delete
void foedus::storage::PageHeader::set_in_layer_level ( uint8_t  level)
inline

Definition at line 282 of file page.hpp.

Referenced by foedus::storage::hash::HashIntermediatePage::initialize_snapshot_page(), and foedus::storage::hash::HashIntermediatePage::initialize_volatile_page().

282 { masstree_in_layer_level_ = level; }
uint8_t masstree_in_layer_level_
used only in masstree.
Definition: page.hpp:243

Here is the caller graph for this function:

void foedus::storage::PageHeader::set_key_count ( uint8_t  key_count)
inline

Definition at line 319 of file page.hpp.

Referenced by foedus::storage::masstree::SplitIntermediate::migrate_pointers(), and foedus::storage::masstree::MasstreePage::set_key_count().

319 { key_count_ = key_count; }
uint16_t key_count_
physical key count (those keys might be deleted) in this page.
Definition: page.hpp:219

Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const PageHeader v 
)
friend

Definition at line 52 of file page.cpp.

52  {
53  o << "<PageHeader>";
54  o << std::endl << "<page_id>"
55  << "<raw>" << assorted::Hex(v.page_id_, 16) << "</raw>";
56  // Also write out interpreted version
57  if (v.snapshot_) {
58  describe_snapshot_pointer(&o, v.page_id_);
59  } else {
60  VolatilePagePointer pointer;
61  pointer.word = v.page_id_;
62  describe_volatile_pointer(&o, pointer);
63  }
64  o << "</page_id>";
65  o << std::endl << "<storage_id_>" << v.storage_id_ << "</storage_id_>";
66  o << "<checksum_>" << v.checksum_ << "</checksum_>";
67  o << "<page_type_>" << static_cast<int>(v.page_type_) << "</page_type_>";
68  o << std::endl << "<snapshot_>" << v.snapshot_ << "</snapshot_>";
69  o << "<key_count_>" << v.key_count_ << "</key_count_>";
70  o << "<masstree_layer_>" << static_cast<int>(v.masstree_layer_) << "</masstree_layer_>";
71  o << "<masstree_in_layer_level_>" << static_cast<int>(v.masstree_in_layer_level_)
72  << "</masstree_in_layer_level_>";
73  o << "<hotness_>" << static_cast<int>(v.hotness_.value_) << "</hotness_>";
74  o << std::endl << "<stat_last_updater_node_>" << static_cast<int>(v.stat_last_updater_node_)
75  << "</stat_last_updater_node_>";
76  o << v.page_version_;
77  o << "</PageHeader>";
78  return o;
79 }
void describe_volatile_pointer(std::ostream *o, VolatilePagePointer pointer)
Definition: storage_id.cpp:44
void describe_snapshot_pointer(std::ostream *o, SnapshotPagePointer pointer)
Definition: storage_id.cpp:27

Member Data Documentation

Checksum foedus::storage::PageHeader::checksum_

Checksum of the content of this page to detect corrupted pages.

Changes only when this page becomes a snapshot page.

Definition at line 202 of file page.hpp.

Referenced by foedus::snapshot::SnapshotWriter::open(), and foedus::storage::operator<<().

assorted::ProbCounter foedus::storage::PageHeader::hotness_

Loosely maintained statistics on data temperature.

This is a probabilistic counter: 0->1 = 100%, 1->2 = 50%, 2->3 = 25%, etc. So it grows exponentially, which should make it easy enough to tell an obviously hot record/page.

XXX(tzwang): This field only makes sense for volatile pages.

Among the preceeding word-size-algned fields (masstree_layer_, masstree_in_layer_level_, and stat_last_updater_node_), masstree_* are not changed once page constructed; stat_last_updater_node_ is loosely maintained stat. So we don't need to use atomic write for this field.

Assuming 4-byte word size ($getconf WORD_BIT).

Definition at line 268 of file page.hpp.

Referenced by foedus::xct::RetrospectiveLockList::construct(), contains_hot_records(), foedus::storage::hash::HashStoragePimpl::hcc_reset_all_temperature_stat_data(), foedus::storage::array::ArrayStoragePimpl::hcc_reset_all_temperature_stat_intermediate(), foedus::storage::masstree::MasstreeStoragePimpl::hcc_reset_all_temperature_stat_recurse(), foedus::xct::RwLockableXctId::hotter(), foedus::thread::Thread::is_hot_page(), and foedus::storage::operator<<().

uint16_t foedus::storage::PageHeader::key_count_

physical key count (those keys might be deleted) in this page.

It depends on the page type what "key count" exactly means. For example, in masstree interior page, key count is a separator count, so it contains pointers of key_count_+1. In many pages, key_count=record_count.

Definition at line 219 of file page.hpp.

Referenced by foedus::storage::sequential::SequentialPage::append_record_nosync(), foedus::storage::masstree::MasstreePage::get_key_count(), foedus::storage::hash::HashDataPage::get_record_count(), foedus::storage::masstree::grow_case_b_common(), increment_key_count(), foedus::storage::masstree::MasstreeBorderPage::initialize_layer_root(), and foedus::storage::operator<<().

uint8_t foedus::storage::PageHeader::masstree_in_layer_level_

used only in masstree.

Logical B-tree level of the page. Border pages are always level-0 whether they are foster-child or not. Intermediate pages right above border pages are level-1, their parents are level-2, ... Foster-child of an intermediate page has the same level as its foster parent. Again, this is a logical level, not physical.

Our implementation of masstree might have unbalanced sub-trees. In that case, an interemediate page's level is max(child's level) + 1. This imbalance can happen only at the root page of the first layer because of how the masstree composer work. Other than that, all B-tree nodes are balanced.

Todo:
this should be renamed to in_layer_level. now both masstree and hash use this.

Definition at line 243 of file page.hpp.

Referenced by foedus::storage::masstree::MasstreeComposer::construct_root(), foedus::storage::masstree::MasstreePage::get_btree_level(), get_in_layer_level(), foedus::storage::masstree::MasstreePage::initialize_snapshot_common(), foedus::storage::masstree::MasstreePage::initialize_volatile_common(), and foedus::storage::operator<<().

uint8_t foedus::storage::PageHeader::masstree_layer_
uint64_t foedus::storage::PageHeader::page_id_

Page ID of this page.

If this page is a snapshot page, it stores SnapshotPagePointer. If this page is a volatile page, it stores VolatilePagePointer (only numa_node/offset matters).

Definition at line 191 of file page.hpp.

Referenced by foedus::storage::masstree::allocate_new_border_page(), foedus::storage::assert_valid_volatile_page(), foedus::storage::assert_within_valid_volatile_page_impl(), foedus::storage::sequential::SequentialComposer::compose(), foedus::storage::array::ArrayComposer::construct_root(), foedus::storage::hash::HashComposer::construct_root(), foedus::storage::masstree::MasstreeComposer::construct_root(), foedus::storage::sequential::SequentialComposer::construct_root(), foedus::storage::masstree::SplitIntermediate::decide_strategy(), foedus::thread::ThreadPimpl::find_or_read_a_snapshot_page(), foedus::thread::ThreadPimpl::find_or_read_snapshot_pages_batch(), foedus::storage::hash::HashStoragePimpl::follow_page_bin_head(), foedus::storage::hash::HashIntermediatePage::get_snapshot_page_id(), foedus::storage::masstree::MasstreePage::get_snapshot_page_id(), foedus::storage::hash::HashDataPage::get_snapshot_page_id(), foedus::storage::Page::get_snapshot_page_id(), foedus::storage::hash::HashIntermediatePage::get_volatile_page_id(), foedus::storage::masstree::MasstreePage::get_volatile_page_id(), foedus::storage::hash::HashDataPage::get_volatile_page_id(), foedus::storage::Page::get_volatile_page_id(), foedus::thread::ThreadPimpl::install_a_volatile_page(), foedus::storage::masstree::SplitBorder::lock_existing_records(), foedus::snapshot::SnapshotWriter::open(), foedus::storage::hash::ComposedBinsMergedStream::open_path(), foedus::storage::operator<<(), foedus::storage::StorageManagerPimpl::reinitialize_for_recovered_snapshot(), foedus::storage::hash::HashIntermediatePage::release_pages_recursive(), foedus::storage::hash::HashDataPage::release_pages_recursive(), foedus::storage::masstree::MasstreeIntermediatePage::release_pages_recursive(), foedus::storage::masstree::MasstreeBorderPage::release_pages_recursive(), foedus::storage::hash::HashIntermediatePage::release_pages_recursive_parallel(), foedus::storage::masstree::MasstreeIntermediatePage::release_pages_recursive_parallel(), foedus::storage::hash::resolve_data_impl(), foedus::storage::hash::resolve_intermediate_impl(), foedus::memory::GlobalVolatilePageResolver::resolve_offset(), and foedus::storage::masstree::ReserveRecords::run().

uint8_t foedus::storage::PageHeader::page_type_

Actually of PageType.

Definition at line 205 of file page.hpp.

Referenced by get_page_type(), and foedus::storage::operator<<().

PageVersion foedus::storage::PageHeader::page_version_

Used in several storage types as concurrency control mechanism for the page.

Definition at line 272 of file page.hpp.

Referenced by foedus::storage::sequential::SequentialPage::append_record_nosync(), foedus::storage::hash::ReserveRecords::create_new_record_in_tail_page(), foedus::storage::hash::ReserveRecords::find_and_lock_spacious_tail(), foedus::storage::masstree::MasstreePage::get_lock_address(), foedus::storage::masstree::MasstreePage::get_version(), foedus::storage::masstree::MasstreePage::get_version_address(), foedus::storage::masstree::MasstreePage::has_foster_child(), foedus::storage::masstree::MasstreePage::is_locked(), foedus::storage::hash::HashDataPage::is_locked(), foedus::storage::masstree::MasstreePage::is_moved(), foedus::storage::masstree::MasstreePage::is_retired(), foedus::thread::ThreadPimpl::is_volatile_page_retired(), foedus::storage::hash::HashStoragePimpl::locate_record(), foedus::storage::operator<<(), foedus::xct::SysxctLockList::release_all_locks(), foedus::storage::masstree::MasstreeIntermediatePage::release_pages_recursive(), foedus::storage::masstree::MasstreeBorderPage::release_pages_recursive(), foedus::storage::masstree::MasstreeIntermediatePage::release_pages_recursive_parallel(), foedus::storage::hash::HashDataPage::reserve_record(), foedus::storage::hash::ReserveRecords::search_within_page(), foedus::storage::masstree::MasstreePage::set_moved(), foedus::storage::masstree::MasstreePage::set_retired(), and foedus::storage::hash::HashStoragePimpl::verify_single_thread_intermediate().

bool foedus::storage::PageHeader::snapshot_

Whether this page image is of a snapshot page.

This is one of the properties that don't have permanent meaning.

Definition at line 211 of file page.hpp.

Referenced by foedus::storage::masstree::Adopt::adopt_case_a(), foedus::storage::masstree::MasstreeIntermediatePage::append_minipage_snapshot(), foedus::storage::masstree::MasstreeIntermediatePage::append_pointer_snapshot(), foedus::storage::sequential::SequentialPage::append_record_nosync(), foedus::storage::hash::HashDataPage::assert_entries_impl(), foedus::storage::masstree::MasstreeBorderPage::assert_entries_impl(), foedus::storage::assert_within_valid_volatile_page_impl(), foedus::storage::masstree::MasstreeBorderPage::can_accomodate_snapshot(), foedus::storage::masstree::MasstreeComposer::construct_root(), foedus::storage::hash::HashDataPage::create_record_in_snapshot(), foedus::storage::masstree::MasstreeIntermediatePage::extract_separators_snapshot(), foedus::storage::masstree::MasstreeIntermediatePage::extract_separators_volatile(), foedus::storage::masstree::MasstreeStoragePimpl::fatify_first_root_double(), foedus::storage::masstree::MasstreeBorderPage::find_key_for_snapshot(), foedus::storage::hash::ReserveRecords::find_or_create_or_expand(), foedus::storage::hash::HashStoragePimpl::follow_page(), foedus::storage::hash::HashStoragePimpl::follow_page_bin_head(), foedus::thread::ThreadPimpl::follow_page_pointer(), foedus::thread::ThreadPimpl::follow_page_pointers_for_read_batch(), foedus::thread::ThreadPimpl::follow_page_pointers_for_write_batch(), foedus::storage::array::ArrayStoragePimpl::follow_pointers_for_read_batch(), foedus::storage::array::ArrayStoragePimpl::follow_pointers_for_write_batch(), foedus::storage::masstree::MasstreeStoragePimpl::get_first_root(), foedus::storage::hash::HashIntermediatePage::get_snapshot_page_id(), foedus::storage::masstree::MasstreePage::get_snapshot_page_id(), foedus::storage::hash::HashDataPage::get_snapshot_page_id(), foedus::storage::Page::get_snapshot_page_id(), foedus::storage::hash::HashIntermediatePage::get_volatile_page_id(), foedus::storage::masstree::MasstreePage::get_volatile_page_id(), foedus::storage::hash::HashDataPage::get_volatile_page_id(), foedus::storage::Page::get_volatile_page_id(), foedus::storage::masstree::grow_case_a_common(), foedus::storage::hash::HashStoragePimpl::insert_record(), foedus::thread::ThreadPimpl::install_a_volatile_page(), foedus::storage::hash::HashStoragePimpl::locate_bin(), foedus::storage::masstree::MasstreeStoragePimpl::locate_record(), foedus::storage::hash::HashStoragePimpl::locate_record(), foedus::storage::hash::HashStoragePimpl::locate_record_in_snapshot(), foedus::storage::masstree::MasstreeStoragePimpl::locate_record_normalized(), foedus::storage::array::ArrayStoragePimpl::lookup_for_read(), foedus::storage::array::ArrayStoragePimpl::lookup_for_read_batch(), foedus::storage::array::ArrayStoragePimpl::lookup_for_write(), foedus::storage::array::ArrayStoragePimpl::lookup_for_write_batch(), foedus::storage::masstree::MasstreeIntermediatePointerIterator::MasstreeIntermediatePointerIterator(), foedus::storage::operator<<(), foedus::storage::masstree::MasstreeStoragePimpl::peek_volatile_page_boundaries_next_layer(), foedus::storage::masstree::MasstreeStoragePimpl::peek_volatile_page_boundaries_this_layer(), foedus::storage::masstree::MasstreeStoragePimpl::peek_volatile_page_boundaries_this_layer_recurse(), foedus::thread::ThreadPimpl::place_a_new_volatile_page(), foedus::storage::array::ArrayStoragePimpl::prefetch_pages_recurse(), foedus::storage::hash::ComposedBinsMergedStream::process_a_bin(), foedus::storage::StorageManagerPimpl::reinitialize_for_recovered_snapshot(), foedus::storage::masstree::Adopt::run(), foedus::storage::masstree::GrowNonFirstLayerRoot::run(), foedus::storage::masstree::SplitBorder::run(), foedus::storage::masstree::ReserveRecords::run(), foedus::storage::hash::ReserveRecords::search_within_page(), foedus::storage::masstree::MasstreePage::set_foster_major_offset_unsafe(), foedus::storage::masstree::MasstreePage::set_high_fence_unsafe(), foedus::storage::masstree::SplitIntermediate::split_impl_no_error(), foedus::storage::hash::HashStoragePimpl::track_moved_record_search(), foedus::storage::masstree::MasstreeBorderPage::try_expand_record_in_page_physical(), foedus::storage::hash::HashStoragePimpl::upsert_record(), and foedus::storage::masstree::verify_page_basic().

uint8_t foedus::storage::PageHeader::stat_last_updater_node_

A loosely maintained statistics for volatile pages.

The NUMA node of the thread that has most recently tried to update this page. This is not atomically/transactionally maintained and should be used only as a stat. Depending on page type, this might not be even maintained (eg implicit in sequential pages).

Definition at line 251 of file page.hpp.

Referenced by foedus::storage::masstree::MasstreeStoragePimpl::delete_general(), foedus::storage::masstree::design_partition_first_parallel_recurse(), foedus::storage::masstree::MasstreeStoragePimpl::increment_general(), foedus::storage::masstree::MasstreeStoragePimpl::insert_general(), foedus::storage::hash::HashStoragePimpl::locate_record(), foedus::storage::operator<<(), foedus::storage::masstree::MasstreeStoragePimpl::overwrite_general(), and foedus::storage::masstree::MasstreeStoragePimpl::upsert_general().


The documentation for this struct was generated from the following files: