From 9fe305c7d28e993e55c55427f377ae7e3251ea4f Mon Sep 17 00:00:00 2001 From: "Douglas B. Rumbaugh" Date: Fri, 6 Dec 2024 13:13:51 -0500 Subject: Interface update (#5) * Query Interface Adjustments/Refactoring Began the process of adjusting the query interface (and also the shard interface, to a lesser degree) to better accommodate the user. In particular the following changes have been made, 1. The number of necessary template arguments for the query type has been drastically reduced, while also removing the void pointers and manual delete functions from the interface. This was accomplished by requiring many of the sub-types associated with a query (parameters, etc.) to be nested inside the main query class, and by forcing the SHARD type to expose its associated record type. 2. User-defined query return types are now supported. Queries no longer are required to return strictly sets of records. Instead, the query now has LocalResultType and ResultType template parameters (which can be defaulted using a typedef in the Query type itself), allowing much more flexibility. Note that, at least for the short term, the LocalResultType must still expose the same is_deleted/is_tombstone interface as a Wrapped used to, as this is currently needed for delete filtering. A better approach to this is, hopefully, forthcoming. 3. Updated the ISAMTree.h shard and rangequery.h query to use the new interfaces, and adjusted the associated unit tests as well. 4. Dropped the unnecessary "get_data()" function from the ShardInterface concept. 5. Dropped the need to specify a record type in the ShardInterface concept. This is now handled using a required Shard::RECORD member of the Shard class itself, which should expose the name of the record type. * Updates to framework to support new Query/Shard interfaces Pretty extensive adjustments to the framework, particularly to the templates themselves, along with some type-renaming work, to support the new query and shard interfaces. Adjusted the external query interface to take an rvalue reference, rather than a pointer, to the query parameters. * Removed framework-level delete filtering This was causing some issues with the new query interface, and should probably be reworked anyway, so I'm temporarily (TM) removing the feature. * Updated benchmarks + remaining code for new interface --- include/framework/scheduling/SerialScheduler.h | 64 ++++++++++++-------------- 1 file changed, 29 insertions(+), 35 deletions(-) (limited to 'include/framework/scheduling/SerialScheduler.h') diff --git a/include/framework/scheduling/SerialScheduler.h b/include/framework/scheduling/SerialScheduler.h index ac59301..7cd9cfc 100644 --- a/include/framework/scheduling/SerialScheduler.h +++ b/include/framework/scheduling/SerialScheduler.h @@ -1,13 +1,13 @@ /* * include/framework/scheduling/SerialScheduler.h * - * Copyright (C) 2023 Douglas B. Rumbaugh + * Copyright (C) 2023-2024 Douglas B. Rumbaugh * * Distributed under the Modified BSD License. * * IMPORTANT: This "scheduler" is a shim implementation for allowing - * strictly serial, single-threaded operation of the framework. It should - * never be used in multi-threaded contexts. A call to the schedule_job + * strictly serial, single-threaded operation of the framework. It should + * never be used in multi-threaded contexts. A call to the schedule_job * function will immediately run the job and block on its completion before * returning. * @@ -21,42 +21,36 @@ namespace de { class SerialScheduler { public: - SerialScheduler(size_t memory_budget, size_t thread_cnt) - : m_memory_budget((memory_budget) ? memory_budget : UINT64_MAX) - , m_thrd_cnt((thread_cnt) ? thread_cnt: UINT64_MAX) - , m_used_memory(0) - , m_used_thrds(0) - , m_counter(0) - {} - - ~SerialScheduler() = default; - - void schedule_job(std::function job, size_t size, void *args, size_t type=0) { - size_t ts = m_counter++; - m_stats.job_queued(ts, type, size); - m_stats.job_scheduled(ts); - auto t = Task(size, ts, job, args, type, &m_stats); - t(0); - } - - void shutdown() { - /* intentionally left blank */ - } - - void print_statistics() { - m_stats.print_statistics(); - } + SerialScheduler(size_t memory_budget, size_t thread_cnt) + : m_memory_budget((memory_budget) ? memory_budget : UINT64_MAX), + m_thrd_cnt((thread_cnt) ? thread_cnt : UINT64_MAX), m_used_memory(0), + m_used_thrds(0), m_counter(0) {} + + ~SerialScheduler() = default; + + void schedule_job(std::function job, size_t size, void *args, + size_t type = 0) { + size_t ts = m_counter++; + m_stats.job_queued(ts, type, size); + m_stats.job_scheduled(ts); + auto t = Task(size, ts, job, args, type, &m_stats); + t(0); + } + + void shutdown() { /* intentionally left blank */ } + + void print_statistics() { m_stats.print_statistics(); } private: - size_t m_memory_budget; - size_t m_thrd_cnt; + [[maybe_unused]] size_t m_memory_budget; + [[maybe_unused]] size_t m_thrd_cnt; - size_t m_used_thrds; - size_t m_used_memory; + [[maybe_unused]] size_t m_used_memory; + [[maybe_unused]] size_t m_used_thrds; - size_t m_counter; + size_t m_counter; - SchedulerStatistics m_stats; + SchedulerStatistics m_stats; }; -} +} // namespace de -- cgit v1.2.3