From 69ca5e3395a74cb839eb69d1c0e87034b9b5f539 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 30 Jun 2022 15:39:17 -0700 Subject: [PATCH] ircd::gpt: Fix fs::fd/map options regressions. --- ircd/gpt_model.cc | 30 ++++++++++++++++++++---------- ircd/gpt_vocab.cc | 33 +++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/ircd/gpt_model.cc b/ircd/gpt_model.cc index 65e27a0d0..0dc4abb35 100644 --- a/ircd/gpt_model.cc +++ b/ircd/gpt_model.cc @@ -255,7 +255,7 @@ ircd::gpt::model::init_from_cache(const string_view &cache_path) decoder_size }; - const fs::map::opts map_opts + fs::map::opts map_opts { .alignment = alignof(model::decoder), .shared = bool(cache_shared), @@ -263,9 +263,10 @@ ircd::gpt::model::init_from_cache(const string_view &cache_path) .huge2mb = bool(cache_hugepage), }; + map_opts.mode = mode; default_model_shm = fs::map { - fd, map_opts, map_size + fd, map_size, map_opts, }; default_model = reinterpret_cast @@ -365,17 +366,21 @@ ircd::gpt::model::init_from_json_handle(decoder &d, fs::path(fs::path_scratch, path_part) }; - fs::fd::opts fdopts; - fdopts.sequential = true; + const fs::fd::opts fd_opts + { + .mode = std::ios::in, + .sequential = true, + }; + const fs::fd fd { - path, fdopts + path, fd_opts }; // mmap of the file const fs::map map { - fd + fd, size(fd), fs::map::opts{fd_opts}, }; // Each file is a JSON array at the top level. @@ -416,16 +421,21 @@ ircd::gpt::model::init_dataset(const string_view &path) fs::size(path) }; - const fs::fd fd + const fs::fd::opts fd_opts { - path + .mode = std::ios::in, }; - fs::map::opts map_opts; + const fs::fd fd + { + path, fd_opts, + }; + + fs::map::opts map_opts{fd_opts}; map_opts.huge2mb = bool(cache_hugepage); default_dataset_shm = fs::map { - fd, map_opts, size + fd, size, map_opts }; default_dataset = string_view diff --git a/ircd/gpt_vocab.cc b/ircd/gpt_vocab.cc index c5274843b..282059be1 100644 --- a/ircd/gpt_vocab.cc +++ b/ircd/gpt_vocab.cc @@ -107,14 +107,23 @@ ircd::gpt::vocab::init_tokens() if(!tokens_path) return; - const ircd::fs::fd file + const fs::fd file { - string_view{tokens_path} + string_view{tokens_path}, fs::fd::opts + { + .mode = std::ios::in, + }, }; - const ircd::fs::map vocab_json + const fs::map vocab_json { - file, ircd::fs::map::opts{} + file, fs::size(file), fs::map::opts + { + fs::fd::opts + { + .mode = std::ios::in + }, + }, }; tokens = 0; @@ -143,14 +152,22 @@ ircd::gpt::vocab::init_merges() if(!merges_path) return; - const ircd::fs::fd file + const fs::fd::opts file_opts { - string_view{merges_path} + .mode = std::ios::in, }; - const ircd::fs::map merges_txt + const fs::fd file { - file, ircd::fs::map::opts{} + string_view{merges_path}, file_opts + }; + + const fs::map merges_txt + { + file, fs::size(file), fs::map::opts + { + file_opts + }, }; merges = 0;