diff --git a/doc b/doc index ed12c703fc..f6efe0c577 160000 --- a/doc +++ b/doc @@ -1 +1 @@ -Subproject commit ed12c703fce3b0832a745e74c95073a17e1331d4 +Subproject commit f6efe0c5770bcdb36f25e915b64eaaa8ae176597 diff --git a/scripts/base/init-bare.zeek b/scripts/base/init-bare.zeek index 46d2bc8675..547234ecbe 100644 --- a/scripts/base/init-bare.zeek +++ b/scripts/base/init-bare.zeek @@ -773,8 +773,6 @@ type ReporterStats: record { ## Table type used to map variable names to their memory allocation. ## -## .. zeek:see:: global_sizes -## ## .. todo:: We need this type definition only for declaring builtin functions ## via ``bifcl``. We should extend ``bifcl`` to understand composite types ## directly and then remove this alias. diff --git a/src/CCL.cc b/src/CCL.cc index 02d23d9bac..e396c5af55 100644 --- a/src/CCL.cc +++ b/src/CCL.cc @@ -48,10 +48,4 @@ void CCL::Sort() std::sort(syms->begin(), syms->end()); } -unsigned int CCL::MemoryAllocation() const - { - return padded_sizeof(*this) + padded_sizeof(*syms) + - util::pad_size(syms->size() * sizeof(int_list::value_type)); - } - } // namespace zeek::detail diff --git a/src/CCL.h b/src/CCL.h index 2a43244b77..5b5688a333 100644 --- a/src/CCL.h +++ b/src/CCL.h @@ -31,10 +31,6 @@ public: syms = new_syms; } - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const; - protected: int_list* syms; int negated; diff --git a/src/CompHash.h b/src/CompHash.h index da51dc6116..b5cb0ed53a 100644 --- a/src/CompHash.h +++ b/src/CompHash.h @@ -32,13 +32,6 @@ public: // Given a hash key, recover the values used to create it. ListValPtr RecoverVals(const HashKey& k) const; - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const - { - return padded_sizeof(*this); - } - protected: bool SingleValHash(HashKey& hk, const Val* v, Type* bt, bool type_check, bool optional, bool singleton) const; diff --git a/src/Conn.cc b/src/Conn.cc index 5beebf1bc0..e27c0923bd 100644 --- a/src/Conn.cc +++ b/src/Conn.cc @@ -380,27 +380,6 @@ void Connection::FlipRoles() AddHistory('^'); } -unsigned int Connection::MemoryAllocation() const - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return session::Session::MemoryAllocation() + padded_sizeof(*this) + - (timers.MemoryAllocation() - padded_sizeof(timers)) + - (conn_val ? conn_val->MemoryAllocation() : 0) + - (adapter ? adapter->MemoryAllocation() : 0) - // primary_PIA is already contained in the analyzer tree. - ; -#pragma GCC diagnostic pop - } - -unsigned int Connection::MemoryAllocationVal() const - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return conn_val ? conn_val->MemoryAllocation() : 0; -#pragma GCC diagnostic pop - } - void Connection::Describe(ODesc* d) const { session::Session::Describe(d); diff --git a/src/Conn.h b/src/Conn.h index 88ddd6c93c..bbd1d6c386 100644 --- a/src/Conn.h +++ b/src/Conn.h @@ -195,14 +195,6 @@ public: // Statistics. - // Just a lower bound. - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const override; - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocationVal() const override; - static uint64_t TotalConnections() { return total_connections; } static uint64_t CurrentConnections() { return current_connections; } diff --git a/src/DFA.cc b/src/DFA.cc index 6a2c018813..085af83a23 100644 --- a/src/DFA.cc +++ b/src/DFA.cc @@ -418,18 +418,6 @@ void DFA_Machine::Dump(FILE* f) start_state->ClearMarks(); } -unsigned int DFA_Machine::MemoryAllocation() const - { - DFA_State_Cache::Stats s; - dfa_state_cache->GetStats(&s); - - // FIXME: Count *ec? -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return padded_sizeof(*this) + s.mem + padded_sizeof(*start_state) + nfa->MemoryAllocation(); -#pragma GCC diagnostic pop - } - bool DFA_Machine::StateSetToDFA_State(NFA_state_list* state_set, DFA_State*& d, const EquivClass* ec) { diff --git a/src/DFA.h b/src/DFA.h index 5ebd3c98c9..f1d615d334 100644 --- a/src/DFA.h +++ b/src/DFA.h @@ -127,10 +127,6 @@ public: void Describe(ODesc* d) const override; void Dump(FILE* f); - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const; - protected: friend class DFA_State; // for DFA_State::ComputeXtion friend class DFA_State_Cache; diff --git a/src/Dict.cc b/src/Dict.cc index 0ccbf81b39..255b25c6bd 100644 --- a/src/Dict.cc +++ b/src/Dict.cc @@ -801,24 +801,6 @@ void Dictionary::AssertValid() const } #endif // ZEEK_DICT_DEBUG -size_t Dictionary::MemoryAllocation() const - { - size_t size = padded_sizeof(*this); - if ( table ) - { - size += zeek::util::pad_size(Capacity() * sizeof(detail::DictEntry)); - for ( int i = Capacity() - 1; i >= 0; i-- ) - if ( ! table[i].Empty() && table[i].key_size > 8 ) - size += zeek::util::pad_size(table[i].key_size); - } - - if ( order ) - size += padded_sizeof(std::vector) + - zeek::util::pad_size(sizeof(detail::DictEntry) * order->capacity()); - - return size; - } - void Dictionary::DumpKeys() const { if ( ! table ) @@ -844,11 +826,7 @@ void Dictionary::DumpKeys() const if ( binary ) { char key = char(random() % 26) + 'A'; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - sprintf(key_file, "%d.%d.%zu-%c.key", Length(), max_distance, MemoryAllocation() / Length(), - key); -#pragma GCC diagnostic pop + sprintf(key_file, "%d.%d-%c.key", Length(), max_distance, key); std::ofstream f(key_file, std::ios::binary | std::ios::out | std::ios::trunc); for ( int idx = 0; idx < Capacity(); idx++ ) if ( ! table[idx].Empty() ) @@ -861,11 +839,7 @@ void Dictionary::DumpKeys() const else { char key = char(random() % 26) + 'A'; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - sprintf(key_file, "%d.%d.%zu-%d.ckey", Length(), max_distance, - MemoryAllocation() / Length(), key); -#pragma GCC diagnostic pop + sprintf(key_file, "%d.%d-%d.ckey", Length(), max_distance, key); std::ofstream f(key_file, std::ios::out | std::ios::trunc); for ( int idx = 0; idx < Capacity(); idx++ ) if ( ! table[idx].Empty() ) @@ -913,14 +887,10 @@ void Dictionary::Dump(int level) const int distances[DICT_NUM_DISTANCES]; int max_distance = 0; DistanceStats(max_distance, distances, DICT_NUM_DISTANCES); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - printf("cap %'7d ent %'7d %'-7d load %.2f max_dist %2d mem %10zu mem/ent %3zu key/ent %3d lg " + printf("cap %'7d ent %'7d %'-7d load %.2f max_dist %2d key/ent %3d lg " "%2d remaps %1d remap_end %4d ", Capacity(), Length(), MaxLength(), (double)Length() / (table ? Capacity() : 1), - max_distance, MemoryAllocation(), (MemoryAllocation()) / (Length() ? Length() : 1), - key_size / (Length() ? Length() : 1), log2_buckets, remaps, remap_end); -#pragma GCC diagnostic pop + max_distance, key_size / (Length() ? Length() : 1), log2_buckets, remaps, remap_end); if ( Length() > 0 ) { for ( int i = 0; i < DICT_NUM_DISTANCES - 1; i++ ) diff --git a/src/Dict.h b/src/Dict.h index 5f905fcfb0..040d95b661 100644 --- a/src/Dict.h +++ b/src/Dict.h @@ -358,10 +358,6 @@ public: // Remove all entries. void Clear(); - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] size_t - MemoryAllocation() const; - /// The capacity of the table, Buckets + Overflow Size. int Capacity(bool expected = false) const; diff --git a/src/Frag.cc b/src/Frag.cc index 17159fee25..fa5d170761 100644 --- a/src/Frag.cc +++ b/src/Frag.cc @@ -381,9 +381,4 @@ void FragmentManager::Remove(detail::FragReassembler* f) Unref(f); } -uint32_t FragmentManager::MemoryAllocation() const - { - return fragments.size() * (sizeof(FragmentMap::key_type) + sizeof(FragmentMap::value_type)); - } - } // namespace zeek::detail diff --git a/src/Frag.h b/src/Frag.h index eff680011c..991f150a9d 100644 --- a/src/Frag.h +++ b/src/Frag.h @@ -87,9 +87,6 @@ public: size_t Size() const { return fragments.size(); } size_t MaxFragments() const { return max_fragments; } - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] uint32_t - MemoryAllocation() const; private: using FragmentMap = std::map; diff --git a/src/Hash.h b/src/Hash.h index a1ffaa1698..37ce6fb240 100644 --- a/src/Hash.h +++ b/src/Hash.h @@ -271,13 +271,6 @@ public: size_t Size() const { return size; } hash_t Hash() const; - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const - { - return padded_sizeof(*this) + util::pad_size(size); - } - static hash_t HashBytes(const void* bytes, size_t size); // A HashKey is "allocated" when the underlying key points somewhere diff --git a/src/IPAddr.h b/src/IPAddr.h index 91170d73a0..3a18fd9a56 100644 --- a/src/IPAddr.h +++ b/src/IPAddr.h @@ -382,13 +382,6 @@ public: */ void ConvertToThreadingValue(threading::Value::addr_t* v) const; - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const - { - return padded_sizeof(*this); - } - /** * Check if an IP prefix length would be valid against this IP address. * @@ -636,13 +629,6 @@ public: prefix.ConvertToThreadingValue(&v->prefix); } - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const - { - return padded_sizeof(*this); - } - /** * Comparison operator for IP prefix. */ diff --git a/src/List.h b/src/List.h index 6d3c318ab6..7a3d379148 100644 --- a/src/List.h +++ b/src/List.h @@ -160,13 +160,6 @@ public: return max_entries; } - [[deprecated( - "Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See GHI-572.")]] int - MemoryAllocation() const - { - return padded_sizeof(*this) + util::pad_size(max_entries * sizeof(T)); - } - void push_front(const T& a) { if ( num_entries == max_entries ) diff --git a/src/NFA.cc b/src/NFA.cc index 0d3a6d9c79..db629c5c58 100644 --- a/src/NFA.cc +++ b/src/NFA.cc @@ -157,15 +157,6 @@ void NFA_State::Dump(FILE* f) xtions[i]->Dump(f); } -unsigned int NFA_State::TotalMemoryAllocation() const - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return padded_sizeof(*this) + xtions.MemoryAllocation() - padded_sizeof(xtions) + - (epsclosure ? epsclosure->MemoryAllocation() : 0); -#pragma GCC diagnostic pop - } - NFA_Machine::NFA_Machine(NFA_State* first, NFA_State* final) { first_state = first; diff --git a/src/NFA.h b/src/NFA.h index bb77ce20b4..6304662639 100644 --- a/src/NFA.h +++ b/src/NFA.h @@ -64,11 +64,6 @@ public: void Describe(ODesc* d) const override; void Dump(FILE* f); - // Recursivly count all the reachable states. - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - TotalMemoryAllocation() const; - protected: int sym; // if SYM_CCL, then use ccl int id; // number that uniquely identifies this state @@ -128,16 +123,6 @@ public: void Describe(ODesc* d) const override; void Dump(FILE* f); - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return padded_sizeof(*this) + first_state->TotalMemoryAllocation(); -#pragma GCC diagnostic pop - } - protected: NFA_State* first_state; NFA_State* final_state; diff --git a/src/RE.cc b/src/RE.cc index f5fb352079..2751b106a1 100644 --- a/src/RE.cc +++ b/src/RE.cc @@ -411,47 +411,6 @@ int Specific_RE_Matcher::LongestMatch(const u_char* bv, int n) return last_accept; } -unsigned int Specific_RE_Matcher::MemoryAllocation() const - { - unsigned int size = 0; - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - for ( int i = 0; i < ccl_list.length(); ++i ) - size += ccl_list[i]->MemoryAllocation(); -#pragma GCC diagnostic pop - - size += util::pad_size(sizeof(CCL*) * ccl_dict.size()); - for ( const auto& entry : ccl_dict ) - { - size += padded_sizeof(std::string) + - util::pad_size(sizeof(std::string::value_type) * entry.first.size()); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - size += entry.second->MemoryAllocation(); -#pragma GCC diagnostic pop - } - - for ( const auto& entry : defs ) - { - size += padded_sizeof(std::string) + - util::pad_size(sizeof(std::string::value_type) * entry.first.size()); - size += padded_sizeof(std::string) + - util::pad_size(sizeof(std::string::value_type) * entry.second.size()); - } - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return size + padded_sizeof(*this) + - (pattern_text ? util::pad_size(strlen(pattern_text) + 1) : 0) + - ccl_list.MemoryAllocation() - padded_sizeof(ccl_list) + equiv_class.Size() - - padded_sizeof(EquivClass) + - (dfa ? dfa->MemoryAllocation() : 0) // this is ref counted; consider the bytes here? - + padded_sizeof(*any_ccl) + padded_sizeof(*accepted) // NOLINT(bugprone-sizeof-container) - + accepted->size() * padded_sizeof(AcceptingSet::key_type); -#pragma GCC diagnostic pop - } - static RE_Matcher* matcher_merge(const RE_Matcher* re1, const RE_Matcher* re2, const char* merge_op) { const char* text1 = re1->PatternText(); diff --git a/src/RE.h b/src/RE.h index e30fbb91a4..43ab308dca 100644 --- a/src/RE.h +++ b/src/RE.h @@ -123,10 +123,6 @@ public: void Dump(FILE* f); - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const; - protected: void AddAnywherePat(const char* pat); void AddExactPat(const char* pat); @@ -237,17 +233,6 @@ public: // the main ("explicit") constructor was used. const char* OrigText() const { return orig_text.c_str(); } - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return padded_sizeof(*this) + (re_anywhere ? re_anywhere->MemoryAllocation() : 0) + - (re_exact ? re_exact->MemoryAllocation() : 0); -#pragma GCC diagnostic pop - } - protected: std::string orig_text; diff --git a/src/Reassem.h b/src/Reassem.h index 8deff8d5d3..a63e2708a6 100644 --- a/src/Reassem.h +++ b/src/Reassem.h @@ -276,18 +276,10 @@ public: void Describe(ODesc* d) const override; - // Sum over all data buffered in some reassembler. - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] static uint64_t - TotalMemoryAllocation() - { - return total_size; - } + static uint64_t TotalMemoryAllocation() { return total_size; } // Data buffered by type of reassembler. - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] static uint64_t - MemoryAllocation(ReassemblerType rtype); + static uint64_t MemoryAllocation(ReassemblerType rtype); void SetMaxOldBlocks(uint32_t count) { max_old_blocks = count; } diff --git a/src/Stats.cc b/src/Stats.cc index cb764f15fe..5ac3c7b427 100644 --- a/src/Stats.cc +++ b/src/Stats.cc @@ -125,27 +125,11 @@ void ProfileLogger::Log() run_state::network_time, (utime + stime) - (first_utime + first_stime), utime - first_utime, stime - first_stime, rtime - first_rtime)); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - int conn_mem_use = expensive ? session_mgr->SessionMemoryUsage() : 0; -#pragma GCC diagnostic pop - double avg_conn_mem_use = 0; - - if ( expensive && session_mgr->CurrentSessions() != 0 ) - avg_conn_mem_use = conn_mem_use / static_cast(session_mgr->CurrentSessions()); - - // TODO: This previously output the number of connections, but now that we're storing - // sessions as well as connections, this might need to be renamed. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - file->Write(util::fmt("%.06f Conns: total=%" PRIu64 " current=%" PRIu64 "/%" PRIi32 - " mem=%" PRIi32 "K avg=%.1f table=%" PRIu32 "K connvals=%" PRIu32 "K\n", + // TODO: This previously output the number of connections, but now that we're storing + // sessions as well as connections, this might need to be renamed. + file->Write(util::fmt("%.06f Conns: total=%" PRIu64 " current=%" PRIu64 "/%u\n", run_state::network_time, Connection::TotalConnections(), - Connection::CurrentConnections(), session_mgr->CurrentSessions(), - conn_mem_use, avg_conn_mem_use, - expensive ? session_mgr->MemoryAllocation() / 1024 : 0, - expensive ? session_mgr->SessionMemoryUsageVals() / 1024 : 0)); -#pragma GCC diagnostic pop + Connection::CurrentConnections(), session_mgr->CurrentSessions())); session::Stats s; session_mgr->GetStats(s); @@ -176,12 +160,6 @@ void ProfileLogger::Log() file->Write(util::fmt("%.06f Connections expired due to inactivity: %" PRIu64 "\n", run_state::network_time, killed_by_inactivity)); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - file->Write(util::fmt("%.06f Total reassembler data: %" PRIu64 "K\n", run_state::network_time, - Reassembler::TotalMemoryAllocation() / 1024)); -#pragma GCC diagnostic pop - // Signature engine. if ( expensive && rule_matcher ) { @@ -251,7 +229,6 @@ void ProfileLogger::Log() cs.num_ids_outgoing)); // Script-level state. - unsigned int size, mem = 0; const auto& globals = global_scope()->Vars(); if ( expensive ) @@ -259,9 +236,6 @@ void ProfileLogger::Log() int total_table_entries = 0; int total_table_rentries = 0; - file->Write( - util::fmt("%.06f Global_sizes > 100k: %dK\n", run_state::network_time, mem / 1024)); - for ( const auto& global : globals ) { auto& id = global.second; @@ -272,19 +246,10 @@ void ProfileLogger::Log() { const auto& v = id->GetVal(); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - size = v->MemoryAllocation(); -#pragma GCC diagnostic pop - mem += size; - bool print = false; int entries = -1; int rentries = -1; - if ( size > 100 * 1024 ) - print = true; - if ( v->GetType()->Tag() == TYPE_TABLE ) { entries = v->AsTable()->Length(); @@ -301,21 +266,14 @@ void ProfileLogger::Log() print = true; } - if ( print ) + if ( print && entries >= 0 ) { - file->Write(util::fmt("%.06f %s = %dK", run_state::network_time, - id->Name(), size / 1024)); - - if ( entries >= 0 ) - file->Write(util::fmt(" (%d/%d entries)\n", entries, rentries)); - else - file->Write("\n"); + file->Write(util::fmt("%.06f %d/%d entries\n", + run_state::network_time, entries, rentries)); } } } - file->Write( - util::fmt("%.06f Global_sizes total: %dK\n", run_state::network_time, mem / 1024)); file->Write(util::fmt("%.06f Total number of table entries: %d/%d\n", run_state::network_time, total_table_entries, total_table_rentries)); } diff --git a/src/Type.cc b/src/Type.cc index 0196644288..77ecd5c679 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -269,11 +269,6 @@ void Type::SetError() tag = TYPE_ERROR; } -unsigned int Type::MemoryAllocation() const - { - return padded_sizeof(*this); - } - detail::TraversalCode Type::Traverse(detail::TraversalCallback* cb) const { auto tc = cb->PreType(this); @@ -334,21 +329,6 @@ void TypeList::DoDescribe(ODesc* d) const } } -unsigned int TypeList::MemoryAllocation() const - { - unsigned int size = 0; - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - for ( const auto& t : types ) - size += t->MemoryAllocation(); - - size += util::pad_size(types.capacity() * sizeof(decltype(types)::value_type)); - - return Type::MemoryAllocation() + padded_sizeof(*this) - padded_sizeof(Type) + size; -#pragma GCC diagnostic pop - } - detail::TraversalCode TypeList::Traverse(detail::TraversalCallback* cb) const { auto tc = cb->PreType(this); diff --git a/src/Type.h b/src/Type.h index 7e9b3a1d29..9afa347f18 100644 --- a/src/Type.h +++ b/src/Type.h @@ -252,10 +252,6 @@ public: void Describe(ODesc* d) const override; virtual void DescribeReST(ODesc* d, bool roles_only = false) const; - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] virtual unsigned - MemoryAllocation() const; - void SetName(const std::string& arg_name) { name = arg_name; } const std::string& GetName() const { return name; } @@ -352,10 +348,6 @@ public: void Append(TypePtr t); void AppendEvenIfNotPure(TypePtr t); - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const override; - detail::TraversalCode Traverse(detail::TraversalCallback* cb) const override; protected: diff --git a/src/Val.cc b/src/Val.cc index f8c09aa677..fa37469038 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -258,11 +258,6 @@ ValPtr Val::SizeVal() const return val_mgr->Count(0); } -unsigned int Val::MemoryAllocation() const - { - return padded_sizeof(*this); - } - bool Val::AddTo(Val* v, bool is_first_init) const { Error("+= initializer only applies to aggregate values"); @@ -807,14 +802,6 @@ AddrVal::~AddrVal() delete addr_val; } -unsigned int AddrVal::MemoryAllocation() const - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return padded_sizeof(*this) + addr_val->MemoryAllocation(); -#pragma GCC diagnostic pop - } - ValPtr AddrVal::SizeVal() const { if ( addr_val->GetFamily() == IPv4 ) @@ -877,14 +864,6 @@ int SubNetVal::Width() const return subnet_val->Length(); } -unsigned int SubNetVal::MemoryAllocation() const - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return padded_sizeof(*this) + subnet_val->MemoryAllocation(); -#pragma GCC diagnostic pop - } - ValPtr SubNetVal::SizeVal() const { int retained = 128 - subnet_val->LengthIPv6(); @@ -1002,14 +981,6 @@ void StringVal::ValDescribe(ODesc* d) const d->Add("\""); } -unsigned int StringVal::MemoryAllocation() const - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return padded_sizeof(*this) + string_val->MemoryAllocation(); -#pragma GCC diagnostic pop - } - StringValPtr StringVal::Replace(RE_Matcher* re, const String& repl, bool do_all) { const u_char* s = Bytes(); @@ -1210,14 +1181,6 @@ void PatternVal::ValDescribe(ODesc* d) const d->Add("/"); } -unsigned int PatternVal::MemoryAllocation() const - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return padded_sizeof(*this) + re_val->MemoryAllocation(); -#pragma GCC diagnostic pop - } - ValPtr PatternVal::DoClone(CloneState* state) { // We could likely treat this type as immutable and return a reference @@ -1332,19 +1295,6 @@ unsigned int ListVal::ComputeFootprint(std::unordered_set* analyzed_ return fp; } -unsigned int ListVal::MemoryAllocation() const - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - unsigned int size = 0; - for ( const auto& val : vals ) - size += val->MemoryAllocation(); - - size += util::pad_size(vals.capacity() * sizeof(decltype(vals)::value_type)); - return size + padded_sizeof(*this) + type->MemoryAllocation(); -#pragma GCC diagnostic pop - } - TableEntryVal* TableEntryVal::Clone(Val::CloneState* state) { auto rval = new TableEntryVal(val ? val->Clone(state) : nullptr); @@ -2724,25 +2674,6 @@ unsigned int TableVal::ComputeFootprint(std::unordered_set* analyzed return fp; } -unsigned int TableVal::MemoryAllocation() const - { - unsigned int size = 0; - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - for ( const auto& ve : *table_val ) - { - auto* tv = ve.GetValue(); - if ( tv->GetVal() ) - size += tv->GetVal()->MemoryAllocation(); - size += padded_sizeof(TableEntryVal); - } - - return size + padded_sizeof(*this) + table_val->MemoryAllocation() + - table_hash->MemoryAllocation(); -#pragma GCC diagnostic pop - } - std::unique_ptr TableVal::MakeHashKey(const Val& index) const { return table_hash->MakeHashKey(index, true); @@ -3107,27 +3038,6 @@ unsigned int RecordVal::ComputeFootprint(std::unordered_set* analyze return fp; } -unsigned int RecordVal::MemoryAllocation() const - { - unsigned int size = 0; - - int n = NumFields(); - for ( auto i = 0; i < n; ++i ) - { - auto f_i = GetField(i); - if ( f_i ) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - size += f_i->MemoryAllocation(); -#pragma GCC diagnostic pop - } - - size += util::pad_size(record_val->capacity() * sizeof(ZVal)); - size += padded_sizeof(*record_val); - - return size + padded_sizeof(*this); - } - ValPtr EnumVal::SizeVal() const { return val_mgr->Int(AsInt()); diff --git a/src/Val.h b/src/Val.h index ff537072ea..080278b045 100644 --- a/src/Val.h +++ b/src/Val.h @@ -135,11 +135,6 @@ public: return Footprint(&analyzed_vals); } - // Bytes in total value object. - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] virtual unsigned int - MemoryAllocation() const; - // Add this value to the given value (if appropriate). // Returns true if succcessful. is_first_init is true only if // this is the *first* initialization of the value, not @@ -510,10 +505,6 @@ public: const IPAddr& Get() const { return *addr_val; } - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const override; - protected: ValPtr DoClone(CloneState* state) override; @@ -542,10 +533,6 @@ public: const IPPrefix& Get() const { return *subnet_val; } - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const override; - protected: void ValDescribe(ODesc* d) const override; ValPtr DoClone(CloneState* state) override; @@ -579,10 +566,6 @@ public: const String* Get() const { return string_val; } - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const override; - StringValPtr Replace(RE_Matcher* re, const String& repl, bool do_all); protected: @@ -644,10 +627,6 @@ public: const RE_Matcher* Get() const { return re_val; } - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const override; - protected: void ValDescribe(ODesc* d) const override; ValPtr DoClone(CloneState* state) override; @@ -696,10 +675,6 @@ public: void Describe(ODesc* d) const override; - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const override; - protected: unsigned int ComputeFootprint(std::unordered_set* analyzed_vals) const override; @@ -973,10 +948,6 @@ public: // the function in the frame allowing it to capture its closure. void InitDefaultFunc(detail::Frame* f); - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const override; - void ClearTimer(detail::Timer* t) { if ( timer == t ) @@ -1401,9 +1372,6 @@ public: } RecordValPtr CoerceTo(RecordTypePtr other, bool allow_orphaning = false); - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const override; void DescribeReST(ODesc* d) const override; notifier::detail::Modifiable* Modifiable() override { return this; } diff --git a/src/ZeekString.cc b/src/ZeekString.cc index 2021e4696b..78067d43ec 100644 --- a/src/ZeekString.cc +++ b/src/ZeekString.cc @@ -294,11 +294,6 @@ void String::ToUpper() b[i] = toupper(b[i]); } -unsigned int String::MemoryAllocation() const - { - return padded_sizeof(*this) + util::pad_size(n + final_NUL); - } - String* String::GetSubstring(int start, int len) const { // This code used to live in zeek.bif's sub_bytes() routine. diff --git a/src/ZeekString.h b/src/ZeekString.h index 1d129e0411..9d6e6b3bf1 100644 --- a/src/ZeekString.h +++ b/src/ZeekString.h @@ -130,10 +130,6 @@ public: // XXX and to_upper; the latter doesn't use String::ToUpper(). void ToUpper(); - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation() const; - // Returns new string containing the substring of this string, // starting at @start >= 0 for going up to @length elements, // A negative @length means "until end of string". Other invalid diff --git a/src/analyzer/Analyzer.cc b/src/analyzer/Analyzer.cc index 19b854a957..48ade8b86f 100644 --- a/src/analyzer/Analyzer.cc +++ b/src/analyzer/Analyzer.cc @@ -795,25 +795,6 @@ void Analyzer::AppendNewChildren() new_children.clear(); } -unsigned int Analyzer::MemoryAllocation() const - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - unsigned int mem = padded_sizeof(*this) + (timers.MemoryAllocation() - padded_sizeof(timers)); - - LOOP_OVER_CONST_CHILDREN(i) - mem += (*i)->MemoryAllocation(); - - for ( SupportAnalyzer* a = orig_supporters; a; a = a->sibling ) - mem += a->MemoryAllocation(); - - for ( SupportAnalyzer* a = resp_supporters; a; a = a->sibling ) - mem += a->MemoryAllocation(); - - return mem; -#pragma GCC diagnostic pop - } - void Analyzer::UpdateConnVal(RecordVal* conn_val) { LOOP_OVER_CHILDREN(i) diff --git a/src/analyzer/Analyzer.h b/src/analyzer/Analyzer.h index 12fa44848f..157cebd5e4 100644 --- a/src/analyzer/Analyzer.h +++ b/src/analyzer/Analyzer.h @@ -650,13 +650,6 @@ public: */ void Weird(const char* name, const char* addl = ""); - /** - * Internal method. - */ - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] virtual unsigned int - MemoryAllocation() const; - protected: friend class AnalyzerTimer; friend class Manager; diff --git a/src/session/Manager.cc b/src/session/Manager.cc index 062ff83d2f..1316fdbcfd 100644 --- a/src/session/Manager.cc +++ b/src/session/Manager.cc @@ -269,56 +269,6 @@ void Manager::Weird(const char* name, const IP_Hdr* ip, const char* addl) reporter->Weird(ip->SrcAddr(), ip->DstAddr(), name, addl); } -unsigned int Manager::SessionMemoryUsage() - { - unsigned int mem = 0; - - if ( run_state::terminating ) - // Connections have been flushed already. - return 0; - - for ( const auto& entry : session_map ) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - mem += entry.second->MemoryAllocation(); -#pragma GCC diagnostic pop - - return mem; - } - -unsigned int Manager::SessionMemoryUsageVals() - { - unsigned int mem = 0; - - if ( run_state::terminating ) - // Connections have been flushed already. - return 0; - - for ( const auto& entry : session_map ) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - mem += entry.second->MemoryAllocationVal(); -#pragma GCC diagnostic pop - - return mem; - } - -unsigned int Manager::MemoryAllocation() - { - if ( run_state::terminating ) - // Connections have been flushed already. - return 0; - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return SessionMemoryUsage() + padded_sizeof(*this) + - (session_map.size() * (sizeof(SessionMap::key_type) + sizeof(SessionMap::value_type))) + - zeek::detail::fragment_mgr->MemoryAllocation(); - // FIXME: MemoryAllocation() not implemented for rest. - ; -#pragma GCC diagnostic pop - } - void Manager::InsertSession(detail::Key key, Session* session) { session->SetInSessionTable(true); diff --git a/src/session/Manager.h b/src/session/Manager.h index 620c475546..1160e2794a 100644 --- a/src/session/Manager.h +++ b/src/session/Manager.h @@ -94,38 +94,6 @@ public: unsigned int CurrentSessions() { return session_map.size(); } - [[deprecated("Remove in v5.1. Use CurrentSessions().")]] unsigned int CurrentConnections() - { - return CurrentSessions(); - } - - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - SessionMemoryUsage(); - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - SessionMemoryUsageVals(); - - [[deprecated("Remove in v5.1. Use SessionMemoryUsage().")]] unsigned int ConnectionMemoryUsage() - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return SessionMemoryUsage(); -#pragma GCC diagnostic pop - } - [[deprecated("Remove in v5.1. Use SessionMemoryUsageVals().")]] unsigned int - ConnectionMemoryUsageConnVals() - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return SessionMemoryUsageVals(); -#pragma GCC diagnostic pop - } - - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] unsigned int - MemoryAllocation(); - private: using SessionMap = std::unordered_map; diff --git a/src/session/Session.cc b/src/session/Session.cc index 2e267ea7fb..c8e8ef24a8 100644 --- a/src/session/Session.cc +++ b/src/session/Session.cc @@ -64,11 +64,6 @@ Session::Session(double t, EventHandlerPtr timeout_event, EventHandlerPtr status installed_status_timer = 0; } -unsigned int Session::MemoryAllocation() const - { - return 0; - } - void Session::Event(EventHandlerPtr f, analyzer::Analyzer* analyzer, const char* name) { if ( ! f ) diff --git a/src/session/Session.h b/src/session/Session.h index de4877aade..184a69c138 100644 --- a/src/session/Session.h +++ b/src/session/Session.h @@ -112,35 +112,6 @@ public: */ virtual const RecordValPtr& GetVal() = 0; - [[deprecated("Remove in v5.1. Use GetVal().")]] const RecordValPtr& ConnVal() - { - return GetVal(); - } - - /** - * Return the memory allocation required by the session record. This requires at - * least one call to Get() first in order to setup the record object. - */ - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] virtual unsigned int - MemoryAllocationVal() const = 0; - - [[deprecated("Remove in v5.1. Use MemoryAllocationVal().")]] unsigned int - MemoryAllocationConnVal() const - { -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return MemoryAllocationVal(); -#pragma GCC diagnostic pop - } - - /** - * A lower-bound calculation of how much memory a session object is using. - */ - [[deprecated("Remove in v5.1. MemoryAllocation() is deprecated and will be removed. See " - "GHI-572.")]] virtual unsigned int - MemoryAllocation() const; - /** * Generates session removal event(s). Must be overridden by child classes to * provide specific removal events. diff --git a/src/stats.bif b/src/stats.bif index 1f7f16d919..ba5b94efae 100644 --- a/src/stats.bif +++ b/src/stats.bif @@ -215,18 +215,16 @@ function get_event_stats%(%): EventStats ## get_timer_stats ## get_broker_stats ## get_reporter_stats +## TODO: this should have been deprecated before? function get_reassembler_stats%(%): ReassemblerStats %{ auto r = zeek::make_intrusive(ReassemblerStats); int n = 0; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" r->Assign(n++, Reassembler::MemoryAllocation(zeek::REASSEM_FILE)); r->Assign(n++, Reassembler::MemoryAllocation(zeek::REASSEM_FRAG)); r->Assign(n++, Reassembler::MemoryAllocation(zeek::REASSEM_TCP)); r->Assign(n++, Reassembler::MemoryAllocation(zeek::REASSEM_UNKNOWN)); -#pragma GCC diagnostic pop return r; %} diff --git a/src/zeek.bif b/src/zeek.bif index 7c6773105b..fb0c74ddd4 100644 --- a/src/zeek.bif +++ b/src/zeek.bif @@ -1265,19 +1265,6 @@ function same_object%(o1: any, o2: any%): bool return zeek::val_mgr->Bool(o1 == o2); %} -## Returns the number of bytes that a value occupies in memory. -## -## v: The value -## -## Returns: The number of bytes that *v* occupies. -function val_size%(v: any%): count &deprecated="Remove in v5.1. MemoryAllocation() is deprecated and will be removed." - %{ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - return zeek::val_mgr->Count(v->MemoryAllocation()); -#pragma GCC diagnostic pop - %} - ## Resizes a vector. ## ## aggr: The vector instance. @@ -1971,34 +1958,6 @@ function packet_source%(%): PacketSource return r; %} -## Generates a table of the size of all global variables. The table index is -## the variable name and the value is the variable size in bytes. -## -## Returns: A table that maps variable names to their sizes. -## -## .. zeek:see:: global_ids -function global_sizes%(%): var_sizes &deprecated="Remove in v5.1. MemoryAllocation() is deprecated and will be removed." - %{ - auto sizes = zeek::make_intrusive(IntrusivePtr{zeek::NewRef{}, var_sizes}); - const auto& globals = zeek::detail::global_scope()->Vars(); - - for ( const auto& global : globals ) - { - auto& id = global.second; - if ( id->HasVal() ) - { - auto id_name = zeek::make_intrusive(id->Name()); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - auto id_size = zeek::val_mgr->Count(id->GetVal()->MemoryAllocation()); -#pragma GCC diagnostic pop - sizes->Assign(std::move(id_name), std::move(id_size)); - } - } - - return sizes; - %} - ## Generates a table of the "footprint" of all global container variables. ## This is (approximately) the number of objects the global contains either ## directly or indirectly. The number is not meant to be precise, but @@ -2047,8 +2006,6 @@ function val_footprint%(v: any%): count ## has one). ## ## Returns: A table that maps identifier names to information about them. -## -## .. zeek:see:: global_sizes function global_ids%(%): id_table %{ static auto id_table = zeek::id::find_type("id_table"); diff --git a/testing/btest/Baseline/bifs.global_sizes/out b/testing/btest/Baseline/bifs.global_sizes/out deleted file mode 100644 index d746788e73..0000000000 --- a/testing/btest/Baseline/bifs.global_sizes/out +++ /dev/null @@ -1,2 +0,0 @@ -### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. -found zeek_init diff --git a/testing/btest/bifs/global_sizes.zeek b/testing/btest/bifs/global_sizes.zeek deleted file mode 100644 index 373cf74425..0000000000 --- a/testing/btest/bifs/global_sizes.zeek +++ /dev/null @@ -1,16 +0,0 @@ -# -# @TEST-EXEC: zeek -b %INPUT >out -# @TEST-EXEC: btest-diff out - -event zeek_init() - { - local a = global_sizes(); - for ( i in a ) - { - # the table is quite large, so just look for one item we expect - if ( i == "zeek_init" ) - print "found zeek_init"; - - } - - } diff --git a/testing/btest/bifs/val_size.zeek b/testing/btest/bifs/val_size.zeek deleted file mode 100644 index b375c94551..0000000000 --- a/testing/btest/bifs/val_size.zeek +++ /dev/null @@ -1,16 +0,0 @@ -# -# @TEST-EXEC: zeek -b %INPUT - -event zeek_init() - { - local a = T; - local b = 12; - local c: table[string] of addr = { ["a"] = 192.168.0.2, ["b"] = 10.0.0.2 }; - - if ( val_size(a) > val_size(b) ) - exit(1); - - if ( val_size(b) > val_size(c) ) - exit(1); - - }