205 :
208{
209 static_assert(
sizeof(
allocator_t) <= header_offset,
"header offset intersects with allocator");
210
211 bfs::create_directories(data_dir);
212
214 SYS_ASSERT(eosvmoc_config.cache_size >= allocator_t::get_min_size(total_header_size),
database_exception,
"configured code cache size is too small");
218 bip::file_mapping creation_mapping(
_cache_file_path.generic_string().c_str(), bip::read_write);
219 bip::mapped_region creation_region(creation_mapping, bip::read_write);
220 new (creation_region.get_address())
allocator_t(eosvmoc_config.cache_size, total_header_size);
221 new ((char*)creation_region.get_address() + header_offset) code_cache_header;
222 }
223
224 code_cache_header cache_header;
225 {
226 char header_buff[total_header_size];
228 hs.read(header_buff, sizeof(header_buff));
229 SYS_ASSERT(!hs.fail(), bad_database_version_exception,
"failed to read code cache header");
230 memcpy((
char*)&cache_header, header_buff + header_offset,
sizeof(cache_header));
231 }
232
233 SYS_ASSERT(cache_header.id == header_id, bad_database_version_exception,
"existing SYS VM OC code cache not compatible with this version");
235
237
239 if(eosvmoc_config.cache_size > existing_file_size) {
241
242 bip::file_mapping resize_mapping(
_cache_file_path.generic_string().c_str(), bip::read_write);
243 bip::mapped_region resize_region(resize_mapping, bip::read_write);
244
246 resize_allocator->grow(eosvmoc_config.cache_size - existing_file_size);
247 }
248
251
252
253 char* code_mapping = (
char*)mmap(
nullptr, eosvmoc_config.cache_size, PROT_READ|PROT_WRITE, MAP_SHARED,
_cache_fd, 0);
255
257
258 if(cache_header.serialized_descriptor_index) {
259 fc::datastream<const char*> ds(code_mapping + cache_header.serialized_descriptor_index, eosvmoc_config.cache_size - cache_header.serialized_descriptor_index);
260 unsigned number_entries;
262 for(unsigned i = 0; i < number_entries; ++i) {
263 code_descriptor cd;
265 if(cd.codegen_version != current_codegen_version) {
266 allocator->deallocate(code_mapping + cd.code_begin);
267 allocator->deallocate(code_mapping + cd.initdata_begin);
268 continue;
269 }
271 }
272 allocator->deallocate(code_mapping + cache_header.serialized_descriptor_index);
273
274 ilog(
"SYS VM Optimized Compiler code cache loaded with ${c} entries; ${f} of ${t} bytes free", (
"c", number_entries)(
"f",
allocator->get_free_memory())(
"t",
allocator->get_size()));
275 }
276 munmap(code_mapping, eosvmoc_config.cache_size);
277
279
281
282
283
284 int duped = dup(compile_monitor_conn);
287}
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
local::datagram_protocol::socket _compile_monitor_write_socket
local::datagram_protocol::socket _compile_monitor_read_socket
void set_on_disk_region_dirty(bool)
size_t _free_bytes_eviction_threshold
bfs::path _cache_file_path
const chainbase::database & _db
code_cache_index _cache_index
static const Segment ds(Segment::ds)
bip::allocator< T, pinnable_mapped_file::segment_manager > allocator
void unpack(Stream &s, std::deque< T > &value)
bip::rbtree_best_fit< bip::null_mutex_family, bip::offset_ptr< void >, alignof(std::max_align_t)> allocator_t
wrapped_fd get_connection_to_compile_monitor(int cache_fd)
key Invalid authority Invalid transaction Invalid block ID Invalid packed transaction Invalid chain ID Invalid symbol Signature type is not a currently activated type Block can not be found Unlinkable block Block does not guarantee concurrent execution without conflicts Block exhausted allowed resources Block is from the future Block is not signed by expected producer Block includes an ill formed protocol feature activation extension Block includes an ill formed additional block signature extension Error decompressing transaction Transaction should have at least one required authority Expired Transaction Invalid Reference Block Duplicate deferred transaction The transaction can not be found Transaction is too big Invalid transaction extension Transaction includes disallowed Transaction exceeded transient resource limit Account name already exists sysio_assert_message assertion failure Action can not be found Attempt to use unaccessible API Inline Action exceeds maximum size limit sysio_assert_code assertion failure uses restricted error code value action return value size too big database_exception
memcpy((char *) pInfo->slotDescription, s, l)