-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Engines common headers support (#1000)
This commit adds support for the new format of engine common headers.
- Loading branch information
Showing
6 changed files
with
330 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Compiler for PHP (aka KPHP) | ||
// Copyright (c) 2024 LLC «V Kontakte» | ||
// Distributed under the GPL v3 License, see LICENSE.notice.txt | ||
|
||
#include "common/binlog/binlog-snapshot.h" | ||
|
||
#include <tuple> | ||
|
||
#include "common/tl/fetch.h" | ||
|
||
namespace kphp { | ||
namespace tl { | ||
|
||
namespace { | ||
|
||
constexpr int32_t RESULT_TRUE_MAGIC{0x3f9c8ef8}; | ||
|
||
} // namespace | ||
|
||
BarsicSnapshotHeader::BarsicSnapshotHeader() | ||
: fields_mask() | ||
, dependencies(DEPENDENCIES_BUFFER_SIZE) | ||
, payload_offset() {} | ||
|
||
void BarsicSnapshotHeader::SnapshotDependency::tl_fetch() noexcept { | ||
std::basic_string<char> buffer{}; | ||
buffer.reserve(STRING_BUFFER_SIZE); | ||
|
||
fields_mask = tl_fetch_int(); | ||
// skip cluster_id | ||
vk::tl::fetch_string(buffer); | ||
// skip shard_id | ||
vk::tl::fetch_string(buffer); | ||
payload_offset = tl_fetch_long(); | ||
} | ||
|
||
void BarsicSnapshotHeader::tl_fetch() noexcept { | ||
std::basic_string<char> buffer{}; | ||
buffer.reserve(STRING_BUFFER_SIZE); | ||
|
||
fields_mask = tl_fetch_int(); | ||
// skip cluster_id | ||
vk::tl::fetch_string(buffer); | ||
// skip shard_id | ||
vk::tl::fetch_string(buffer); | ||
// skip snapshot_meta | ||
vk::tl::fetch_string(buffer); | ||
// skip dependencies | ||
vk::tl::fetch_vector(dependencies); | ||
|
||
payload_offset = tl_fetch_long(); | ||
|
||
// skip engine_version | ||
vk::tl::fetch_string(buffer); | ||
// skip creation_time_nano | ||
std::ignore = tl_fetch_long(); | ||
// skip control_meta | ||
if (static_cast<bool>(fields_mask & 0x1)) { | ||
vk::tl::fetch_string(buffer); | ||
} | ||
} | ||
|
||
void TlEngineSnapshotHeader::tl_fetch() noexcept { | ||
fields_mask = tl_fetch_int(); | ||
binlog_time_sec = tl_fetch_long(); | ||
|
||
if (tl_fetch_int() == RESULT_TRUE_MAGIC) { | ||
file_binlog_crc = tl_fetch_int(); | ||
} | ||
} | ||
|
||
} // namespace tl | ||
} // namespace kphp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Compiler for PHP (aka KPHP) | ||
// Copyright (c) 2024 LLC «V Kontakte» | ||
// Distributed under the GPL v3 License, see LICENSE.notice.txt | ||
|
||
#pragma once | ||
|
||
#include <cstddef> | ||
#include <cstdint> | ||
#include <optional> | ||
#include <vector> | ||
|
||
namespace kphp { | ||
namespace tl { | ||
|
||
constexpr auto UNEXPECTED_TL_MAGIC_ERROR_FORMAT = "unexpected TL magic 0x%x, expected 0x%x\n"; | ||
|
||
constexpr auto COMMON_HEADER_META_SIZE = sizeof(int32_t) + sizeof(int64_t); | ||
constexpr auto COMMON_HEADER_HASH_SIZE = 2 * sizeof(int64_t); | ||
|
||
constexpr int32_t PMEMCACHED_OLD_INDEX_MAGIC = 0x53407fa0; | ||
constexpr int32_t PMEMCACHED_INDEX_RAM_MAGIC_G3 = 0x65049e9e; | ||
constexpr int32_t BARSIC_SNAPSHOT_HEADER_MAGIC = 0x1d0d1b74; | ||
constexpr int32_t TL_ENGINE_SNAPSHOT_HEADER_MAGIC = 0x4bf8b614; | ||
constexpr int32_t PERSISTENT_CONFIG_V2_SNAPSHOT_BLOCK = 0x501096b7; | ||
constexpr int32_t RPC_QUERIES_SNAPSHOT_QUERY_COMMON = 0x9586c501; | ||
constexpr int32_t SNAPSHOT_MAGIC = 0xf0ec39fb; | ||
constexpr int32_t COMMON_INFO_END = 0x5a9ce5ec; | ||
|
||
struct BarsicSnapshotHeader { | ||
struct SnapshotDependency { | ||
int32_t fields_mask; | ||
int64_t payload_offset; | ||
|
||
void tl_fetch() noexcept; | ||
}; | ||
|
||
int32_t fields_mask; | ||
std::vector<SnapshotDependency> dependencies; | ||
int64_t payload_offset; | ||
|
||
void tl_fetch() noexcept; | ||
|
||
BarsicSnapshotHeader(); | ||
|
||
private: | ||
static constexpr auto STRING_BUFFER_SIZE = 512; | ||
static constexpr auto DEPENDENCIES_BUFFER_SIZE = 128; | ||
}; | ||
|
||
struct TlEngineSnapshotHeader { | ||
int32_t fields_mask{}; | ||
int64_t binlog_time_sec{}; | ||
std::optional<int32_t> file_binlog_crc; | ||
|
||
void tl_fetch() noexcept; | ||
}; | ||
|
||
} // namespace tl | ||
} // namespace kphp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.