]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Project] Move runtime cache part to a separate unit
authorVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 21 Apr 2022 21:07:32 +0000 (22:07 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 21 Apr 2022 21:07:32 +0000 (22:07 +0100)
src/libserver/symcache/symcache_impl.cxx
src/libserver/symcache/symcache_internal.hxx
src/libserver/symcache/symcache_runtime.hxx [new file with mode: 0644]

index 1b7baef435f81622a9a4ff37be8ccd96b65f21be..48646de33ffa91c5284ef6217be8cfc3176f6697 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "symcache_internal.hxx"
 #include "symcache_item.hxx"
+#include "symcache_runtime.hxx"
 #include "unix-std.h"
 #include "libutil/cxx/locked_file.hxx"
 #include "fmt/core.h"
index 974c34e756af429ca92dc787f8c0760c5db82927..e094330fd27811b1cf8a086b0cac6f84c2b1d386 100644 (file)
@@ -336,34 +336,7 @@ public:
        }
 };
 
-/*
- * These items are saved within task structure and are used to track
- * symbols execution
- */
-struct cache_dynamic_item {
-       std::uint16_t start_msec; /* Relative to task time */
-       unsigned started: 1;
-       unsigned finished: 1;
-       /* unsigned pad:14; */
-       std::uint32_t async_events;
-};
-
-struct cache_savepoint {
-       unsigned order_gen;
-       unsigned items_inflight;
-       bool profile;
-       bool has_slow;
 
-       double profile_start;
-       double lim;
-
-       struct rspamd_scan_result *rs;
-
-       struct cache_item *cur_item;
-       order_generation_ptr order;
-       /* Dynamically expanded as needed */
-       struct cache_dynamic_item dynamic_items[];
-};
 } // namespace rspamd
 
 #endif //RSPAMD_SYMCACHE_INTERNAL_HXX
diff --git a/src/libserver/symcache/symcache_runtime.hxx b/src/libserver/symcache/symcache_runtime.hxx
new file mode 100644 (file)
index 0000000..bf3049f
--- /dev/null
@@ -0,0 +1,66 @@
+/*-
+ * Copyright 2022 Vsevolod Stakhov
+ *
+ * Licensed 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.
+ */
+
+
+/**
+ * Symcache runtime is produced for each task and it consists of symbols
+ * being executed, being dynamically disabled/enabled and it also captures
+ * the current order of the symbols (produced by resort periodic)
+ */
+
+#ifndef RSPAMD_SYMCACHE_RUNTIME_HXX
+#define RSPAMD_SYMCACHE_RUNTIME_HXX
+#pragma once
+
+#include "symcache_internal.hxx"
+
+namespace rspamd::symcache {
+/**
+ * These items are saved within task structure and are used to track
+ * symbols execution.
+ * Each symcache item occupies a single dynamic item, that currently has 8 bytes
+ * length
+ */
+struct cache_dynamic_item {
+       std::uint16_t start_msec; /* Relative to task time */
+       bool started;
+       bool finished;
+       std::uint32_t async_events;
+};
+
+static_assert(sizeof(cache_dynamic_item) == sizeof(std::uint64_t));
+static_assert(std::is_trivial_v<cache_dynamic_item>);
+
+struct cache_savepoint {
+       unsigned order_gen;
+       unsigned items_inflight;
+       bool profile;
+       bool has_slow;
+
+       double profile_start;
+       double lim;
+
+       struct rspamd_scan_result *rs;
+
+       struct cache_item *cur_item;
+       order_generation_ptr order;
+       /* Dynamically expanded as needed */
+       struct cache_dynamic_item dynamic_items[];
+};
+
+}
+
+#endif //RSPAMD_SYMCACHE_RUNTIME_HXX