xinyiZzz commented on code in PR #21522: URL: https://github.com/apache/doris/pull/21522#discussion_r1258101142
########## be/src/runtime/memory/cache_policy.h: ########## @@ -0,0 +1,133 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "olap/lru_cache.h" +#include "util/stopwatch.hpp" +#include "util/time.h" + +namespace doris { + +static constexpr int32_t CACHE_GC_MIN_FREE_SIZE = 67108864; // 64M + +template <typename T> +class CachePolicy { +public: + CachePolicy(const std::string& name) : _name(name) {} + virtual ~CachePolicy() = default; + virtual int64_t prune_stale() = 0; + virtual int64_t prune_all() = 0; + + static void for_each_cahce_prune_stale(); + + static void for_each_cahce_prune_stale(int64_t& freed_mem, + std::unordered_map<std::string, int64_t>& freed_details, + std::unordered_map<std::string, uint64_t>& cost_details); + + static void for_each_cahce_prune_all(int64_t& freed_mem, + std::unordered_map<std::string, int64_t>& freed_details, + std::unordered_map<std::string, uint64_t>& cost_details); + +protected: + static std::list<T*>::iterator register_cache(T* cache) { Review Comment: fix,我加了个 CacheManager ########## be/src/runtime/memory/cache_policy.h: ########## @@ -0,0 +1,133 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#pragma once + +#include "olap/lru_cache.h" +#include "util/stopwatch.hpp" +#include "util/time.h" + +namespace doris { + +static constexpr int32_t CACHE_GC_MIN_FREE_SIZE = 67108864; // 64M + +template <typename T> +class CachePolicy { +public: + CachePolicy(const std::string& name) : _name(name) {} + virtual ~CachePolicy() = default; + virtual int64_t prune_stale() = 0; + virtual int64_t prune_all() = 0; + + static void for_each_cahce_prune_stale(); + + static void for_each_cahce_prune_stale(int64_t& freed_mem, + std::unordered_map<std::string, int64_t>& freed_details, + std::unordered_map<std::string, uint64_t>& cost_details); + + static void for_each_cahce_prune_all(int64_t& freed_mem, + std::unordered_map<std::string, int64_t>& freed_details, + std::unordered_map<std::string, uint64_t>& cost_details); + +protected: + static std::list<T*>::iterator register_cache(T* cache) { Review Comment: fix,我加了个 CacheManager -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org