Skip to content

Commit

Permalink
Fix repodata benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoinePrv committed Aug 31, 2023
1 parent 8d59195 commit 8dba3de
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
19 changes: 17 additions & 2 deletions libmamba/benchmarks/src/bench_repodata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ namespace
{
ChannelContext chan_ctx = {};
MPool pool = { chan_ctx };
MRepo repo = { pool, "mychannel", repodata_file(), {}, MRepo::RepodataParser::libsolv };
MRepo repo = {
pool,
"mychannel",
repodata_file(),
{},
MRepo::RepodataParser::libsolv,
MRepo::LibsolvCache::no,
};
}
}
BENCHMARK(bench_repodata_libsolv);
Expand All @@ -45,7 +52,15 @@ namespace
{
ChannelContext chan_ctx = {};
MPool pool = { chan_ctx };
MRepo repo = { pool, "mychannel", repodata_file(), {}, MRepo::RepodataParser::mamba };
MRepo repo = {
pool,
"mychannel",
repodata_file(),
{},
MRepo::RepodataParser::mamba,
MRepo::LibsolvCache::no,

};
}
}
BENCHMARK(bench_repodata_mamba);
Expand Down
11 changes: 9 additions & 2 deletions libmamba/include/mamba/core/repo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,19 @@ namespace mamba
libsolv,
};

enum class LibsolvCache
{
yes,
no,
};

MRepo(
MPool& pool,
const std::string& name,
const fs::u8path& filename,
const RepoMetadata& meta,
RepodataParser parser = RepodataParser::automatic
RepodataParser parser = RepodataParser::automatic,
LibsolvCache use_cache = LibsolvCache::yes
);
MRepo(MPool& pool, const PrefixData& prefix_data);
MRepo(MPool& pool, const std::string& name, const std::vector<PackageInfo>& uris);
Expand Down Expand Up @@ -109,7 +116,7 @@ namespace mamba

void add_pip_as_python_dependency();
void clear(bool reuse_ids = true);
void load_file(const fs::u8path& filename, RepodataParser parser);
void load_file(const fs::u8path& filename, RepodataParser parser, LibsolvCache use_cache);
void libsolv_read_json(const fs::u8path& filename);
void mamba_read_json(const fs::u8path& filename);
bool read_solv(const fs::u8path& filename);
Expand Down
9 changes: 5 additions & 4 deletions libmamba/src/core/repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,16 @@ namespace mamba
const std::string& name,
const fs::u8path& index,
const RepoMetadata& metadata,
RepodataParser parser
RepodataParser parser,
LibsolvCache use_cache
)
: m_pool(pool)
, m_metadata(metadata)
{
auto [_, repo] = pool.pool().add_repo(name);
m_repo = repo.raw();
repo.set_url(m_metadata.url);
load_file(index, parser);
load_file(index, parser, use_cache);
repo.internalize();
}

Expand Down Expand Up @@ -402,7 +403,7 @@ namespace mamba
return true;
}

void MRepo::load_file(const fs::u8path& filename, RepodataParser parser)
void MRepo::load_file(const fs::u8path& filename, RepodataParser parser, LibsolvCache use_cache)
{
auto repo = srepo(*this);
bool is_solv = filename.extension() == ".solv";
Expand All @@ -422,7 +423,7 @@ namespace mamba
LOG_INFO << "Reading cache files '" << (filename.parent_path() / filename).string()
<< ".*' for repo index '" << name() << "'";

if (is_solv)
if (is_solv && (use_cache == LibsolvCache::yes))
{
const auto lock = LockFile(solv_file);
const bool read = read_solv(solv_file);
Expand Down

0 comments on commit 8dba3de

Please sign in to comment.