From 58e275e362f590026bf83029d496b30ea807cc60 Mon Sep 17 00:00:00 2001 From: Nadav Har'El Date: Wed, 5 May 2021 13:21:11 +0300 Subject: [PATCH] cross-tree: reduce dependency on db/config.hh and database.hh Every time db/config.hh is modified (e.g., to add a new configuration option), 110 source files need to be recompiled. Many of those 110 didn't really care about configuration options, and just got the dependency accidentally by including some other header file. In this patch, I remove the include of "db/config.hh" from all header files. It is only needed in source files - and header files only need forward declarations. In some cases, source files were missing certain includes which they got incidentally from db/config.hh, so I had to add these includes explicitly. After this patch, the number of source files that get recompiled after a change to db/config.hh goes down from 110 to 45. It also means that 65 source files now compile faster because they don't include db/config.hh and whatever it included. Additionally, this patch also eliminates a few unnecessary inclusions of database.hh in other header files, which can use a forward declaration or database_fwd.hh. Some of the source files including one of those header files relied on one of the many header files brought in by database.hh, so we need to include those explicitly. In view_update_generator.hh something interesting happened - it *needs* database.hh because of code in the header file, but only included database_fwd.hh, and the only reason this worked was that the files including view_update_generator.hh already happened to unnecessarily include database.hh. So we fix that too. Refs #1 Signed-off-by: Nadav Har'El Message-Id: <20210505102111.955470-1-nyh@scylladb.com> --- cql3/functions/user_function.cc | 2 ++ db/schema_tables.hh | 3 +++ db/snapshot-ctl.cc | 1 + db/snapshot-ctl.hh | 4 +++- db/view/view_builder.hh | 2 +- db/view/view_update_generator.hh | 2 +- db/view/view_updating_consumer.hh | 3 ++- init.hh | 2 +- lua.cc | 1 + lua.hh | 5 ++++- redis/keyspace_utils.cc | 1 + redis/keyspace_utils.hh | 4 +++- repair/repair.cc | 1 + service/storage_proxy.hh | 3 +-- table.cc | 1 + transport/server.cc | 1 + 16 files changed, 27 insertions(+), 9 deletions(-) diff --git a/cql3/functions/user_function.cc b/cql3/functions/user_function.cc index f6323b3cf4..21c9ba1888 100644 --- a/cql3/functions/user_function.cc +++ b/cql3/functions/user_function.cc @@ -23,6 +23,8 @@ #include "lua.hh" #include "log.hh" +#include + namespace cql3 { namespace functions { diff --git a/db/schema_tables.hh b/db/schema_tables.hh index 3df2e55409..e93b9e7127 100644 --- a/db/schema_tables.hh +++ b/db/schema_tables.hh @@ -49,10 +49,13 @@ #include "types/map.hh" #include "query-result-set.hh" +#include + #include #include class keyspace_metadata; +class database; namespace query { class result_set; diff --git a/db/snapshot-ctl.cc b/db/snapshot-ctl.cc index b0753f31a4..9d6c4ccad0 100644 --- a/db/snapshot-ctl.cc +++ b/db/snapshot-ctl.cc @@ -40,6 +40,7 @@ #include #include "db/snapshot-ctl.hh" +#include "database.hh" namespace db { diff --git a/db/snapshot-ctl.hh b/db/snapshot-ctl.hh index 9a5cfe23fd..6d0709a5f1 100644 --- a/db/snapshot-ctl.hh +++ b/db/snapshot-ctl.hh @@ -44,7 +44,9 @@ #include #include -#include "database.hh" +#include "database_fwd.hh" +#include +#include using namespace seastar; diff --git a/db/view/view_builder.hh b/db/view/view_builder.hh index f4d3d39f44..aeea9424ef 100644 --- a/db/view/view_builder.hh +++ b/db/view/view_builder.hh @@ -21,7 +21,6 @@ #pragma once -#include "database.hh" #include "dht/i_partitioner.hh" #include "keys.hh" #include "query-request.hh" @@ -56,6 +55,7 @@ class view_build_progress; } +class database; namespace db::view { diff --git a/db/view/view_update_generator.hh b/db/view/view_update_generator.hh index d753aeceb0..a69f48829a 100644 --- a/db/view/view_update_generator.hh +++ b/db/view/view_update_generator.hh @@ -21,7 +21,7 @@ #pragma once -#include "database_fwd.hh" +#include "database.hh" #include "sstables/sstables.hh" #include "db/view/view_updating_consumer.hh" diff --git a/db/view/view_updating_consumer.hh b/db/view/view_updating_consumer.hh index 61dc9a5204..d04fa70c39 100644 --- a/db/view/view_updating_consumer.hh +++ b/db/view/view_updating_consumer.hh @@ -25,8 +25,9 @@ #include "schema_fwd.hh" #include "mutation_fragment.hh" #include "sstables/shared_sstable.hh" -#include "database.hh" #include "reader_permit.hh" +#include "db/view/row_locking.hh" +#include class evictable_reader_handle; diff --git a/init.hh b/init.hh index b53750bb37..9557e91196 100644 --- a/init.hh +++ b/init.hh @@ -24,13 +24,13 @@ #include #include #include -#include "db/config.hh" #include "log.hh" #include "seastarx.hh" namespace db { class extensions; class seed_provider_type; +class config; namespace view { class view_update_generator; } diff --git a/lua.cc b/lua.cc index 2fc14cf3b6..92bee37f48 100644 --- a/lua.cc +++ b/lua.cc @@ -27,6 +27,7 @@ #include "utils/date.h" #include #include +#include "db/config.hh" // Lua 5.4 added an extra parameter to lua_resume diff --git a/lua.hh b/lua.hh index 2c8690fb93..d168bdb9c3 100644 --- a/lua.hh +++ b/lua.hh @@ -23,9 +23,12 @@ #include "types.hh" #include "utils/updateable_value.hh" -#include "db/config.hh" #include +namespace db { +class config; +} + namespace lua { // type safe alias struct bitcode_view { diff --git a/redis/keyspace_utils.cc b/redis/keyspace_utils.cc index b92023ca28..a69abdc605 100644 --- a/redis/keyspace_utils.cc +++ b/redis/keyspace_utils.cc @@ -38,6 +38,7 @@ #include "database.hh" #include "gms/gossiper.hh" #include +#include "db/config.hh" using namespace seastar; diff --git a/redis/keyspace_utils.hh b/redis/keyspace_utils.hh index 81e9adc6f9..60bdb46396 100644 --- a/redis/keyspace_utils.hh +++ b/redis/keyspace_utils.hh @@ -21,13 +21,15 @@ #pragma once -#include "db/config.hh" #include "seastar/core/sharded.hh" #include "seastar/core/future.hh" namespace service { class migration_manager; } +namespace db { +class config; +} namespace redis { diff --git a/repair/repair.cc b/repair/repair.cc index 5071d6c415..d1ec30607d 100644 --- a/repair/repair.cc +++ b/repair/repair.cc @@ -35,6 +35,7 @@ #include "message/messaging_service.hh" #include "sstables/sstables.hh" #include "database.hh" +#include "db/config.hh" #include "hashers.hh" #include "locator/network_topology_strategy.hh" #include "utils/bit_cast.hh" diff --git a/service/storage_proxy.hh b/service/storage_proxy.hh index 9b47e4b6b9..9df7d8acc0 100644 --- a/service/storage_proxy.hh +++ b/service/storage_proxy.hh @@ -65,7 +65,6 @@ #include "cdc/stats.hh" #include "locator/token_metadata.hh" #include "db/hints/host_filter.hh" -#include "db/config.hh" class reconcilable_result; class frozen_mutation_and_schema; @@ -174,7 +173,7 @@ public: }; using clock_type = lowres_clock; struct config { - db::config::hinted_handoff_enabled_type hinted_handoff_enabled = {}; + db::hints::host_filter hinted_handoff_enabled = {}; db::hints::directory_initializer hints_directory_initializer; size_t available_memory; smp_service_group read_smp_service_group = default_smp_service_group(); diff --git a/table.cc b/table.cc index a67835f947..7fa98934ef 100644 --- a/table.cc +++ b/table.cc @@ -47,6 +47,7 @@ #include "utils/fb_utilities.hh" #include "mutation_source_metadata.hh" #include "gms/gossiper.hh" +#include "db/config.hh" static logging::logger tlogger("table"); static seastar::metrics::label column_family_label("cf"); diff --git a/transport/server.cc b/transport/server.cc index 1ed801d7b8..ae0dfd3381 100644 --- a/transport/server.cc +++ b/transport/server.cc @@ -69,6 +69,7 @@ #include "transport/cql_protocol_extension.hh" #include "utils/bit_cast.hh" +#include "db/config.hh" namespace cql_transport {