diff --git a/.clang-format b/.clang-format index 1b08f5938..b6a56e0f6 100644 --- a/.clang-format +++ b/.clang-format @@ -2,7 +2,6 @@ BasedOnStyle: Google --- Language: Cpp -Standard: "c++20" UseTab: Never DerivePointerAlignment: false PointerAlignment: Right diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0c94cc552..ed2eff3b6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,9 +17,10 @@ repos: name: isort (python) args: ["--profile", "black"] - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v13.0.0 + rev: v17.0.6 hooks: - id: clang-format + types_or: [c++, c] # - repo: local # hooks: # - id: clang-tidy diff --git a/init b/init index 9187ee5aa..823ef2484 100755 --- a/init +++ b/init @@ -120,7 +120,7 @@ fi # develop on them -> pre-commit hook not required -> we can use latest # packages. if [ "${DISTRO}" != "centos-7" ] && [ "$DISTRO" != "debian-10" ] && [ "${DISTRO}" != "ubuntu-18.04" ] && [ "${DISTRO}" != "amzn-2" ]; then - python3 -m pip install pre-commit + python3 -m pip install pre-commit==3.6.* python3 -m pre_commit install # Install py format tools for usage during the development. echo "Install black formatter" diff --git a/src/storage/v2/vertex_info_cache.cpp b/src/storage/v2/vertex_info_cache.cpp index a2546d7be..a415dfa8c 100644 --- a/src/storage/v2/vertex_info_cache.cpp +++ b/src/storage/v2/vertex_info_cache.cpp @@ -1,4 +1,4 @@ -// Copyright 2023 Memgraph Ltd. +// Copyright 2024 Memgraph Ltd. // // Use of this software is governed by the Business Source License // included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source @@ -15,6 +15,8 @@ #include "utils/flag_validation.hpp" +#include + // NOLINTNEXTLINE (cppcoreguidelines-avoid-non-const-global-variables) DEFINE_VALIDATED_uint64(delta_chain_cache_threshold, 128, "The threshold for when to cache long delta chains. This is used for heavy read + write " @@ -31,6 +33,7 @@ auto FetchHelper(VertexInfoCache const &caches, Func &&getCache, View view, Keys // check empty first, cheaper than the relative cost of doing an actual hash + find if (cache.empty()) return std::nullopt; + return std::nullopt; // defer building the key, maybe a cost at construction using key_type = typename std::remove_cvref_t::key_type; auto const it = cache.find(key_type{std::forward(keys)...}); @@ -76,8 +79,8 @@ void VertexInfoCache::Invalidate(Vertex const *vertex) { new_.outDegreeCache_.erase(vertex); // aggressive cache invalidation, TODO: be smarter - new_.hasLabelCache_.clear(); - new_.propertyValueCache_.clear(); + // new_.hasLabelCache_.clear(); + // new_.propertyValueCache_.clear(); new_.inEdgesCache_.clear(); new_.outEdgesCache_.clear(); } @@ -87,36 +90,38 @@ auto VertexInfoCache::GetLabels(View view, Vertex const *vertex) const return FetchHelper>(*this, std::mem_fn(&VertexInfoCache::Caches::labelCache_), view, vertex); } void VertexInfoCache::StoreLabels(View view, Vertex const *vertex, const std::vector &res) { - Store(res, *this, std::mem_fn(&Caches::labelCache_), view, vertex); + // Store(res, *this, std::mem_fn(&Caches::labelCache_), view, vertex); } auto VertexInfoCache::GetHasLabel(View view, Vertex const *vertex, LabelId label) const -> std::optional { - return FetchHelper(*this, std::mem_fn(&Caches::hasLabelCache_), view, vertex, label); + // return FetchHelper(*this, std::mem_fn(&Caches::hasLabelCache_), view, vertex, label); + return std::nullopt; } void VertexInfoCache::StoreHasLabel(View view, Vertex const *vertex, LabelId label, bool res) { - Store(res, *this, std::mem_fn(&Caches::hasLabelCache_), view, vertex, label); + // Store(res, *this, std::mem_fn(&Caches::hasLabelCache_), view, vertex, label); } void VertexInfoCache::Invalidate(Vertex const *vertex, LabelId label) { new_.labelCache_.erase(vertex); - new_.hasLabelCache_.erase(std::tuple{vertex, label}); + // new_.hasLabelCache_.erase(std::tuple{vertex, label}); } auto VertexInfoCache::GetProperty(View view, Vertex const *vertex, PropertyId property) const -> std::optional> { - return FetchHelper(*this, std::mem_fn(&Caches::propertyValueCache_), view, vertex, property); + // return FetchHelper(*this, std::mem_fn(&Caches::propertyValueCache_), view, vertex, property); + return std::nullopt; } void VertexInfoCache::StoreProperty(View view, Vertex const *vertex, PropertyId property, PropertyValue value) { - Store(std::move(value), *this, std::mem_fn(&Caches::propertyValueCache_), view, vertex, property); + // Store(std::move(value), *this, std::mem_fn(&Caches::propertyValueCache_), view, vertex, property); } auto VertexInfoCache::GetProperties(View view, Vertex const *vertex) const -> std::optional const>> { return FetchHelper>(*this, std::mem_fn(&Caches::propertiesCache_), view, vertex); } void VertexInfoCache::StoreProperties(View view, Vertex const *vertex, std::map properties) { - Store(std::move(properties), *this, std::mem_fn(&Caches::propertiesCache_), view, vertex); + // Store(std::move(properties), *this, std::mem_fn(&Caches::propertiesCache_), view, vertex); } void VertexInfoCache::Invalidate(Vertex const *vertex, PropertyId property_key) { new_.propertiesCache_.erase(vertex); - new_.propertyValueCache_.erase(std::tuple{vertex, property_key}); + // new_.propertyValueCache_.erase(std::tuple{vertex, property_key}); } auto VertexInfoCache::GetInEdges(View view, Vertex const *src_vertex, Vertex const *dst_vertex, @@ -126,8 +131,8 @@ auto VertexInfoCache::GetInEdges(View view, Vertex const *src_vertex, Vertex con } void VertexInfoCache::StoreInEdges(View view, Vertex const *src_vertex, Vertex const *dst_vertex, std::vector edge_types, EdgeStore in_edges) { - Store(std::move(in_edges), *this, std::mem_fn(&Caches::inEdgesCache_), view, src_vertex, dst_vertex, - std::move(edge_types)); + // Store(std::move(in_edges), *this, std::mem_fn(&Caches::inEdgesCache_), view, src_vertex, dst_vertex, + // std::move(edge_types)); } auto VertexInfoCache::GetOutEdges(View view, Vertex const *src_vertex, Vertex const *dst_vertex, const std::vector &edge_types) const @@ -136,8 +141,8 @@ auto VertexInfoCache::GetOutEdges(View view, Vertex const *src_vertex, Vertex co } void VertexInfoCache::StoreOutEdges(View view, Vertex const *src_vertex, Vertex const *dst_vertex, std::vector edge_types, EdgeStore out_edges) { - Store(std::move(out_edges), *this, std::mem_fn(&Caches::outEdgesCache_), view, src_vertex, dst_vertex, - std::move(edge_types)); + // Store(std::move(out_edges), *this, std::mem_fn(&Caches::outEdgesCache_), view, src_vertex, dst_vertex, + // std::move(edge_types)); } auto VertexInfoCache::GetInDegree(View view, Vertex const *vertex) const -> std::optional { @@ -145,7 +150,7 @@ auto VertexInfoCache::GetInDegree(View view, Vertex const *vertex) const -> std: } void VertexInfoCache::StoreInDegree(View view, Vertex const *vertex, std::size_t in_degree) { - Store(in_degree, *this, std::mem_fn(&Caches::inDegreeCache_), view, vertex); + // Store(in_degree, *this, std::mem_fn(&Caches::inDegreeCache_), view, vertex); } auto VertexInfoCache::GetOutDegree(View view, Vertex const *vertex) const -> std::optional { @@ -153,7 +158,7 @@ auto VertexInfoCache::GetOutDegree(View view, Vertex const *vertex) const -> std } void VertexInfoCache::StoreOutDegree(View view, Vertex const *vertex, std::size_t out_degree) { - Store(out_degree, *this, std::mem_fn(&Caches::outDegreeCache_), view, vertex); + // Store(out_degree, *this, std::mem_fn(&Caches::outDegreeCache_), view, vertex); } void VertexInfoCache::Invalidate(Vertex const *vertex, EdgeTypeId /*unused*/, EdgeDirection direction) { @@ -175,8 +180,8 @@ void VertexInfoCache::Clear() { void VertexInfoCache::Caches::Clear() { existsCache_.clear(); deletedCache_.clear(); - hasLabelCache_.clear(); - propertyValueCache_.clear(); + // hasLabelCache_.clear(); + // propertyValueCache_.clear(); labelCache_.clear(); propertiesCache_.clear(); inEdgesCache_.clear();