Type: Add TypeManager->TypeList() and use for ListVal()

It turns out that for every ListVal we construct, we also allocate
and construct a new TypeList instance, even though they are all the
same. Pre-create and cache the type instances in a new TypeManager.

The following script runs ~10% faster for me after this change.

    global tbl: table[string] of string;
    global i = 0;
    while ( ++i < 10000000 )
        tbl["a"] = "a";
This commit is contained in:
Arne Welzel 2023-03-30 19:36:26 +02:00
parent 04a2ee7220
commit 24c606b4df
4 changed files with 36 additions and 4 deletions

View file

@ -172,6 +172,7 @@ void do_ssl_deinit()
} // namespace
#endif
zeek::TypeManager* zeek::type_mgr = nullptr;
zeek::ValManager* zeek::val_mgr = nullptr;
zeek::packet_analysis::Manager* zeek::packet_mgr = nullptr;
zeek::analyzer::Manager* zeek::analyzer_mgr = nullptr;
@ -437,6 +438,7 @@ static void terminate_zeek()
delete session_mgr;
delete fragment_mgr;
delete telemetry_mgr;
delete type_mgr;
// free the global scope
pop_scope();
@ -593,6 +595,7 @@ SetupResult setup(int argc, char** argv, Options* zopts)
run_state::zeek_start_time = util::current_time(true);
type_mgr = new TypeManager();
val_mgr = new ValManager();
reporter = new Reporter(options.abort_on_scripting_errors);
thread_mgr = new threading::Manager();