From 9e20a97fded7f396ef35f1d6154f0c74b041748e Mon Sep 17 00:00:00 2001 From: Lalit Maganti Date: Thu, 8 Oct 2026 13:39:41 -0700 Subject: [PATCH] tp: move trace processor to FlatHashMapV2 FlatHashMapV2 (a Swiss table) is faster than FlatHashMapV1 in our benchmarks for general workloads and now generates less code, so move trace processor's maps over to it, including the StringPool's string index. The FlatHashMap alias, used by the rest of Perfetto, stays on FlatHashMapV1. A few maps stay on FlatHashMapV1, with a comment: those looked up on every event of a trace whose lookups measured slower on FlatHashMapV2 (args dedup, track interning, slice stacks and thread lookups). V2 stores each value next to its key, so large values or a large table of small padded slots cost more cache misses than V1's separate arrays. Load and load+query times vs before, Linux x64 (min of 5 runs): trace_500mb.pftrace (ftrace) -2.3% / -1.1% post_boot_trace.atr -0.8% / -0.5% ui-funcgraph.pftrace 0.0% / -0.4% trace_processor_shell stripped: -67KB. --- src/trace_processor/containers/string_pool.h | 6 +--- .../core/common/string_ranks.h | 2 +- .../core/dataframe/arrow_serializer.cc | 2 +- .../core/dataframe/bytecode_lowering.h | 2 +- .../core/dataframe/dataframe.cc | 4 +-- .../core/exec/tree_number_nodes.h | 2 +- src/trace_processor/core/plugin/plugin.cc | 4 +-- src/trace_processor/core/tree/tree.h | 2 +- src/trace_processor/core/util/ops.cc | 4 +-- src/trace_processor/core/util/ops.h | 4 +-- src/trace_processor/core/util/ops_unittest.cc | 2 +- src/trace_processor/export_json.cc | 4 +-- .../importers/art_hprof/art_heap_graph.h | 12 +++---- .../art_hprof/art_heap_graph_builder.h | 14 ++++---- .../art_hprof/art_heap_graph_resolver.cc | 8 ++--- .../importers/art_hprof/art_hprof_model.h | 4 +-- .../importers/art_hprof/art_hprof_parser.cc | 2 +- .../importers/art_hprof/art_hprof_parser.h | 6 ++-- .../art_method/art_method_tokenizer.h | 4 +-- .../art_method/art_method_v2_tokenizer.h | 4 +-- .../importers/common/args_tracker.cc | 2 +- .../importers/common/args_translation_table.h | 15 +++++---- .../common/args_translation_table_unittest.cc | 2 +- .../importers/common/clock_converter.h | 2 +- .../common/deobfuscation_mapping_table.cc | 3 +- .../common/deobfuscation_mapping_table.h | 17 +++++----- .../deobfuscation_mapping_table_unittest.cc | 10 +++--- .../importers/common/flow_tracker.h | 8 ++--- .../importers/common/global_args_tracker.h | 7 ++-- .../common/global_metadata_tracker.h | 2 +- .../importers/common/global_stats_tracker.h | 2 +- .../importers/common/gpu_tracker.h | 11 ++++--- .../importers/common/jit_cache.h | 4 +-- .../common/legacy_v8_cpu_profile_tracker.cc | 4 +-- .../common/legacy_v8_cpu_profile_tracker.h | 10 +++--- .../importers/common/mapping_tracker.h | 18 +++++------ .../common/process_track_translation_table.h | 2 +- .../importers/common/process_tracker.h | 15 +++++---- .../common/profiler_sample_tracker.h | 12 +++---- .../common/registered_file_tracker.h | 4 +-- .../importers/common/slice_tracker.h | 3 ++ .../common/slice_translation_table.h | 2 +- .../importers/common/sparse_counter_tracker.h | 2 +- .../importers/common/stack_profile_tracker.h | 5 +-- .../importers/common/state_tracker.h | 2 +- .../importers/common/symbol_tracker.h | 4 +-- .../importers/common/track_compressor.h | 4 +-- .../importers/common/track_tracker.h | 2 ++ .../importers/common/virtual_memory_mapping.h | 6 ++-- .../importers/etm/error_logger.h | 2 +- .../importers/etm/etm_tracker.h | 2 +- .../etm/etm_v4_stream_demultiplexer.cc | 2 +- .../importers/etm/target_memory.cc | 2 +- .../importers/etm/target_memory.h | 4 +-- .../importers/ftrace/binder_tracker.h | 6 ++-- .../importers/ftrace/drm_tracker.h | 10 +++--- .../importers/ftrace/ftrace_parser.h | 6 ++-- .../importers/ftrace/ftrace_tokenizer.h | 4 +-- .../importers/ftrace/generic_ftrace_tracker.h | 4 +-- .../importers/ftrace/rss_stat_tracker.h | 2 +- .../importers/ftrace/v4l2_tracker.h | 2 +- .../importers/ftrace/virtio_gpu_tracker.h | 2 +- .../importers/ftrace/virtio_video_tracker.h | 2 +- .../importers/fuchsia/fuchsia_trace_parser.h | 4 +-- .../importers/gecko/gecko_trace_tokenizer.h | 2 +- .../importers/i2c/i2c_tracker.h | 2 +- .../importers/instruments/row_parser.h | 4 +-- .../importers/perf/aux_stream_manager.h | 2 +- src/trace_processor/importers/perf/features.h | 8 ++--- .../importers/perf/perf_event_attr.h | 7 ++-- .../importers/perf/perf_invocation.cc | 4 +-- .../importers/perf/perf_invocation.h | 15 +++++---- .../importers/perf/perf_tracker.h | 2 +- .../importers/perf/record_parser.h | 2 +- .../importers/pprof/pprof_trace_reader.cc | 6 ++-- .../importers/primes/primes_trace_parser.h | 2 +- .../proto/active_chrome_processes_tracker.h | 2 +- .../proto/android_cpu_per_uid_module.h | 8 ++--- .../proto/android_cpu_per_uid_state.h | 2 +- .../proto/android_kernel_wakelocks_state.h | 4 +-- .../importers/proto/content_analyzer.cc | 6 ++-- .../importers/proto/content_analyzer.h | 10 +++--- .../importers/proto/deobfuscation_module.cc | 2 +- .../importers/proto/deobfuscation_tracker.cc | 2 +- .../importers/proto/deobfuscation_tracker.h | 2 +- .../proto/frame_timeline_event_parser.h | 2 +- .../proto/gpu_counter_sequence_state.h | 2 +- .../importers/proto/gpu_event_parser.cc | 2 +- .../importers/proto/gpu_event_parser.h | 12 +++---- .../importers/proto/graphics_event_module.cc | 6 ++-- .../proto/graphics_frame_event_parser.h | 6 ++-- .../importers/proto/heap_graph_tracker.h | 12 +++---- .../importers/proto/jit_tracker.h | 2 +- .../importers/proto/network_trace_module.h | 2 +- .../importers/proto/pigweed_detokenizer.cc | 6 ++-- .../importers/proto/pigweed_detokenizer.h | 5 +-- .../importers/proto/pixel_modem_parser.cc | 6 ++-- .../importers/proto/profile_module.h | 2 +- .../proto/profile_packet_sequence_state.h | 32 ++++++++++--------- .../importers/proto/proto_trace_parser_impl.h | 2 +- .../importers/proto/proto_trace_reader.cc | 6 ++-- .../importers/proto/proto_trace_reader.h | 10 +++--- .../proto/protovm_incremental_tracing.h | 4 +-- .../proto/stack_profile_sequence_state.h | 18 +++++------ .../importers/proto/statsd_module.h | 2 +- .../importers/proto/system_probes_parser.h | 4 +-- .../proto/track_event_extension_parser.h | 2 +- .../proto/track_event_sequence_state.h | 2 +- .../importers/proto/track_event_tracker.h | 6 ++-- .../importers/proto/user_tracker.h | 2 +- .../importers/proto/v8_module.h | 2 +- .../importers/proto/v8_sequence_state.h | 10 +++--- .../importers/proto/v8_tracker.h | 28 ++++++++-------- .../simpleperf_proto_tracker.h | 4 +-- .../systrace/systrace_line_parser.cc | 2 +- .../engine/perfetto_sql_connection.h | 8 ++--- .../engine/perfetto_sql_database.h | 10 +++--- .../generator/structured_query_generator.cc | 10 +++--- .../generator/structured_query_generator.h | 4 +-- .../perfetto_sql/intrinsics/types/counter.h | 7 ++-- .../intrinsics/types/partitioned_intervals.h | 2 +- .../parser/perfetto_sql_parser.cc | 10 +++--- .../perfetto_sql/parser/perfetto_sql_parser.h | 2 +- .../parser/perfetto_sql_parser_unittest.cc | 2 +- .../pipeline/physical_plan_unittest.cc | 2 +- .../pipeline/plan_serialization_unittest.cc | 2 +- .../perfetto_sql/pipeline/test_catalog.h | 2 +- .../android_framework_track_event.cc | 5 +-- .../connected_flow/connected_flow_impl.h | 4 +-- .../experimental_slice_layout.cc | 2 +- .../perf_text/perf_text_trace_tokenizer.h | 2 +- .../perfetto_manifest_reader.cc | 2 +- .../span_join_operator/span_join_operator.h | 2 +- .../plugins/stack_sample_importer/module.h | 2 +- .../plugins/to_ftrace/to_ftrace.h | 2 +- .../video_frame_importer/video_frame_module.h | 2 +- .../protolog_message_decoder.h | 4 +-- .../viewcapture_args_parser.h | 4 +-- .../winscope_importer/winscope_rect_tracker.h | 6 ++-- .../winscope_transform_tracker.h | 6 ++-- .../winscope_proto_to_args_with_defaults.cc | 6 ++-- src/trace_processor/rpc/httpd.cc | 3 +- src/trace_processor/rpc/rpc.h | 2 +- src/trace_processor/trace_processor_impl.cc | 6 ++-- .../trace_summary/summarizer.cc | 4 +-- .../trace_summary/summarizer.h | 4 +-- src/trace_processor/trace_summary/summary.cc | 5 +-- .../types/trace_manifest_state.h | 4 +-- .../types/trace_processor_context.h | 12 +++---- src/trace_processor/util/args_utils.cc | 3 +- src/trace_processor/util/args_utils.h | 2 +- .../util/interned_message_view.h | 4 +-- src/trace_processor/util/profile_builder.h | 6 ++-- .../util/proto_to_args_parser.h | 6 ++-- src/trace_processor/util/sql_modules.h | 6 ++-- src/trace_processor/util/trace_type.h | 6 ++-- 156 files changed, 414 insertions(+), 390 deletions(-) diff --git a/src/trace_processor/containers/string_pool.h b/src/trace_processor/containers/string_pool.h index 46282e5e83..9c8bc233c7 100644 --- a/src/trace_processor/containers/string_pool.h +++ b/src/trace_processor/containers/string_pool.h @@ -466,11 +466,7 @@ class StringPool { uint32_t block_index_ PERFETTO_GUARDED_BY(mutex_) = 0; // Maps hashes of strings to the Id in the string pool. - base::FlatHashMap, - base::LinearProbe, - /*AppendOnly=*/true> + base::FlatHashMapV2> string_index_ PERFETTO_GUARDED_BY(mutex_){/*initial_capacity=*/4096u}; }; diff --git a/src/trace_processor/core/common/string_ranks.h b/src/trace_processor/core/common/string_ranks.h index b97244919c..6fac01dbd9 100644 --- a/src/trace_processor/core/common/string_ranks.h +++ b/src/trace_processor/core/common/string_ranks.h @@ -39,7 +39,7 @@ class StringRanks { void Clear() { ranks_.Clear(); } private: - base::FlatHashMap ranks_; + base::FlatHashMapV2 ranks_; }; } // namespace perfetto::trace_processor::core diff --git a/src/trace_processor/core/dataframe/arrow_serializer.cc b/src/trace_processor/core/dataframe/arrow_serializer.cc index 610524804d..94e1879e75 100644 --- a/src/trace_processor/core/dataframe/arrow_serializer.cc +++ b/src/trace_processor/core/dataframe/arrow_serializer.cc @@ -49,7 +49,7 @@ struct ArrowSerializer::BodyPlan { struct ArrowSerializer::DictionaryPlan { std::vector values; - base::FlatHashMap index_by_id; + base::FlatHashMapV2 index_by_id; uint32_t data_length = 0; uint64_t body_size = 0; std::vector buffers; diff --git a/src/trace_processor/core/dataframe/bytecode_lowering.h b/src/trace_processor/core/dataframe/bytecode_lowering.h index 80b1f3b46d..86690444e9 100644 --- a/src/trace_processor/core/dataframe/bytecode_lowering.h +++ b/src/trace_processor/core/dataframe/bytecode_lowering.h @@ -241,7 +241,7 @@ class BytecodeLowering { IndicesReg indices_reg_; // Tracks which columns have had PrefixPopcount bytecode emitted. - base::FlatHashMap prefix_popcount_emitted_; + base::FlatHashMapV2 prefix_popcount_emitted_; // Last scratch registers returned by GetOrCreateScratchSpanRegister. std::optional scratch_; diff --git a/src/trace_processor/core/dataframe/dataframe.cc b/src/trace_processor/core/dataframe/dataframe.cc index f8f289608d..4a53962ad9 100644 --- a/src/trace_processor/core/dataframe/dataframe.cc +++ b/src/trace_processor/core/dataframe/dataframe.cc @@ -44,7 +44,7 @@ namespace { // Estimates the distinct-value count of a finalized column, or 0 if unknown. // Only computed for HasDuplicates columns: unique columns select at most one // row regardless, and the planner already handles them exactly. -uint32_t EstimateDistinct(base::FlatHashMap& counts, +uint32_t EstimateDistinct(base::FlatHashMapV2& counts, const Column& c) { if (!c.duplicate_state.Is()) { return 0; @@ -232,7 +232,7 @@ void Dataframe::FinalizeColumns(bool estimate_distinct) { finalized_ = true; // Reused across columns; Clear() keeps its capacity so it allocates at most // once for the whole dataframe. - base::FlatHashMap distinct_counts; + base::FlatHashMapV2 distinct_counts; for (const auto& c : columns_) { switch (c->storage.type().index()) { case StorageType::GetTypeIndex(): diff --git a/src/trace_processor/core/exec/tree_number_nodes.h b/src/trace_processor/core/exec/tree_number_nodes.h index cba80cb740..b38fa9848f 100644 --- a/src/trace_processor/core/exec/tree_number_nodes.h +++ b/src/trace_processor/core/exec/tree_number_nodes.h @@ -87,7 +87,7 @@ class TreeNumberNodes final : public Transform { // so the map stays empty. bool dense = true; uint32_t numbered = 0; - base::FlatHashMap numbers; + base::FlatHashMapV2 numbers; // Which nodes have had a row of their own, to catch an id used twice. BitVector has_row; // The batch's ids and parent ids, whatever type they arrived as. diff --git a/src/trace_processor/core/plugin/plugin.cc b/src/trace_processor/core/plugin/plugin.cc index 16c4f1a971..074e6a8534 100644 --- a/src/trace_processor/core/plugin/plugin.cc +++ b/src/trace_processor/core/plugin/plugin.cc @@ -43,7 +43,7 @@ PluginSet BuildPluginSet() { } // Build a map from plugin_id -> index in |regs|. - base::FlatHashMap id_to_idx; + base::FlatHashMapV2 id_to_idx; for (size_t i = 0; i < regs.size(); ++i) { id_to_idx[regs[i]->plugin_id] = i; } @@ -90,7 +90,7 @@ PluginSet BuildPluginSet() { // Build a map from original reg index -> position in sorted output, // so we can resolve dep indices into the final array. - base::FlatHashMap id_to_sorted_idx; + base::FlatHashMapV2 id_to_sorted_idx; for (size_t i = 0; i < sorted_order.size(); ++i) { id_to_sorted_idx[regs[sorted_order[i]]->plugin_id] = i; } diff --git a/src/trace_processor/core/tree/tree.h b/src/trace_processor/core/tree/tree.h index 863bb0cb44..80efd92e86 100644 --- a/src/trace_processor/core/tree/tree.h +++ b/src/trace_processor/core/tree/tree.h @@ -63,7 +63,7 @@ struct Tree { std::vector dense; // dense uint32 ids -> row, kNullParent absent // Arbitrary ids -> row. Optional because FlatHashMap's constructor is // explicit, which would break aggregate initialization of Tree. - std::optional> hash; + std::optional> hash; // Resolves an id to a row index within a table of |num_rows| rows, or // kNullParent if absent (returned as a sentinel rather than wrapped in diff --git a/src/trace_processor/core/util/ops.cc b/src/trace_processor/core/util/ops.cc index 455607e981..492b91d153 100644 --- a/src/trace_processor/core/util/ops.cc +++ b/src/trace_processor/core/util/ops.cc @@ -72,7 +72,7 @@ struct RowLayoutKey { } // namespace template -uint32_t EstimateDistinctCount(base::FlatHashMap* counts, +uint32_t EstimateDistinctCount(base::FlatHashMapV2* counts, Span values) { const uint64_t total = values.size(); if (total == 0) { @@ -169,7 +169,7 @@ void SortRowLayout(Span row_layout, #define PERFETTO_INSTANTIATE_DISTINCT(type) \ template uint32_t EstimateDistinctCount( \ - base::FlatHashMap*, Span); + base::FlatHashMapV2*, Span); PERFETTO_INSTANTIATE_DISTINCT(uint32_t) PERFETTO_INSTANTIATE_DISTINCT(int32_t) PERFETTO_INSTANTIATE_DISTINCT(int64_t) diff --git a/src/trace_processor/core/util/ops.h b/src/trace_processor/core/util/ops.h index b5a5ba5907..cff9ab5a77 100644 --- a/src/trace_processor/core/util/ops.h +++ b/src/trace_processor/core/util/ops.h @@ -76,7 +76,7 @@ void GatherNullableRows(Span source, // Estimates the number of distinct values using a bounded strided sample. template -uint32_t EstimateDistinctCount(base::FlatHashMap* counts, +uint32_t EstimateDistinctCount(base::FlatHashMapV2* counts, Span values); // Removes duplicate fixed-width rows and compacts |indices| in place. Rows in @@ -92,7 +92,7 @@ void SortRowLayout(Span row_layout, #define PERFETTO_DECLARE_DISTINCT(type) \ extern template uint32_t EstimateDistinctCount( \ - base::FlatHashMap*, Span); + base::FlatHashMapV2*, Span); PERFETTO_DECLARE_DISTINCT(uint32_t) PERFETTO_DECLARE_DISTINCT(int32_t) PERFETTO_DECLARE_DISTINCT(int64_t) diff --git a/src/trace_processor/core/util/ops_unittest.cc b/src/trace_processor/core/util/ops_unittest.cc index fd6832824e..0aeac35eaa 100644 --- a/src/trace_processor/core/util/ops_unittest.cc +++ b/src/trace_processor/core/util/ops_unittest.cc @@ -72,7 +72,7 @@ TEST(OpsTest, GatherNullableRowsInPlace) { } TEST(OpsTest, EstimateDistinctCount) { - base::FlatHashMap counts; + base::FlatHashMapV2 counts; const int32_t values[] = {1, 2, 1, 3}; EXPECT_EQ(EstimateDistinctCount(&counts, MakeSpan(values)), 3u); diff --git a/src/trace_processor/export_json.cc b/src/trace_processor/export_json.cc index 210de3e4fa..014e2b6571 100644 --- a/src/trace_processor/export_json.cc +++ b/src/trace_processor/export_json.cc @@ -672,8 +672,8 @@ class JsonExporter { } const TraceStorage* storage_; - base::FlatHashMap args_sets_; - base::FlatHashMap legacy_trace_ids_; + base::FlatHashMapV2 args_sets_; + base::FlatHashMapV2 legacy_trace_ids_; const Dom empty_value_; }; diff --git a/src/trace_processor/importers/art_hprof/art_heap_graph.h b/src/trace_processor/importers/art_hprof/art_heap_graph.h index c84f64258b..bb054a2976 100644 --- a/src/trace_processor/importers/art_hprof/art_heap_graph.h +++ b/src/trace_processor/importers/art_hprof/art_heap_graph.h @@ -43,10 +43,10 @@ class HeapGraph { class_fields_ = std::move(fields); } void SetIdSize(uint32_t id_size) { id_size_ = id_size; } - void SetClasses(base::FlatHashMap cls) { + void SetClasses(base::FlatHashMapV2 cls) { classes_ = std::move(cls); } - void SetStrings(base::FlatHashMap strs) { + void SetStrings(base::FlatHashMapV2 strs) { strings_ = std::move(strs); } @@ -59,7 +59,7 @@ class HeapGraph { uint32_t GetIdSize() const { return id_size_; } - const base::FlatHashMap& GetClasses() const { + const base::FlatHashMapV2& GetClasses() const { return classes_; } @@ -114,9 +114,9 @@ class HeapGraph { private: ObjectStore objects_; ClassFieldLayouts class_fields_; - base::FlatHashMap classes_; - base::FlatHashMap strings_; - base::FlatHashMap heap_id_to_name_; + base::FlatHashMapV2 classes_; + base::FlatHashMapV2 strings_; + base::FlatHashMapV2 heap_id_to_name_; uint64_t timestamp_; uint32_t id_size_ = 4; }; diff --git a/src/trace_processor/importers/art_hprof/art_heap_graph_builder.h b/src/trace_processor/importers/art_hprof/art_heap_graph_builder.h index fe4064357c..4ca3a4508b 100644 --- a/src/trace_processor/importers/art_hprof/art_heap_graph_builder.h +++ b/src/trace_processor/importers/art_hprof/art_heap_graph_builder.h @@ -112,8 +112,8 @@ class HeapGraphResolver { HeapGraphResolver(TraceProcessorContext* context, HprofHeader& header, ObjectStore& objects, - base::FlatHashMap& classes, - base::FlatHashMap& roots, + base::FlatHashMapV2& classes, + base::FlatHashMapV2& roots, ClassFieldLayouts& class_fields, uint64_t string_class_id, DebugStats& stats); @@ -134,8 +134,8 @@ class HeapGraphResolver { TraceProcessorContext* context_; HprofHeader& header_; ObjectStore& objects_; - base::FlatHashMap& roots_; - base::FlatHashMap& classes_; + base::FlatHashMapV2& roots_; + base::FlatHashMapV2& classes_; ClassFieldLayouts& class_fields_; DebugStats& stats_; @@ -251,15 +251,15 @@ class HeapGraphBuilder { StringId current_heap_; // Data collections - base::FlatHashMap strings_; - base::FlatHashMap classes_; + base::FlatHashMapV2 strings_; + base::FlatHashMapV2 classes_; ObjectStore objects_; ClassFieldLayouts class_fields_; // Type mapping and root tracking std::array prim_array_class_ids_ = {}; uint64_t string_class_id_ = 0; - base::FlatHashMap roots_; + base::FlatHashMapV2 roots_; // Debug statistics DebugStats stats_; diff --git a/src/trace_processor/importers/art_hprof/art_heap_graph_resolver.cc b/src/trace_processor/importers/art_hprof/art_heap_graph_resolver.cc index fd505a46dc..5ec732820c 100644 --- a/src/trace_processor/importers/art_hprof/art_heap_graph_resolver.cc +++ b/src/trace_processor/importers/art_hprof/art_heap_graph_resolver.cc @@ -31,8 +31,8 @@ HeapGraphResolver::HeapGraphResolver( TraceProcessorContext* context, HprofHeader& header, ObjectStore& objects, - base::FlatHashMap& classes, - base::FlatHashMap& roots, + base::FlatHashMapV2& classes, + base::FlatHashMapV2& roots, ClassFieldLayouts& class_fields, uint64_t string_class_id, DebugStats& stats) @@ -348,9 +348,9 @@ void HeapGraphResolver::BuildClassFieldLayouts() { // Reference subclasses whose "referent" edge must not be followed when // computing reachability. Matches ahat's retained=SOFT behavior: soft // referent edges are followed. - base::FlatHashMap weak_ref_classes; + base::FlatHashMapV2 weak_ref_classes; { - base::FlatHashMap base_refs; + base::FlatHashMapV2 base_refs; for (auto it = classes_.GetIterator(); it; ++it) { const auto& name = it.value().GetName(); if (name == "java.lang.ref.WeakReference" || diff --git a/src/trace_processor/importers/art_hprof/art_hprof_model.h b/src/trace_processor/importers/art_hprof/art_hprof_model.h index a6dacd651d..fe4ea67fef 100644 --- a/src/trace_processor/importers/art_hprof/art_hprof_model.h +++ b/src/trace_processor/importers/art_hprof/art_hprof_model.h @@ -326,7 +326,7 @@ struct ClassFieldLayout { std::vector object_fields; }; -using ClassFieldLayouts = base::FlatHashMap; +using ClassFieldLayouts = base::FlatHashMapV2; // Stores all the objects in a dump contiguously, with a side map from hprof // object id to index. Keeping the (large) Object payloads out of the hash map @@ -370,7 +370,7 @@ class ObjectStore { } private: - base::FlatHashMap index_; + base::FlatHashMapV2 index_; std::vector objects_; }; diff --git a/src/trace_processor/importers/art_hprof/art_hprof_parser.cc b/src/trace_processor/importers/art_hprof/art_hprof_parser.cc index 7eac976e65..fda9f8952f 100644 --- a/src/trace_processor/importers/art_hprof/art_hprof_parser.cc +++ b/src/trace_processor/importers/art_hprof/art_hprof_parser.cc @@ -332,7 +332,7 @@ void ArtHprofParser::PopulateClasses(const HeapGraph& graph) { // "referent" field during BFS. { // Find base reference type class IDs - base::FlatHashMap base_ref_kinds; + base::FlatHashMapV2 base_ref_kinds; for (auto it = graph.GetClasses().GetIterator(); it; ++it) { const auto& name = it.value().GetName(); if (name == "java.lang.ref.WeakReference") { diff --git a/src/trace_processor/importers/art_hprof/art_hprof_parser.h b/src/trace_processor/importers/art_hprof/art_hprof_parser.h index db7fa56230..99ccfa57d5 100644 --- a/src/trace_processor/importers/art_hprof/art_hprof_parser.h +++ b/src/trace_processor/importers/art_hprof/art_hprof_parser.h @@ -106,14 +106,14 @@ class ArtHprofParser : public ChunkedTraceReader { std::unique_ptr parser_; // HPROF ID → table row ID mappings, used during PopulateObjects/References. - base::FlatHashMap class_map_; - base::FlatHashMap + base::FlatHashMapV2 class_map_; + base::FlatHashMapV2 class_object_map_; // Row id in the object table for each object in the heap graph, indexed by // ObjectIndex. kInvalidRow for objects which were not inserted. static constexpr uint32_t kInvalidRow = std::numeric_limits::max(); std::vector object_rows_; - base::FlatHashMap class_name_map_; + base::FlatHashMapV2 class_name_map_; }; } // namespace perfetto::trace_processor::art_hprof #endif // SRC_TRACE_PROCESSOR_IMPORTERS_ART_HPROF_ART_HPROF_PARSER_H_ diff --git a/src/trace_processor/importers/art_method/art_method_tokenizer.h b/src/trace_processor/importers/art_method/art_method_tokenizer.h index c89dff5795..3a97ca0ab5 100644 --- a/src/trace_processor/importers/art_method/art_method_tokenizer.h +++ b/src/trace_processor/importers/art_method/art_method_tokenizer.h @@ -120,8 +120,8 @@ class ArtMethodTokenizer : public ChunkedTraceReader { uint32_t version_ = std::numeric_limits::max(); int64_t ts_ = std::numeric_limits::max(); uint32_t record_size_ = std::numeric_limits::max(); - base::FlatHashMap method_map_; - base::FlatHashMap thread_map_; + base::FlatHashMapV2 method_map_; + base::FlatHashMapV2 thread_map_; std::unique_ptr> stream_; }; diff --git a/src/trace_processor/importers/art_method/art_method_v2_tokenizer.h b/src/trace_processor/importers/art_method/art_method_v2_tokenizer.h index d321ea5a66..c9f8aa48d4 100644 --- a/src/trace_processor/importers/art_method/art_method_v2_tokenizer.h +++ b/src/trace_processor/importers/art_method/art_method_v2_tokenizer.h @@ -78,8 +78,8 @@ class ArtMethodV2Tokenizer : public ChunkedTraceReader { uint64_t tsc_frequency_ = 0; std::string summary_; - base::FlatHashMap thread_map_; - base::FlatHashMap method_map_; + base::FlatHashMapV2 thread_map_; + base::FlatHashMapV2 method_map_; }; } // namespace perfetto::trace_processor::art_method diff --git a/src/trace_processor/importers/common/args_tracker.cc b/src/trace_processor/importers/common/args_tracker.cc index 9eeea750cc..ef75a565af 100644 --- a/src/trace_processor/importers/common/args_tracker.cc +++ b/src/trace_processor/importers/common/args_tracker.cc @@ -109,7 +109,7 @@ ArgsInserter& ArgsInserter::AddArg(StringId flat_key, Variadic value, UpdatePolicy update_policy) { std::vector& args = buffer_->args; - base::FlatHashMap& key_index = buffer_->key_index; + base::FlatHashMapV2& key_index = buffer_->key_index; // Collapse same-key duplicates in place (kSkipIfExists keeps the first value, // kAddOrUpdate the last) so AddArgSet never sees two args with the same key. diff --git a/src/trace_processor/importers/common/args_translation_table.h b/src/trace_processor/importers/common/args_translation_table.h index 8ed3d9b23c..e2b4ac3a41 100644 --- a/src/trace_processor/importers/common/args_translation_table.h +++ b/src/trace_processor/importers/common/args_translation_table.h @@ -92,7 +92,7 @@ class ArgsTranslationTable { const DeobfuscationMappingTable::PackageId& package, StringId obfuscated_class, StringId deobfuscated_class, - base::FlatHashMap members) { + base::FlatHashMapV2 members) { deobfuscation_mapping_table_.AddClassTranslation( package, obfuscated_class, deobfuscated_class, std::move(members)); } @@ -190,14 +190,15 @@ class ArgsTranslationTable { // deobfuscated. A Java class name must be contained in this argument. StringId interned_obfuscated_view_dump_class_name_flat_key_; - base::FlatHashMap chrome_histogram_hash_to_name_; - base::FlatHashMap chrome_user_event_hash_to_action_; - base::FlatHashMap + base::FlatHashMapV2 chrome_histogram_hash_to_name_; + base::FlatHashMapV2 chrome_user_event_hash_to_action_; + base::FlatHashMapV2 chrome_performance_mark_site_hash_to_name_; - base::FlatHashMap + base::FlatHashMapV2 chrome_performance_mark_mark_hash_to_name_; - base::FlatHashMap chrome_study_hash_to_name_; - base::FlatHashMap native_symbol_to_location_; + base::FlatHashMapV2 chrome_study_hash_to_name_; + base::FlatHashMapV2 + native_symbol_to_location_; // A translation mapping for obfuscated Java class names and its members. DeobfuscationMappingTable deobfuscation_mapping_table_; diff --git a/src/trace_processor/importers/common/args_translation_table_unittest.cc b/src/trace_processor/importers/common/args_translation_table_unittest.cc index cf388475b7..9a20db2155 100644 --- a/src/trace_processor/importers/common/args_translation_table_unittest.cc +++ b/src/trace_processor/importers/common/args_translation_table_unittest.cc @@ -102,7 +102,7 @@ TEST(ArgsTranslationTable, TranslateClassName) { DeobfuscationMappingTable deobfuscation_mapping; deobfuscation_mapping.AddClassTranslation( DeobfuscationMappingTable::PackageId{"app", 123}, xyz_id, class_x_id, - base::FlatHashMap{}); + base::FlatHashMapV2{}); ArgsTranslationTable table(&storage); table.AddDeobfuscationMappingTable(std::move(deobfuscation_mapping)); diff --git a/src/trace_processor/importers/common/clock_converter.h b/src/trace_processor/importers/common/clock_converter.h index 5ce504f841..5491bc03bd 100644 --- a/src/trace_processor/importers/common/clock_converter.h +++ b/src/trace_processor/importers/common/clock_converter.h @@ -87,7 +87,7 @@ class ClockConverter { TraceProcessorContext* context_; bool is_initialized = false; - base::FlatHashMap timelines_; + base::FlatHashMapV2 timelines_; }; } // namespace trace_processor diff --git a/src/trace_processor/importers/common/deobfuscation_mapping_table.cc b/src/trace_processor/importers/common/deobfuscation_mapping_table.cc index 243295b681..683318791c 100644 --- a/src/trace_processor/importers/common/deobfuscation_mapping_table.cc +++ b/src/trace_processor/importers/common/deobfuscation_mapping_table.cc @@ -25,7 +25,8 @@ bool DeobfuscationMappingTable::AddClassTranslation( const PackageId& package, StringId obfuscated_class_name, StringId deobfuscated_class_name, - base::FlatHashMap obfuscated_to_deobfuscated_members) { + base::FlatHashMapV2 + obfuscated_to_deobfuscated_members) { if (PERFETTO_UNLIKELY(!default_package_id_)) { default_package_id_ = package; } diff --git a/src/trace_processor/importers/common/deobfuscation_mapping_table.h b/src/trace_processor/importers/common/deobfuscation_mapping_table.h index dba2ae4600..4da9d274ff 100644 --- a/src/trace_processor/importers/common/deobfuscation_mapping_table.h +++ b/src/trace_processor/importers/common/deobfuscation_mapping_table.h @@ -47,11 +47,11 @@ class DeobfuscationMappingTable { // Returns `true` if the translation for the given class // was inserted, `false` if there is already a translation for the given // class. - bool AddClassTranslation( - const PackageId& package, - StringId obfuscated_class_name, - StringId deobfuscated_class_name, - base::FlatHashMap obfuscated_to_deobfuscated_members); + bool AddClassTranslation(const PackageId& package, + StringId obfuscated_class_name, + StringId deobfuscated_class_name, + base::FlatHashMapV2 + obfuscated_to_deobfuscated_members); // These functions return the deobfuscated class/member name from an // obfuscated class/member name. @@ -75,15 +75,16 @@ class DeobfuscationMappingTable { } }; - using ObfuscatedToDeobfuscatedMembers = base::FlatHashMap; + using ObfuscatedToDeobfuscatedMembers = + base::FlatHashMapV2; struct ClassTranslation { StringId deobfuscated_class_name; ObfuscatedToDeobfuscatedMembers members; }; using ObfuscatedClassesToMembers = - base::FlatHashMap; - base::FlatHashMap + base::FlatHashMapV2; + base::FlatHashMapV2 class_per_package_translation_; // To translate entities which don't have a package id, we will use diff --git a/src/trace_processor/importers/common/deobfuscation_mapping_table_unittest.cc b/src/trace_processor/importers/common/deobfuscation_mapping_table_unittest.cc index d663db4468..64d81e90bd 100644 --- a/src/trace_processor/importers/common/deobfuscation_mapping_table_unittest.cc +++ b/src/trace_processor/importers/common/deobfuscation_mapping_table_unittest.cc @@ -42,7 +42,7 @@ TEST(DeobfuscationMappingTable, TranslateClassSingleInsert) { DeobfuscationMappingTable table; table.AddClassTranslation(PackageId{"app", 123}, xyz_id, class_x_id, - base::FlatHashMap{}); + base::FlatHashMapV2{}); EXPECT_EQ(table.TranslateClass(xyz_id), class_x_id); EXPECT_EQ(table.TranslateClass(PackageId{"app", 123}, xyz_id), class_x_id); EXPECT_EQ(table.TranslateClass(PackageId{"app", 124}, xyz_id), std::nullopt); @@ -59,11 +59,11 @@ TEST(DeobfuscationMappingTable, TranslateClassMultipleInsert) { DeobfuscationMappingTable table; table.AddClassTranslation(PackageId{"app1", 123}, xyz_id, class_x_id, - base::FlatHashMap{}); + base::FlatHashMapV2{}); table.AddClassTranslation(PackageId{"app2", 123}, xyz_id, class_y_id, - base::FlatHashMap{}); + base::FlatHashMapV2{}); table.AddClassTranslation(PackageId{"app3", 123}, abc_id, class_a_id, - base::FlatHashMap{}); + base::FlatHashMapV2{}); EXPECT_EQ(table.TranslateClass(xyz_id), class_x_id); EXPECT_EQ(table.TranslateClass(abc_id), std::nullopt); EXPECT_EQ(table.TranslateClass(PackageId{"app1", 123}, xyz_id), class_x_id); @@ -84,7 +84,7 @@ TEST(DeobfuscationMappingTable, TranslateMember) { StringId member_2_id = storage.InternString("member_2"); StringId member_3_id = storage.InternString("member_3"); - base::FlatHashMap members; + base::FlatHashMapV2 members; members[mmm_1_id] = member_1_id; members[mmm_2_id] = member_2_id; members[mmm_3_id] = member_3_id; diff --git a/src/trace_processor/importers/common/flow_tracker.h b/src/trace_processor/importers/common/flow_tracker.h index b988e80bb0..5d6082c62b 100644 --- a/src/trace_processor/importers/common/flow_tracker.h +++ b/src/trace_processor/importers/common/flow_tracker.h @@ -85,11 +85,11 @@ class FlowTracker { } }; - using FlowToSourceSliceMap = base::FlatHashMap; - using PendingFlowsMap = base::FlatHashMap>; + using FlowToSourceSliceMap = base::FlatHashMapV2; + using PendingFlowsMap = base::FlatHashMapV2>; using V1FlowIdToFlowIdMap = - base::FlatHashMap; - using FlowIdToV1FlowId = base::FlatHashMap; + base::FlatHashMapV2; + using FlowIdToV1FlowId = base::FlatHashMapV2; void InsertFlow(FlowId flow_id, SliceId outgoing_slice_id, diff --git a/src/trace_processor/importers/common/global_args_tracker.h b/src/trace_processor/importers/common/global_args_tracker.h index 86968f9f1c..2f0583422f 100644 --- a/src/trace_processor/importers/common/global_args_tracker.h +++ b/src/trace_processor/importers/common/global_args_tracker.h @@ -87,8 +87,8 @@ class GlobalArgsTracker { std::vector args; // key -> index in `args`; empty below a threshold, where a linear scan over // `args` is cheaper than a hash lookup. - base::FlatHashMap key_index; - base::FlatHashMap array_indexes; + base::FlatHashMapV2 key_index; + base::FlatHashMapV2 array_indexes; void Reset() { args.clear(); @@ -222,6 +222,9 @@ class GlobalArgsTracker { return arg_set_id; } + // On FlatHashMapV1 rather than FlatHashMapV2: this map gets very large and + // is hit on every arg set, and V1's separate key and value arrays (rather + // than padded 16 byte key+value slots) make for fewer cache misses here. base::FlatHashMap> arg_row_for_hash_; diff --git a/src/trace_processor/importers/common/global_metadata_tracker.h b/src/trace_processor/importers/common/global_metadata_tracker.h index b75f1cc3a1..44553e4a20 100644 --- a/src/trace_processor/importers/common/global_metadata_tracker.h +++ b/src/trace_processor/importers/common/global_metadata_tracker.h @@ -123,7 +123,7 @@ class GlobalMetadataTracker { std::array key_ids_; std::array key_type_ids_; - base::FlatHashMap id_by_entry_; + base::FlatHashMapV2 id_by_entry_; TraceStorage* const storage_; }; diff --git a/src/trace_processor/importers/common/global_stats_tracker.h b/src/trace_processor/importers/common/global_stats_tracker.h index c741b183e0..844a933944 100644 --- a/src/trace_processor/importers/common/global_stats_tracker.h +++ b/src/trace_processor/importers/common/global_stats_tracker.h @@ -184,7 +184,7 @@ class GlobalStatsTracker { std::array severity_ids_; std::array source_ids_; - base::FlatHashMap id_by_entry_; + base::FlatHashMapV2 id_by_entry_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/common/gpu_tracker.h b/src/trace_processor/importers/common/gpu_tracker.h index 09f1d5e499..390047278d 100644 --- a/src/trace_processor/importers/common/gpu_tracker.h +++ b/src/trace_processor/importers/common/gpu_tracker.h @@ -69,19 +69,20 @@ class GpuTracker { TraceProcessorContext* const context_; // Maps gpu number to GpuTable::Id for the current machine. - base::FlatHashMap gpu_ids_; + base::FlatHashMapV2 gpu_ids_; // Maps event_id to GPU render stage slice IDs. - base::FlatHashMap> event_id_to_gpu_slices_; + base::FlatHashMapV2> event_id_to_gpu_slices_; // Maps event_id to the track event slice ID. - base::FlatHashMap event_id_to_track_event_slice_; + base::FlatHashMapV2 event_id_to_track_event_slice_; // Maps event_id to the terminating track event slice ID. - base::FlatHashMap event_id_to_terminating_slice_; + base::FlatHashMapV2 event_id_to_terminating_slice_; // Maps event_id to slice IDs that are waiting on it (via event_wait_ids). - base::FlatHashMap> event_id_to_waiting_slices_; + base::FlatHashMapV2> + event_id_to_waiting_slices_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/common/jit_cache.h b/src/trace_processor/importers/common/jit_cache.h index 3da4752f5e..0dcf45daac 100644 --- a/src/trace_processor/importers/common/jit_cache.h +++ b/src/trace_processor/importers/common/jit_cache.h @@ -123,7 +123,7 @@ class JitCache { private: const tables::JitCodeTable::Id jit_code_id_; const std::optional symbol_set_id_; - base::FlatHashMap> + base::FlatHashMapV2> interned_frames_; }; @@ -134,7 +134,7 @@ class JitCache { const UniquePid upid_; const AddressRange range_; AddressRangeMap functions_; - base::FlatHashMap> + base::FlatHashMapV2> unknown_frames_; }; diff --git a/src/trace_processor/importers/common/legacy_v8_cpu_profile_tracker.cc b/src/trace_processor/importers/common/legacy_v8_cpu_profile_tracker.cc index f7aa7e2228..a22cfe9283 100644 --- a/src/trace_processor/importers/common/legacy_v8_cpu_profile_tracker.cc +++ b/src/trace_processor/importers/common/legacy_v8_cpu_profile_tracker.cc @@ -62,8 +62,8 @@ void LegacyV8CpuProfileTracker::SetStartTsForSessionAndPid(uint64_t session_id, int64_t ts) { auto [it, inserted] = state_by_session_and_pid_.Insert( std::make_pair(session_id, pid), - State{ts, base::FlatHashMap(), - base::FlatHashMap(), nullptr}); + State{ts, base::FlatHashMapV2(), + base::FlatHashMapV2(), nullptr}); it->ts = ts; if (inserted) { it->mapping = &context_->mapping_tracker->CreateDummyMapping(""); diff --git a/src/trace_processor/importers/common/legacy_v8_cpu_profile_tracker.h b/src/trace_processor/importers/common/legacy_v8_cpu_profile_tracker.h index 33ea87c1d2..630d5e26d5 100644 --- a/src/trace_processor/importers/common/legacy_v8_cpu_profile_tracker.h +++ b/src/trace_processor/importers/common/legacy_v8_cpu_profile_tracker.h @@ -78,13 +78,13 @@ class LegacyV8CpuProfileTracker private: struct State { int64_t ts; - base::FlatHashMap callsites; - base::FlatHashMap callsite_inferred_parents; + base::FlatHashMapV2 callsites; + base::FlatHashMapV2 callsite_inferred_parents; DummyMemoryMapping* mapping; }; - base::FlatHashMap, - State, - base::MurmurHash>> + base::FlatHashMapV2, + State, + base::MurmurHash>> state_by_session_and_pid_; TraceProcessorContext* const context_; diff --git a/src/trace_processor/importers/common/mapping_tracker.h b/src/trace_processor/importers/common/mapping_tracker.h index 3402ccfc82..26fd466190 100644 --- a/src/trace_processor/importers/common/mapping_tracker.h +++ b/src/trace_processor/importers/common/mapping_tracker.h @@ -105,12 +105,12 @@ class MappingTracker { MappingImpl& AddMapping(std::unique_ptr mapping); TraceProcessorContext* const context_; - base::FlatHashMap> + base::FlatHashMapV2> mappings_by_id_; - base::FlatHashMap> + base::FlatHashMapV2> interned_mappings_; struct NameAndBuildId { @@ -128,17 +128,17 @@ class MappingTracker { return H::Combine(std::move(h), o.name, o.build_id); } }; - base::FlatHashMap, - base::MurmurHash> + base::FlatHashMapV2, + base::MurmurHash> mappings_by_name_and_build_id_; - base::FlatHashMap> + base::FlatHashMapV2> user_memory_; AddressRangeMap kernel_modules_; KernelMemoryMapping* kernel_ = nullptr; - base::FlatHashMap> jit_caches_; + base::FlatHashMapV2> jit_caches_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/common/process_track_translation_table.h b/src/trace_processor/importers/common/process_track_translation_table.h index 30f5f56d51..6ad658a595 100644 --- a/src/trace_processor/importers/common/process_track_translation_table.h +++ b/src/trace_processor/importers/common/process_track_translation_table.h @@ -47,7 +47,7 @@ class ProcessTrackTranslationTable { private: TraceStorage* storage_; - base::FlatHashMap raw_to_deobfuscated_name_; + base::FlatHashMapV2 raw_to_deobfuscated_name_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/common/process_tracker.h b/src/trace_processor/importers/common/process_tracker.h index 9950d4305b..85bc394c09 100644 --- a/src/trace_processor/importers/common/process_tracker.h +++ b/src/trace_processor/importers/common/process_tracker.h @@ -326,8 +326,8 @@ class ProcessTracker { // callers merge into one set; committed in OnEventsFullyExtracted. The // reference returned by AddArgsTo{Process,Thread} is only valid until the // next such call (the map may rehash); every caller uses it before then. - base::FlatHashMap process_args_; - base::FlatHashMap thread_args_; + base::FlatHashMapV2 process_args_; + base::FlatHashMapV2 thread_args_; // Mapping for tid to the vector of possible UniqueTids. // TODO(lalitm): this is a one-many mapping because this code was written @@ -335,6 +335,9 @@ class ProcessTracker { // simultaneously. This is no longer the case so this should be removed // (though it seems like there are subtle things which break in Chrome if this // changes). + // + // On FlatHashMapV1, as is |live_tid_|: thread lookups hit these on every + // event and FlatHashMapV2 measured slower for them. base::FlatHashMap> tids_; // Cache of the newest alive incarnation of each tid: the answer to a bare @@ -343,10 +346,10 @@ class ProcessTracker { // upid -> its utids, used to refresh live_tid_ when a process ends or its pid // is recycled. - base::FlatHashMap> process_threads_; + base::FlatHashMapV2> process_threads_; // Mapping of the most recently seen pid to the associated upid. - base::FlatHashMap pids_; + base::FlatHashMapV2 pids_; // Pending thread associations. The meaning of a pair in // this vector is: we know that A and B belong to the same process, but we @@ -392,8 +395,8 @@ class ProcessTracker { int32_t value; SortIndexPriority priority; }; - base::FlatHashMap process_sort_indexes_; - base::FlatHashMap thread_sort_indexes_; + base::FlatHashMapV2 process_sort_indexes_; + base::FlatHashMapV2 thread_sort_indexes_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/common/profiler_sample_tracker.h b/src/trace_processor/importers/common/profiler_sample_tracker.h index a38476d89f..d7e9a524d5 100644 --- a/src/trace_processor/importers/common/profiler_sample_tracker.h +++ b/src/trace_processor/importers/common/profiler_sample_tracker.h @@ -88,13 +88,13 @@ class ProfilerSampleTracker { TraceProcessorContext* const context_; int64_t last_ts_ = std::numeric_limits::min(); - base::FlatHashMap> + base::FlatHashMapV2> task_contexts_; - base::FlatHashMap> + base::FlatHashMapV2> execution_contexts_; }; diff --git a/src/trace_processor/importers/common/registered_file_tracker.h b/src/trace_processor/importers/common/registered_file_tracker.h index eef9b42cde..de6b8bc52c 100644 --- a/src/trace_processor/importers/common/registered_file_tracker.h +++ b/src/trace_processor/importers/common/registered_file_tracker.h @@ -50,12 +50,12 @@ class RegisteredFileTracker { void IndexFileType(tables::FileTable::Id file_id, const TraceBlob& content); TraceProcessorContext* context_; - base::FlatHashMap files_by_build_id_; + base::FlatHashMapV2 files_by_build_id_; // Indexed by `tables::FileTable::Id` std::vector file_content_; - base::FlatHashMap files_by_path_; + base::FlatHashMapV2 files_by_path_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/common/slice_tracker.h b/src/trace_processor/importers/common/slice_tracker.h index 8a4e97e137..fe5f666384 100644 --- a/src/trace_processor/importers/common/slice_tracker.h +++ b/src/trace_processor/importers/common/slice_tracker.h @@ -197,6 +197,9 @@ class SliceTracker { uint32_t legacy_unnestable_begin_count = 0; int64_t legacy_unnestable_last_begin_ts = 0; }; + // On FlatHashMapV1: this map is looked up on every slice event and + // FlatHashMapV2, which stores the (large) TrackInfo next to each key, + // measured slower for it. using StackMap = base::FlatHashMap; // Args pending translation. diff --git a/src/trace_processor/importers/common/slice_translation_table.h b/src/trace_processor/importers/common/slice_translation_table.h index bcbad1606d..d42f5993b4 100644 --- a/src/trace_processor/importers/common/slice_translation_table.h +++ b/src/trace_processor/importers/common/slice_translation_table.h @@ -48,7 +48,7 @@ class SliceTranslationTable { private: TraceStorage* storage_; - base::FlatHashMap raw_to_deobfuscated_name_; + base::FlatHashMapV2 raw_to_deobfuscated_name_; }; } // namespace trace_processor diff --git a/src/trace_processor/importers/common/sparse_counter_tracker.h b/src/trace_processor/importers/common/sparse_counter_tracker.h index 2b83299a02..336768797f 100644 --- a/src/trace_processor/importers/common/sparse_counter_tracker.h +++ b/src/trace_processor/importers/common/sparse_counter_tracker.h @@ -63,7 +63,7 @@ class SparseCounterTracker { }; std::unique_ptr> stream_; - base::FlatHashMap track_state_; + base::FlatHashMapV2 track_state_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/common/stack_profile_tracker.h b/src/trace_processor/importers/common/stack_profile_tracker.h index 1490bf5686..120487fcde 100644 --- a/src/trace_processor/importers/common/stack_profile_tracker.h +++ b/src/trace_processor/importers/common/stack_profile_tracker.h @@ -46,8 +46,9 @@ class StackProfileTracker { } }; TraceProcessorContext* const context_; - base::FlatHashMap - callsite_unique_row_index_; + base:: + FlatHashMapV2 + callsite_unique_row_index_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/common/state_tracker.h b/src/trace_processor/importers/common/state_tracker.h index 99379ff263..b72e37dc71 100644 --- a/src/trace_processor/importers/common/state_tracker.h +++ b/src/trace_processor/importers/common/state_tracker.h @@ -59,7 +59,7 @@ class StateTracker { }; TraceProcessorContext* const context_; - base::FlatHashMap active_states_; + base::FlatHashMapV2 active_states_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/common/symbol_tracker.h b/src/trace_processor/importers/common/symbol_tracker.h index 505bfa0760..67fe05efcd 100644 --- a/src/trace_processor/importers/common/symbol_tracker.h +++ b/src/trace_processor/importers/common/symbol_tracker.h @@ -43,7 +43,7 @@ class SymbolTracker { void OnEventsFullyExtracted(); AddressRangeMap& kernel_symbols() { return kernel_symbols_; } - base::FlatHashMap& dsos() { return dsos_; } + base::FlatHashMapV2& dsos() { return dsos_; } private: void SymbolizeKernelFrame(tables::StackProfileFrameTable::RowReference frame); @@ -55,7 +55,7 @@ class SymbolTracker { const tables::StackProfileMappingTable& mapping_table_; AddressRangeMap kernel_symbols_; - base::FlatHashMap dsos_; + base::FlatHashMapV2 dsos_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/common/track_compressor.h b/src/trace_processor/importers/common/track_compressor.h index f12c843c60..4d7b4a53ee 100644 --- a/src/trace_processor/importers/common/track_compressor.h +++ b/src/trace_processor/importers/common/track_compressor.h @@ -432,8 +432,8 @@ class TrackCompressor { return *it; } - base::FlatHashMap> sets_; - base::FlatHashMap> + base::FlatHashMapV2> sets_; + base::FlatHashMapV2> async_tracks_to_root_string_id_; TraceProcessorContext* const context_; diff --git a/src/trace_processor/importers/common/track_tracker.h b/src/trace_processor/importers/common/track_tracker.h index a17d16fcdb..99e1a8bcd8 100644 --- a/src/trace_processor/importers/common/track_tracker.h +++ b/src/trace_processor/importers/common/track_tracker.h @@ -237,6 +237,8 @@ class TrackTracker { base::ignore_result(dimensions_schema); } + // On FlatHashMapV1: interning a track looks it up here on every event, and + // FlatHashMapV2 measured slower for it. base::FlatHashMap> tracks_; TraceProcessorContext* const context_; diff --git a/src/trace_processor/importers/common/virtual_memory_mapping.h b/src/trace_processor/importers/common/virtual_memory_mapping.h index 926d796bcc..6316c8731a 100644 --- a/src/trace_processor/importers/common/virtual_memory_mapping.h +++ b/src/trace_processor/importers/common/virtual_memory_mapping.h @@ -148,9 +148,9 @@ class VirtualMemoryMapping { return H::Combine(std::move(h), k.rel_pc, k.name_id); } }; - base::FlatHashMap> + base::FlatHashMapV2> interned_frames_; - base::FlatHashMap> frames_by_rel_pc_; + base::FlatHashMapV2> frames_by_rel_pc_; }; class KernelMemoryMapping : public VirtualMemoryMapping { @@ -213,7 +213,7 @@ class DummyMemoryMapping : public VirtualMemoryMapping { k.line_number); } }; - base::FlatHashMap> + base::FlatHashMapV2> interned_dummy_frames_; }; diff --git a/src/trace_processor/importers/etm/error_logger.h b/src/trace_processor/importers/etm/error_logger.h index faa49cc46b..53767ba6e6 100644 --- a/src/trace_processor/importers/etm/error_logger.h +++ b/src/trace_processor/importers/etm/error_logger.h @@ -71,7 +71,7 @@ class ErrorLogger : public ITraceErrorLog { std::vector components_; std::optional last_error_; - base::FlatHashMap last_error_by_channel_id_; + base::FlatHashMapV2 last_error_by_channel_id_; }; } // namespace perfetto::trace_processor::etm diff --git a/src/trace_processor/importers/etm/etm_tracker.h b/src/trace_processor/importers/etm/etm_tracker.h index 7cd23679d8..36a8650475 100644 --- a/src/trace_processor/importers/etm/etm_tracker.h +++ b/src/trace_processor/importers/etm/etm_tracker.h @@ -34,7 +34,7 @@ namespace perfetto::trace_processor::etm { class Configuration; using PerCpuConfiguration = - base::FlatHashMap>; + base::FlatHashMapV2>; class EtmTracker : public Destructible { public: diff --git a/src/trace_processor/importers/etm/etm_v4_stream_demultiplexer.cc b/src/trace_processor/importers/etm/etm_v4_stream_demultiplexer.cc index 7d84ba5497..a8cf2d1c65 100644 --- a/src/trace_processor/importers/etm/etm_v4_stream_demultiplexer.cc +++ b/src/trace_processor/importers/etm/etm_v4_stream_demultiplexer.cc @@ -304,7 +304,7 @@ class EtmV4StreamDemultiplexer : public perf_importer::AuxDataTokenizer { std::unique_ptr etm_tracker_; FrameDecoder decoder_; - base::FlatHashMap> streams_; + base::FlatHashMapV2> streams_; }; } // namespace diff --git a/src/trace_processor/importers/etm/target_memory.cc b/src/trace_processor/importers/etm/target_memory.cc index 3b1b7d1d9c..230dea6b80 100644 --- a/src/trace_processor/importers/etm/target_memory.cc +++ b/src/trace_processor/importers/etm/target_memory.cc @@ -52,7 +52,7 @@ TargetMemory::TargetMemory(TraceProcessorContext* context) {}, }})) { auto kernel = VirtualAddressSpace::Builder(context); - base::FlatHashMap user; + base::FlatHashMapV2 user; const auto& table = context->storage->mmap_record_table(); for (auto mmap = table.IterateRows(); mmap; ++mmap) { diff --git a/src/trace_processor/importers/etm/target_memory.h b/src/trace_processor/importers/etm/target_memory.h index 9460246002..f3fc7fb0ba 100644 --- a/src/trace_processor/importers/etm/target_memory.h +++ b/src/trace_processor/importers/etm/target_memory.h @@ -73,11 +73,11 @@ class TargetMemory : public Destructible { // Kernel memory is shared by all processes. VirtualAddressSpace kernel_memory_; - base::FlatHashMap user_memory_; + base::FlatHashMapV2 user_memory_; // Cache for quick tid -> upid lookups. // TODO(carlscab): This should probably live in `ProcessTracker` - mutable base::FlatHashMap tid_to_space_; + mutable base::FlatHashMapV2 tid_to_space_; }; } // namespace etm diff --git a/src/trace_processor/importers/ftrace/binder_tracker.h b/src/trace_processor/importers/ftrace/binder_tracker.h index 5912904df6..78fef82228 100644 --- a/src/trace_processor/importers/ftrace/binder_tracker.h +++ b/src/trace_processor/importers/ftrace/binder_tracker.h @@ -119,7 +119,7 @@ class BinderTracker : public Destructible { std::optional txn_info; }; // Each thread can have a stack of multiple transactions. - base::FlatHashMap> utid_stacks_; + base::FlatHashMapV2> utid_stacks_; // Returns the current state of this thread or nullptr, if the thread doesn't // have a binder state. @@ -132,8 +132,8 @@ class BinderTracker : public Destructible { // returned TxnFrame*. void PopTidFrame(uint32_t tid); - base::FlatHashMap attempt_lock_; - base::FlatHashMap lock_acquired_; + base::FlatHashMapV2 attempt_lock_; + base::FlatHashMapV2 lock_acquired_; const StringId binder_category_id_; const StringId lock_waiting_id_; diff --git a/src/trace_processor/importers/ftrace/drm_tracker.h b/src/trace_processor/importers/ftrace/drm_tracker.h index d0eed1c8b6..b968dd6724 100644 --- a/src/trace_processor/importers/ftrace/drm_tracker.h +++ b/src/trace_processor/importers/ftrace/drm_tracker.h @@ -162,7 +162,7 @@ class DrmTracker { std::deque running_jobs; // Map queued jobs to their slice ids on the thread track. - base::FlatHashMap out_slice_ids; + base::FlatHashMapV2 out_slice_ids; }; SchedRing& GetSchedRingByName(base::StringView name); @@ -223,13 +223,15 @@ class DrmTracker { const StringId fence_arg_seqno_id_; // Map scheduler ring names to SchedRings. - base::FlatHashMap> sched_rings_; + base::FlatHashMapV2> + sched_rings_; // Map running jobs to SchedRings. - base::FlatHashMap + base::FlatHashMapV2 sched_busy_rings_; // Map dma-fence contexts to FenceTimelines. - base::FlatHashMap> fence_timelines_; + base::FlatHashMapV2> + fence_timelines_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/ftrace/ftrace_parser.h b/src/trace_processor/importers/ftrace/ftrace_parser.h index 9683ea04a4..7ec51e6d37 100644 --- a/src/trace_processor/importers/ftrace/ftrace_parser.h +++ b/src/trace_processor/importers/ftrace/ftrace_parser.h @@ -468,7 +468,7 @@ class FtraceParser { const StringId gpu_power_state_pg_id_; const StringId gpu_power_state_on_id_; - base::FlatHashMap adreno_cmdbatch_ctx_tids_; + base::FlatHashMapV2 adreno_cmdbatch_ctx_tids_; const StringId gpu_cmdbatch_slice_name_id_; const StringId ddic_underrun_id_; @@ -514,7 +514,7 @@ class FtraceParser { uint64_t nr_reclaimed = 0; uint64_t nr_mapped = 0; }; - base::FlatHashMap utid_to_cma_migration_info_; + base::FlatHashMapV2 utid_to_cma_migration_info_; // Record number of kfree_skb with ip protocol. uint64_t num_of_kfree_skb_ip_prot = 0; @@ -572,7 +572,7 @@ class FtraceParser { } }; - base::FlatHashMap, uint32_t, PairHash> + base::FlatHashMapV2, uint32_t, PairHash> inode_offset_thread_map_; }; diff --git a/src/trace_processor/importers/ftrace/ftrace_tokenizer.h b/src/trace_processor/importers/ftrace/ftrace_tokenizer.h index b0bb70699f..c50681571c 100644 --- a/src/trace_processor/importers/ftrace/ftrace_tokenizer.h +++ b/src/trace_processor/importers/ftrace/ftrace_tokenizer.h @@ -129,7 +129,7 @@ class FtraceTokenizer { int64_t trace_ts; uint64_t gpu_ticks; }; - base::FlatHashMap + base::FlatHashMapV2 adreno_cmdbatch_sync_points_; // Buffer retired event when its matching sync hasn't been seen yet, so @@ -143,7 +143,7 @@ class FtraceTokenizer { TraceBlobView event; RefPtr state; }; - base::FlatHashMap + base::FlatHashMapV2 pending_adreno_cmdbatch_retired_; int64_t latest_ftrace_clock_snapshot_ts_ = 0; diff --git a/src/trace_processor/importers/ftrace/generic_ftrace_tracker.h b/src/trace_processor/importers/ftrace/generic_ftrace_tracker.h index 99ab9e9f65..f6b6690397 100644 --- a/src/trace_processor/importers/ftrace/generic_ftrace_tracker.h +++ b/src/trace_processor/importers/ftrace/generic_ftrace_tracker.h @@ -115,9 +115,9 @@ class GenericFtraceTracker { TraceProcessorContext* const context_; // keyed by proto field id inside the FtraceEvent proto - base::FlatHashMap events_; + base::FlatHashMapV2 events_; // keyed by proto field id inside the FtraceEvent proto, subset of the above - base::FlatHashMap track_event_info_; + base::FlatHashMapV2 track_event_info_; const StringId track_event_type_; const StringId slice_name_; diff --git a/src/trace_processor/importers/ftrace/rss_stat_tracker.h b/src/trace_processor/importers/ftrace/rss_stat_tracker.h index 5beb179ca0..7ac2f19d77 100644 --- a/src/trace_processor/importers/ftrace/rss_stat_tracker.h +++ b/src/trace_processor/importers/ftrace/rss_stat_tracker.h @@ -50,7 +50,7 @@ class RssStatTracker { bool is_curr, uint32_t pid); - base::FlatHashMap mm_id_to_utid_; + base::FlatHashMapV2 mm_id_to_utid_; TraceProcessorContext* const context_; }; diff --git a/src/trace_processor/importers/ftrace/v4l2_tracker.h b/src/trace_processor/importers/ftrace/v4l2_tracker.h index 45912987a2..b74b50abb1 100644 --- a/src/trace_processor/importers/ftrace/v4l2_tracker.h +++ b/src/trace_processor/importers/ftrace/v4l2_tracker.h @@ -162,7 +162,7 @@ class V4l2Tracker : public Destructible { StringId InternTcFlags(uint32_t flags); TraceProcessorContext* const context_; - base::FlatHashMap queued_buffers_; + base::FlatHashMapV2 queued_buffers_; BufferEventStringIds buf_event_ids_; BufferTypeStringIds buf_type_ids_; diff --git a/src/trace_processor/importers/ftrace/virtio_gpu_tracker.h b/src/trace_processor/importers/ftrace/virtio_gpu_tracker.h index 621e9e7904..2c701fe240 100644 --- a/src/trace_processor/importers/ftrace/virtio_gpu_tracker.h +++ b/src/trace_processor/importers/ftrace/virtio_gpu_tracker.h @@ -58,7 +58,7 @@ class VirtioGpuTracker { // can be matched up via their seqno field. To calculate the slice // duration we need to lookup the timestamp of the matching CmdQueue // event when we get the CmdResponse event. - base::FlatHashMap start_timestamps_; + base::FlatHashMapV2 start_timestamps_; }; VirtioGpuQueue virtgpu_control_queue_; diff --git a/src/trace_processor/importers/ftrace/virtio_video_tracker.h b/src/trace_processor/importers/ftrace/virtio_video_tracker.h index 74989913d1..c141e95b35 100644 --- a/src/trace_processor/importers/ftrace/virtio_video_tracker.h +++ b/src/trace_processor/importers/ftrace/virtio_video_tracker.h @@ -75,7 +75,7 @@ class VirtioVideoTracker : public Destructible { StringId output_queue_id_; FieldsStringIds fields_string_ids_; - base::FlatHashMap command_names_; + base::FlatHashMapV2 command_names_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/fuchsia/fuchsia_trace_parser.h b/src/trace_processor/importers/fuchsia/fuchsia_trace_parser.h index f75241ff90..6393552e02 100644 --- a/src/trace_processor/importers/fuchsia/fuchsia_trace_parser.h +++ b/src/trace_processor/importers/fuchsia/fuchsia_trace_parser.h @@ -154,12 +154,12 @@ class FuchsiaTraceParser uint64_t fuchsia_global_flow_id_counter_ = 1; // Maps a process-scoped Fuchsia flow identifier to its globally unique ID. - base::FlatHashMap + base::FlatHashMapV2 fuchsia_active_flows_; // Maps a correlation ID to its global flow info. // Used for cross-process flow resolution. - base::FlatHashMap fuchsia_global_flows_; + base::FlatHashMapV2 fuchsia_global_flows_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/gecko/gecko_trace_tokenizer.h b/src/trace_processor/importers/gecko/gecko_trace_tokenizer.h index 74e05833e1..2e5e39ec56 100644 --- a/src/trace_processor/importers/gecko/gecko_trace_tokenizer.h +++ b/src/trace_processor/importers/gecko/gecko_trace_tokenizer.h @@ -88,7 +88,7 @@ class GeckoTraceTokenizer : public ChunkedTraceReader { // Shared across all threads to avoid creating duplicate mappings. DummyMemoryMapping* dummy_mapping_ = nullptr; - base::FlatHashMap mappings_; + base::FlatHashMapV2 mappings_; }; } // namespace perfetto::trace_processor::gecko_importer diff --git a/src/trace_processor/importers/i2c/i2c_tracker.h b/src/trace_processor/importers/i2c/i2c_tracker.h index 0720160b68..9d38d1c162 100644 --- a/src/trace_processor/importers/i2c/i2c_tracker.h +++ b/src/trace_processor/importers/i2c/i2c_tracker.h @@ -65,7 +65,7 @@ class I2cTracker : public Destructible { // In-flight I2C operation counts per I2C adapter per Unique TID. This is // used to match an i2c_result message against the i2c_read and i2c_write // messages that precede it in the transaction. - base::FlatHashMap> + base::FlatHashMapV2> inflight_i2c_ops_; }; diff --git a/src/trace_processor/importers/instruments/row_parser.h b/src/trace_processor/importers/instruments/row_parser.h index a6d4ef4eac..e3caa92a64 100644 --- a/src/trace_processor/importers/instruments/row_parser.h +++ b/src/trace_processor/importers/instruments/row_parser.h @@ -47,8 +47,8 @@ class RowParser // Cache binary mappings by instruments binary pointers. These are already // de-duplicated in the instruments XML parsing. - base::FlatHashMap binary_to_mapping_; - base::FlatHashMap dummy_mappings_; + base::FlatHashMapV2 binary_to_mapping_; + base::FlatHashMapV2 dummy_mappings_; }; } // namespace perfetto::trace_processor::instruments_importer diff --git a/src/trace_processor/importers/perf/aux_stream_manager.h b/src/trace_processor/importers/perf/aux_stream_manager.h index 9a11f8a28d..e0c41bd9de 100644 --- a/src/trace_processor/importers/perf/aux_stream_manager.h +++ b/src/trace_processor/importers/perf/aux_stream_manager.h @@ -159,7 +159,7 @@ class AuxStreamManager { PerfTracker* const perf_tracker_; std::unique_ptr tokenizer_; - base::FlatHashMap> + base::FlatHashMapV2> auxdata_streams_by_cpu_; std::optional time_conv_; }; diff --git a/src/trace_processor/importers/perf/features.h b/src/trace_processor/importers/perf/features.h index 85a6a6f5c2..80cfe5f225 100644 --- a/src/trace_processor/importers/perf/features.h +++ b/src/trace_processor/importers/perf/features.h @@ -102,7 +102,7 @@ struct EventDescription { struct SimpleperfMetaInfo { static base::Status Parse(const TraceBlobView&, SimpleperfMetaInfo& out); - base::FlatHashMap entries; + base::FlatHashMapV2 entries; struct EventTypeAndConfig { uint32_t type; uint64_t config; @@ -118,9 +118,9 @@ struct SimpleperfMetaInfo { } }; using EventName = std::string; - base::FlatHashMap> + base::FlatHashMapV2> event_type_info; }; diff --git a/src/trace_processor/importers/perf/perf_event_attr.h b/src/trace_processor/importers/perf/perf_event_attr.h index cfbecbecbb..3bc7d20bd3 100644 --- a/src/trace_processor/importers/perf/perf_event_attr.h +++ b/src/trace_processor/importers/perf/perf_event_attr.h @@ -147,13 +147,14 @@ class PerfEventAttr : public RefCounted { std::optional global_counter_; // Keyed by cpu index. Per-cpu counters (pid == -1, cpu >= 0). - base::FlatHashMap> cpu_counters_; + base::FlatHashMapV2> cpu_counters_; // Keyed by utid. Per-thread counters (pid >= 0, cpu == -1). - base::FlatHashMap> thread_counters_; + base::FlatHashMapV2> thread_counters_; // Keyed by (utid, cpu). Per-(thread, cpu) counters (pid >= 0, cpu >= 0). - base::FlatHashMap, std::optional> + base::FlatHashMapV2, + std::optional> thread_cpu_counters_; std::string event_name_; diff --git a/src/trace_processor/importers/perf/perf_invocation.cc b/src/trace_processor/importers/perf/perf_invocation.cc index ea2dc324fa..c58d9a0118 100644 --- a/src/trace_processor/importers/perf/perf_invocation.cc +++ b/src/trace_processor/importers/perf/perf_invocation.cc @@ -89,7 +89,7 @@ base::StatusOr> PerfInvocation::Builder::Build() { } RefPtr first_attr; - base::FlatHashMap> attrs_by_id; + base::FlatHashMapV2> attrs_by_id; for (const auto& entry : attr_with_ids_) { // Assign a distinct sampling stream id to each event description. Note: at // the time of writing, we do not correctly re-group the events if the @@ -255,7 +255,7 @@ void PerfInvocation::SetCmdline(const std::vector& args) { } void PerfInvocation::SetSimpleperfCounterScope( - const base::FlatHashMap& entries) { + const base::FlatHashMapV2& entries) { // perf_event_attr does not store the target pid/cpu passed to // perf_event_open. While Linux perf emits PERF_RECORD_ID_INDEX to map each // event ID to its (tid, cpu), simpleperf omits PERF_RECORD_ID_INDEX and diff --git a/src/trace_processor/importers/perf/perf_invocation.h b/src/trace_processor/importers/perf/perf_invocation.h index 9fc3033b31..0ae974df79 100644 --- a/src/trace_processor/importers/perf/perf_invocation.h +++ b/src/trace_processor/importers/perf/perf_invocation.h @@ -88,7 +88,7 @@ class PerfInvocation : public RefCounted { void SetIsSimpleperf() { is_simpleperf_ = true; } void SetSimpleperfCounterScope( - const base::FlatHashMap& entries); + const base::FlatHashMapV2& entries); bool HasPerfClock() const; @@ -108,10 +108,11 @@ class PerfInvocation : public RefCounted { } }; - PerfInvocation(TraceProcessorContext* context, - RefPtr first_attr, - base::FlatHashMap> attrs_by_id, - bool has_single_perf_event_attr) + PerfInvocation( + TraceProcessorContext* context, + RefPtr first_attr, + base::FlatHashMapV2> attrs_by_id, + bool has_single_perf_event_attr) : context_(context), first_attr_(std::move(first_attr)), attrs_by_id_(std::move(attrs_by_id)), @@ -123,7 +124,7 @@ class PerfInvocation : public RefCounted { TraceProcessorContext* const context_; RefPtr first_attr_; - base::FlatHashMap> attrs_by_id_; + base::FlatHashMapV2> attrs_by_id_; // Multiple ids can map to the same perf_event_attr. This member tells us // whether there was only one perf_event_attr (with potentially different ids @@ -133,7 +134,7 @@ class PerfInvocation : public RefCounted { bool is_simpleperf_ = false; - base::FlatHashMap> + base::FlatHashMapV2> build_ids_; }; diff --git a/src/trace_processor/importers/perf/perf_tracker.h b/src/trace_processor/importers/perf/perf_tracker.h index d76c6bde40..5283c256db 100644 --- a/src/trace_processor/importers/perf/perf_tracker.h +++ b/src/trace_processor/importers/perf/perf_tracker.h @@ -71,7 +71,7 @@ class PerfTracker { TraceProcessorContext* const context_; - base::FlatHashMap factories_; + base::FlatHashMapV2 factories_; }; } // namespace perfetto::trace_processor::perf_importer diff --git a/src/trace_processor/importers/perf/record_parser.h b/src/trace_processor/importers/perf/record_parser.h index 3788a3429d..6a3b06b31d 100644 --- a/src/trace_processor/importers/perf/record_parser.h +++ b/src/trace_processor/importers/perf/record_parser.h @@ -81,7 +81,7 @@ class RecordParser : public TraceSorter::Sink { PerfTracker* const perf_tracker_; MappingTracker* const mapping_tracker_; const StringPool::Id linux_perf_source_id_; - base::FlatHashMap dummy_mappings_; + base::FlatHashMapV2 dummy_mappings_; }; } // namespace perf_importer diff --git a/src/trace_processor/importers/pprof/pprof_trace_reader.cc b/src/trace_processor/importers/pprof/pprof_trace_reader.cc index aa9287309f..0513a8c10b 100644 --- a/src/trace_processor/importers/pprof/pprof_trace_reader.cc +++ b/src/trace_processor/importers/pprof/pprof_trace_reader.cc @@ -124,7 +124,7 @@ base::Status PprofTraceReader::ParseProfile() { }; // Parse mappings and create VirtualMemoryMapping objects - base::FlatHashMap mappings; + base::FlatHashMapV2 mappings; for (auto it = profile.mapping(); it; ++it) { const Mapping::Decoder mapping_decoder(*it); if (!mapping_decoder.has_id()) { @@ -155,7 +155,7 @@ base::Status PprofTraceReader::ParseProfile() { } // Parse functions with source file and line information - base::FlatHashMap functions; + base::FlatHashMapV2 functions; for (auto it = profile.function(); it; ++it) { const Function::Decoder func_decoder(*it); if (!func_decoder.has_id()) { @@ -171,7 +171,7 @@ base::Status PprofTraceReader::ParseProfile() { } // Parse locations and create frames - base::FlatHashMap location_to_frame; + base::FlatHashMapV2 location_to_frame; for (auto it = profile.location(); it; ++it) { const Location::Decoder loc_decoder(*it); if (!loc_decoder.has_id()) { diff --git a/src/trace_processor/importers/primes/primes_trace_parser.h b/src/trace_processor/importers/primes/primes_trace_parser.h index a2c0dcd2be..95077d100f 100644 --- a/src/trace_processor/importers/primes/primes_trace_parser.h +++ b/src/trace_processor/importers/primes/primes_trace_parser.h @@ -38,7 +38,7 @@ class PrimesTraceParser private: TraceProcessorContext* const context_; - base::FlatHashMap edge_to_executor_map_; + base::FlatHashMapV2 edge_to_executor_map_; void HandleSliceBegin(int64_t ts, primespb::TraceEdge::Decoder& edge_decoder); void HandleSliceEnd(int64_t ts, primespb::TraceEdge::Decoder& edge_decoder); diff --git a/src/trace_processor/importers/proto/active_chrome_processes_tracker.h b/src/trace_processor/importers/proto/active_chrome_processes_tracker.h index 2b36f2c950..33e6ede158 100644 --- a/src/trace_processor/importers/proto/active_chrome_processes_tracker.h +++ b/src/trace_processor/importers/proto/active_chrome_processes_tracker.h @@ -57,7 +57,7 @@ class ActiveChromeProcessesTracker { }; TraceProcessorContext* context_; - base::FlatHashMap process_data_; + base::FlatHashMapV2 process_data_; // Metadata timestamps across all processes. std::set global_metadata_timestamps_; }; diff --git a/src/trace_processor/importers/proto/android_cpu_per_uid_module.h b/src/trace_processor/importers/proto/android_cpu_per_uid_module.h index 9e24a038e0..6271587125 100644 --- a/src/trace_processor/importers/proto/android_cpu_per_uid_module.h +++ b/src/trace_processor/importers/proto/android_cpu_per_uid_module.h @@ -64,16 +64,16 @@ class AndroidCpuPerUidModule : public ProtoImporterModule { TraceProcessorContext* context_; // Last cpu duration per uid/cluster (key is uid << 32 | cluster). - base::FlatHashMap last_value_; + base::FlatHashMapV2 last_value_; // Cumulative duration per uid/cluster (key is uid << 32 | cluster). - base::FlatHashMap cumulative_; + base::FlatHashMapV2 cumulative_; // Map from cluster to total cumulative app (uid >= 10000) duration. - base::FlatHashMap app_totals_; + base::FlatHashMapV2 app_totals_; // Map from cluster to total cumulative system (uid < 10000) duration. - base::FlatHashMap system_totals_; + base::FlatHashMapV2 system_totals_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/proto/android_cpu_per_uid_state.h b/src/trace_processor/importers/proto/android_cpu_per_uid_state.h index 0dba720ee9..e6cd92e84c 100644 --- a/src/trace_processor/importers/proto/android_cpu_per_uid_state.h +++ b/src/trace_processor/importers/proto/android_cpu_per_uid_state.h @@ -35,7 +35,7 @@ struct AndroidCpuPerUidState : PacketSequenceStateGeneration::CustomState { uint32_t cluster_count; // Key is 32 bits of UID in MSB, 32 bits cluster in LSB. - base::FlatHashMap last_values; + base::FlatHashMapV2 last_values; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/proto/android_kernel_wakelocks_state.h b/src/trace_processor/importers/proto/android_kernel_wakelocks_state.h index ccde625a8c..95cddea0a8 100644 --- a/src/trace_processor/importers/proto/android_kernel_wakelocks_state.h +++ b/src/trace_processor/importers/proto/android_kernel_wakelocks_state.h @@ -43,8 +43,8 @@ struct AndroidKernelWakelockState : PacketSequenceStateGeneration::CustomState { explicit AndroidKernelWakelockState(TraceProcessorContext*); ~AndroidKernelWakelockState() override; - base::FlatHashMap wakelocks; - base::FlatHashMap wakelock_last_values; + base::FlatHashMapV2 wakelocks; + base::FlatHashMapV2 wakelock_last_values; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/proto/content_analyzer.cc b/src/trace_processor/importers/proto/content_analyzer.cc index a0f0e49221..cae5fdcdee 100644 --- a/src/trace_processor/importers/proto/content_analyzer.cc +++ b/src/trace_processor/importers/proto/content_analyzer.cc @@ -61,9 +61,9 @@ void ProtoContentAnalyzer::OnEventsFullyExtracted() { // Perfetto UI supports custom flamegraphs (b/227644078). for (auto annotated_map = aggregated_samples_.GetIterator(); annotated_map; ++annotated_map) { - base::FlatHashMap> + base::FlatHashMapV2> path_ids; for (auto sample = annotated_map.value().GetIterator(); sample; ++sample) { std::string path_string; diff --git a/src/trace_processor/importers/proto/content_analyzer.h b/src/trace_processor/importers/proto/content_analyzer.h index 5d249b421b..ba6e405246 100644 --- a/src/trace_processor/importers/proto/content_analyzer.h +++ b/src/trace_processor/importers/proto/content_analyzer.h @@ -36,10 +36,10 @@ class ProtoContentAnalyzer : public PacketAnalyzer { size_t size; size_t count; }; - using PathToSamplesMap = - base::FlatHashMap>; + using PathToSamplesMap = base::FlatHashMapV2< + util::SizeProfileComputer::FieldPath, + Sample, + base::MurmurHash>; using SampleAnnotation = PacketAnalyzer::SampleAnnotation; struct SampleAnnotationHasher { @@ -56,7 +56,7 @@ class ProtoContentAnalyzer : public PacketAnalyzer { } }; using AnnotatedSamplesMap = base:: - FlatHashMap; + FlatHashMapV2; explicit ProtoContentAnalyzer(TraceProcessorContext* context); ~ProtoContentAnalyzer() override; diff --git a/src/trace_processor/importers/proto/deobfuscation_module.cc b/src/trace_processor/importers/proto/deobfuscation_module.cc index 402ffc3005..b6f25c1898 100644 --- a/src/trace_processor/importers/proto/deobfuscation_module.cc +++ b/src/trace_processor/importers/proto/deobfuscation_module.cc @@ -68,7 +68,7 @@ void DeobfuscationModule::BuildMappingTableIncremental( for (auto class_it = mapping.obfuscated_classes(); class_it; ++class_it) { protos::pbzero::ObfuscatedClass::Decoder cls(*class_it); - base::FlatHashMap members; + base::FlatHashMapV2 members; for (auto member_it = cls.obfuscated_methods(); member_it; ++member_it) { protos::pbzero::ObfuscatedMember::Decoder member(*member_it); members[context_->storage->InternString(member.obfuscated_name())] = diff --git a/src/trace_processor/importers/proto/deobfuscation_tracker.cc b/src/trace_processor/importers/proto/deobfuscation_tracker.cc index f6b9222d21..e1fbde29f1 100644 --- a/src/trace_processor/importers/proto/deobfuscation_tracker.cc +++ b/src/trace_processor/importers/proto/deobfuscation_tracker.cc @@ -175,7 +175,7 @@ void DeobfuscationTracker::DeobfuscateProfiles( std::optional obfuscated_line_end; std::optional source_line_start; }; - base::FlatHashMap> method_mappings; + base::FlatHashMapV2> method_mappings; for (auto class_it = deobfuscation_mapping.obfuscated_classes(); class_it; ++class_it) { diff --git a/src/trace_processor/importers/proto/deobfuscation_tracker.h b/src/trace_processor/importers/proto/deobfuscation_tracker.h index 20f4150247..86abb7c334 100644 --- a/src/trace_processor/importers/proto/deobfuscation_tracker.h +++ b/src/trace_processor/importers/proto/deobfuscation_tracker.h @@ -54,7 +54,7 @@ class DeobfuscationTracker : public Destructible { std::vector frames; }; using JavaFrameMap = - base::FlatHashMap>; + base::FlatHashMapV2>; static void AddJavaFrame(JavaFrameMap& java_frames_for_name, StringId name, diff --git a/src/trace_processor/importers/proto/frame_timeline_event_parser.h b/src/trace_processor/importers/proto/frame_timeline_event_parser.h index c7b1469a3e..a851f14b19 100644 --- a/src/trace_processor/importers/proto/frame_timeline_event_parser.h +++ b/src/trace_processor/importers/proto/frame_timeline_event_parser.h @@ -73,7 +73,7 @@ class FrameTimelineEventParser { // Cookie -> TrackType map. Since cookies are globally unique per slice, this // helps in allowing the producer to send only the cookie as the End marker // without the need for any other fields. - base::FlatHashMap> cookie_map_; + base::FlatHashMapV2> cookie_map_; std::array present_type_ids_; std::array present_type_experimental_ids_; diff --git a/src/trace_processor/importers/proto/gpu_counter_sequence_state.h b/src/trace_processor/importers/proto/gpu_counter_sequence_state.h index 696167e86a..eaf2b8c1e5 100644 --- a/src/trace_processor/importers/proto/gpu_counter_sequence_state.h +++ b/src/trace_processor/importers/proto/gpu_counter_sequence_state.h @@ -49,7 +49,7 @@ struct GpuCounterSequenceState : PacketSequenceStateGeneration::CustomState { // Key: counter_descriptor_iid. Value: per-descriptor map of counter_id -> // track info. Presence of an iid key means the descriptor has already been // parsed (tracks interned, groups inserted) at tokenization time. - base::FlatHashMap> + base::FlatHashMapV2> descriptors; }; diff --git a/src/trace_processor/importers/proto/gpu_event_parser.cc b/src/trace_processor/importers/proto/gpu_event_parser.cc index 7e9aeba583..3d6642b437 100644 --- a/src/trace_processor/importers/proto/gpu_event_parser.cc +++ b/src/trace_processor/importers/proto/gpu_event_parser.cc @@ -383,7 +383,7 @@ void GpuEventParser::InsertCounterGroups( void GpuEventParser::InsertCustomCounterGroups( const GpuCounterDescriptor::Decoder& desc, - const base::FlatHashMap& counter_id_to_track) { + const base::FlatHashMapV2& counter_id_to_track) { for (auto group_it = desc.counter_groups(); group_it; ++group_it) { GpuCounterDescriptor::GpuCounterGroupSpec::Decoder group(*group_it); if (!group.has_group_id()) { diff --git a/src/trace_processor/importers/proto/gpu_event_parser.h b/src/trace_processor/importers/proto/gpu_event_parser.h index dbc495dfec..1721324e92 100644 --- a/src/trace_processor/importers/proto/gpu_event_parser.h +++ b/src/trace_processor/importers/proto/gpu_event_parser.h @@ -73,9 +73,9 @@ class GpuEventParser { StringId name; StringId description; }; - using GroupMetadataMap = base::FlatHashMap; + using GroupMetadataMap = base::FlatHashMapV2; using CounterTrackMap = - base::FlatHashMap; + base::FlatHashMapV2; TrackId InternGpuCounterTrack( int32_t gpu_id, const protos::pbzero::GpuCounterDescriptor::GpuCounterSpec::Decoder& @@ -88,7 +88,7 @@ class GpuEventParser { const GroupMetadataMap& group_metadata); void InsertCustomCounterGroups( const protos::pbzero::GpuCounterDescriptor::Decoder& desc, - const base::FlatHashMap& counter_id_to_track); + const base::FlatHashMapV2& counter_id_to_track); // Pushes the sample values of a GpuCounterEvent at parse time, using an // already-resolved counter_id -> track mapping (built at tokenization time). @@ -162,7 +162,7 @@ class GpuEventParser { // Track-level last_id for GPU counters. Used by both the interned and the // legacy inline descriptor paths when pushing samples. Key: TrackId. - base::FlatHashMap> + base::FlatHashMapV2> gpu_counter_last_id_; // For GpuRenderStageEvent @@ -184,7 +184,7 @@ class GpuEventParser { const StringId description_id_; const StringId correlation_id_; std::vector> gpu_hw_queue_ids_; - base::FlatHashMap gpu_hw_queue_ids_name_to_set_; + base::FlatHashMapV2 gpu_hw_queue_ids_name_to_set_; void ParseExtraComputeArg(PacketSequenceStateGeneration* sequence_state, protozero::ConstBytes bytes, @@ -204,7 +204,7 @@ class GpuEventParser { std::vector> gpu_render_stage_ids_; // Graphics contexts already inserted into gpu_context table. - base::FlatHashMap gpu_contexts_inserted_; + base::FlatHashMapV2 gpu_contexts_inserted_; // For VulkanMemoryEvent std::unordered_mapgpu_id(); auto group_metadata = parser_.BuildGroupMetadata(desc); - base::FlatHashMap + base::FlatHashMapV2 counter_map; - base::FlatHashMap counter_id_to_track; + base::FlatHashMapV2 counter_id_to_track; for (auto spec_it = desc.specs(); spec_it; ++spec_it) { GpuCounterDescriptor::GpuCounterSpec::Decoder spec(*spec_it); if (!spec.has_counter_id() || !spec.has_name()) { @@ -157,7 +157,7 @@ void GraphicsEventModule::TokenizeGpuCounterEvent( if (event.has_counter_descriptor()) { GpuCounterDescriptor::Decoder descriptor(event.counter_descriptor()); auto group_metadata = parser_.BuildGroupMetadata(descriptor); - base::FlatHashMap counter_id_to_track; + base::FlatHashMapV2 counter_id_to_track; for (auto it = descriptor.specs(); it; ++it) { GpuCounterDescriptor::GpuCounterSpec::Decoder spec(*it); if (!spec.has_counter_id()) { diff --git a/src/trace_processor/importers/proto/graphics_frame_event_parser.h b/src/trace_processor/importers/proto/graphics_frame_event_parser.h index 563365f151..acd26c1e03 100644 --- a/src/trace_processor/importers/proto/graphics_frame_event_parser.h +++ b/src/trace_processor/importers/proto/graphics_frame_event_parser.h @@ -96,13 +96,13 @@ class GraphicsFrameEventParser { std::array event_type_name_ids_; // Map of (buffer ID + layer name) -> BufferEvent - base::FlatHashMap buffer_event_map_; + base::FlatHashMapV2 buffer_event_map_; // Maps of (buffer id + layer name) -> track id - base::FlatHashMap phase_event_map_; + base::FlatHashMapV2 phase_event_map_; // Map of layer name -> track id - base::FlatHashMap display_map_; + base::FlatHashMapV2 display_map_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/proto/heap_graph_tracker.h b/src/trace_processor/importers/proto/heap_graph_tracker.h index 17ea750620..83808e7d3e 100644 --- a/src/trace_processor/importers/proto/heap_graph_tracker.h +++ b/src/trace_processor/importers/proto/heap_graph_tracker.h @@ -200,13 +200,13 @@ class HeapGraphTracker : public Destructible { std::map interned_types; std::map interned_location_names; - base::FlatHashMap + base::FlatHashMapV2 object_id_to_db_row; - base::FlatHashMap + base::FlatHashMapV2 type_id_to_db_row; std::map> references_for_field_name_id; - base::FlatHashMap interned_fields; + base::FlatHashMapV2 interned_fields; std::map> deferred_reference_objects_for_type_; @@ -269,9 +269,9 @@ class HeapGraphTracker : public Destructible { tables::HeapGraphReferenceTable::Cursor referred_cursor_; tables::HeapGraphTable::Cursor heap_graph_cursor_; - base::FlatHashMap> class_to_rows_; - base::FlatHashMap> + base::FlatHashMapV2> class_to_rows_; + base::FlatHashMapV2> field_to_rows_; StringId cleaner_thunk_str_id_; diff --git a/src/trace_processor/importers/proto/jit_tracker.h b/src/trace_processor/importers/proto/jit_tracker.h index 814d617887..62822ab269 100644 --- a/src/trace_processor/importers/proto/jit_tracker.h +++ b/src/trace_processor/importers/proto/jit_tracker.h @@ -49,7 +49,7 @@ class JitTracker : public Destructible { TraceProcessorContext* const context_; - base::FlatHashMap>> + base::FlatHashMapV2>> caches_; }; diff --git a/src/trace_processor/importers/proto/network_trace_module.h b/src/trace_processor/importers/proto/network_trace_module.h index b40c674f4f..888dec6aad 100644 --- a/src/trace_processor/importers/proto/network_trace_module.h +++ b/src/trace_processor/importers/proto/network_trace_module.h @@ -71,7 +71,7 @@ class NetworkTraceModule : public ProtoImporterModule { TraceProcessorContext* context_; bool loaded_package_names_ = false; - base::FlatHashMap package_names_; + base::FlatHashMapV2 package_names_; const StringId net_arg_length_; const StringId net_arg_ip_proto_; diff --git a/src/trace_processor/importers/proto/pigweed_detokenizer.cc b/src/trace_processor/importers/proto/pigweed_detokenizer.cc index b9b0bce027..e9e8f335a4 100644 --- a/src/trace_processor/importers/proto/pigweed_detokenizer.cc +++ b/src/trace_processor/importers/proto/pigweed_detokenizer.cc @@ -57,12 +57,12 @@ static constexpr uint32_t ReadUint32(const uint8_t* bytes) { namespace perfetto::trace_processor::pigweed { PigweedDetokenizer CreateNullDetokenizer() { - return PigweedDetokenizer{base::FlatHashMap()}; + return PigweedDetokenizer{base::FlatHashMapV2()}; } base::StatusOr CreateDetokenizer( const protozero::ConstBytes& bytes) { - base::FlatHashMap tokens; + base::FlatHashMapV2 tokens; // See Pigweed's token_database.h for a description of the format, // but tl;dr we have: // @@ -117,7 +117,7 @@ base::StatusOr CreateDetokenizer( } PigweedDetokenizer::PigweedDetokenizer( - base::FlatHashMap tokens) + base::FlatHashMapV2 tokens) : tokens_(std::move(tokens)) {} #if defined(__GNUC__) || defined(__clang__) diff --git a/src/trace_processor/importers/proto/pigweed_detokenizer.h b/src/trace_processor/importers/proto/pigweed_detokenizer.h index 5d2baa5171..a8b2794260 100644 --- a/src/trace_processor/importers/proto/pigweed_detokenizer.h +++ b/src/trace_processor/importers/proto/pigweed_detokenizer.h @@ -99,12 +99,13 @@ class DetokenizedString { class PigweedDetokenizer { public: - explicit PigweedDetokenizer(base::FlatHashMap tokens); + explicit PigweedDetokenizer( + base::FlatHashMapV2 tokens); base::StatusOr Detokenize( const protozero::ConstBytes& bytes) const; private: - base::FlatHashMap tokens_; + base::FlatHashMapV2 tokens_; }; PigweedDetokenizer CreateNullDetokenizer(); diff --git a/src/trace_processor/importers/proto/pixel_modem_parser.cc b/src/trace_processor/importers/proto/pixel_modem_parser.cc index 6980ccce5a..921b4baf33 100644 --- a/src/trace_processor/importers/proto/pixel_modem_parser.cc +++ b/src/trace_processor/importers/proto/pixel_modem_parser.cc @@ -49,12 +49,12 @@ constexpr std::string_view kModemName = "Pixel Modem Events"; // Modem inputs in particular have this key-value encoding. It's not a Pigweed // thing. -base::FlatHashMap SplitUpModemString( +base::FlatHashMapV2 SplitUpModemString( const std::string& input) { auto delimStart = std::string(kKeyDelimiterStart); auto delimEnd = std::string(kKeyDelimiterEnd); - base::FlatHashMap result; + base::FlatHashMapV2 result; std::vector pairs = base::SplitString(input, delimStart); for (auto& it : pairs) { std::vector pair = base::SplitString(it, delimEnd); @@ -90,7 +90,7 @@ base::Status PixelModemParser::ParseEvent(int64_t ts, std::string event = detokenized_str.Format(); - base::FlatHashMap map = SplitUpModemString(event); + base::FlatHashMapV2 map = SplitUpModemString(event); std::string* domain = map.Find(std::string(kKeyDomain)); std::string* format = map.Find(std::string(kKeyFormat)); diff --git a/src/trace_processor/importers/proto/profile_module.h b/src/trace_processor/importers/proto/profile_module.h index c6bac5e59a..c5089e0034 100644 --- a/src/trace_processor/importers/proto/profile_module.h +++ b/src/trace_processor/importers/proto/profile_module.h @@ -102,7 +102,7 @@ class ProfileModule : public ProtoImporterModule { // heap_profile rows already emitted, so the per-dump row is written once per // heap despite the dump header repeating across continued ProfilePackets. // Used as a set: the value is unused. - base::FlatHashMap seen_heap_profiles_; + base::FlatHashMapV2 seen_heap_profiles_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/proto/profile_packet_sequence_state.h b/src/trace_processor/importers/proto/profile_packet_sequence_state.h index 95123ffcb8..f7650c2407 100644 --- a/src/trace_processor/importers/proto/profile_packet_sequence_state.h +++ b/src/trace_processor/importers/proto/profile_packet_sequence_state.h @@ -135,20 +135,20 @@ class ProfilePacketSequenceState final TraceProcessorContext* const context_; - base::FlatHashMap strings_; - base::FlatHashMap mappings_; - base::FlatHashMap frames_; - base::FlatHashMap callstacks_; + base::FlatHashMapV2 strings_; + base::FlatHashMapV2 mappings_; + base::FlatHashMapV2 frames_; + base::FlatHashMapV2 callstacks_; std::vector pending_allocs_; - base::FlatHashMap, - tables::HeapProfileAllocationTable::Row, - base::MurmurHash>> + base::FlatHashMapV2, + tables::HeapProfileAllocationTable::Row, + base::MurmurHash>> prev_alloc_; - base::FlatHashMap, - tables::HeapProfileAllocationTable::Row, - base::MurmurHash>> + base::FlatHashMapV2, + tables::HeapProfileAllocationTable::Row, + base::MurmurHash>> prev_free_; // For continuous dumps, we only store the delta in the data-base. To do @@ -161,13 +161,15 @@ class ProfilePacketSequenceState final // one, and then handle it as normal. If it is the first time we see a // SourceCallstackId for a CallsiteId, we put the previous value into // the correction maps below. - base::FlatHashMap, - base::MurmurHash> + base::FlatHashMapV2, + base::MurmurHash> seen_callstacks_; - base::FlatHashMap + base::FlatHashMapV2 alloc_correction_; - base::FlatHashMap + base::FlatHashMapV2 free_correction_; std::optional prev_index; diff --git a/src/trace_processor/importers/proto/proto_trace_parser_impl.h b/src/trace_processor/importers/proto/proto_trace_parser_impl.h index 823da1c551..4d619966dd 100644 --- a/src/trace_processor/importers/proto/proto_trace_parser_impl.h +++ b/src/trace_processor/importers/proto/proto_trace_parser_impl.h @@ -70,7 +70,7 @@ class ProtoTraceParserImpl { const StringId raw_chrome_legacy_user_trace_event_id_; const StringId missing_metatrace_interned_string_id_; - base::FlatHashMap metatrace_interned_strings_; + base::FlatHashMapV2 metatrace_interned_strings_; }; } // namespace trace_processor diff --git a/src/trace_processor/importers/proto/proto_trace_reader.cc b/src/trace_processor/importers/proto/proto_trace_reader.cc index 9ca36b0465..4c5184ec97 100644 --- a/src/trace_processor/importers/proto/proto_trace_reader.cc +++ b/src/trace_processor/importers/proto/proto_trace_reader.cc @@ -953,10 +953,10 @@ base::Status ProtoTraceReader::ParseRemoteClockSync(ConstBytes blob) { return base::OkStatus(); } -base::FlatHashMap +base::FlatHashMapV2 ProtoTraceReader::CalculateClockOffsets( std::vector& sync_clock_snapshots) { - base::FlatHashMap clock_offsets; + base::FlatHashMapV2 clock_offsets; // The RemoteClockSync message contains a sequence of |synced_clocks| // messages. Each |synced_clocks| message contains pairs of ClockSnapshots @@ -1174,7 +1174,7 @@ void ProtoTraceReader::ParseTraceStats(ConstBytes blob) { uint32_t data_loss_writer_abort = 0; uint32_t data_loss_smb_full = 0; }; - base::FlatHashMap stats_per_buffer; + base::FlatHashMapV2 stats_per_buffer; for (auto it = evt.writer_stats(); it; ++it) { protos::pbzero::TraceStats::WriterStats::Decoder w(*it); auto seq_id = static_cast(w.sequence_id()); diff --git a/src/trace_processor/importers/proto/proto_trace_reader.h b/src/trace_processor/importers/proto/proto_trace_reader.h index cae95597c2..5d15431771 100644 --- a/src/trace_processor/importers/proto/proto_trace_reader.h +++ b/src/trace_processor/importers/proto/proto_trace_reader.h @@ -75,10 +75,10 @@ class ProtoTraceReader : public ChunkedTraceReader { base::Status OnPushDataToSorter() override; void OnEventsFullyExtracted() override; - using SyncClockSnapshots = base::FlatHashMap< + using SyncClockSnapshots = base::FlatHashMapV2< uint32_t, std::pair>; - static base::FlatHashMap + static base::FlatHashMapV2 CalculateClockOffsetsForTesting( std::vector& sync_clock_snapshots) { return CalculateClockOffsets(sync_clock_snapshots); @@ -157,7 +157,7 @@ class ProtoTraceReader : public ChunkedTraceReader { void ParseTraceConfig(ConstBytes); void ParseTraceStats(ConstBytes); - static base::FlatHashMap + static base::FlatHashMapV2 CalculateClockOffsets(std::vector&); PacketSequenceStateBuilder* GetIncrementalState(SequenceScopedState* seq) { @@ -176,7 +176,7 @@ class ProtoTraceReader : public ChunkedTraceReader { ProtoTraceTokenizer tokenizer_; ProtoImporterModuleContext module_context_; std::unique_ptr parser_; - base::FlatHashMap> + base::FlatHashMapV2> machine_to_proto_readers_; const bool is_machine_dispatcher_; // Machine adopted onto the host context (relabelled), or nullopt until the @@ -190,7 +190,7 @@ class ProtoTraceReader : public ChunkedTraceReader { // timestamp given is latest_timestamp_. int64_t latest_timestamp_ = 0; - base::FlatHashMap sequence_state_; + base::FlatHashMapV2 sequence_state_; // The sequence ParsePacket last looked up; reset whenever the map changes. uint32_t last_seq_id_ = 0; SequenceScopedState* last_scoped_state_ = nullptr; diff --git a/src/trace_processor/importers/proto/protovm_incremental_tracing.h b/src/trace_processor/importers/proto/protovm_incremental_tracing.h index 51fa6108fd..8a46b7bad0 100644 --- a/src/trace_processor/importers/proto/protovm_incremental_tracing.h +++ b/src/trace_processor/importers/proto/protovm_incremental_tracing.h @@ -64,9 +64,9 @@ class ProtoVmIncrementalTracing { const SelectiveTracePacketDecoder& patch) const; TraceProcessorContext* context_; - base::FlatHashMap> + base::FlatHashMapV2> producer_id_to_sequence_ids_; - base::FlatHashMap> sequence_id_to_vms_; + base::FlatHashMapV2> sequence_id_to_vms_; std::vector> vms_; }; diff --git a/src/trace_processor/importers/proto/stack_profile_sequence_state.h b/src/trace_processor/importers/proto/stack_profile_sequence_state.h index a7095aef4a..266ece490c 100644 --- a/src/trace_processor/importers/proto/stack_profile_sequence_state.h +++ b/src/trace_processor/importers/proto/stack_profile_sequence_state.h @@ -103,17 +103,17 @@ class StackProfileSequenceState final } }; - base::FlatHashMap> + base::FlatHashMapV2> cached_mappings_; - base::FlatHashMap> + base::FlatHashMapV2> cached_frames_; - base::FlatHashMap> + base::FlatHashMapV2> cached_callstacks_; }; diff --git a/src/trace_processor/importers/proto/statsd_module.h b/src/trace_processor/importers/proto/statsd_module.h index e43027cc1f..3d3d5e88fd 100644 --- a/src/trace_processor/importers/proto/statsd_module.h +++ b/src/trace_processor/importers/proto/statsd_module.h @@ -51,7 +51,7 @@ class StatsdModule : public ProtoImporterModule { TrackId InternTrackId(); TraceProcessorContext* context_; - base::FlatHashMap atom_names_; + base::FlatHashMapV2 atom_names_; uint32_t descriptor_idx_ = std::numeric_limits::max(); util::ProtoToArgsParser args_parser_; std::optional track_id_; diff --git a/src/trace_processor/importers/proto/system_probes_parser.h b/src/trace_processor/importers/proto/system_probes_parser.h index b11c527a56..6b896adbbd 100644 --- a/src/trace_processor/importers/proto/system_probes_parser.h +++ b/src/trace_processor/importers/proto/system_probes_parser.h @@ -92,8 +92,8 @@ class SystemProbesParser { int64_t prev_discard_time = -1; int64_t prev_flush_time = -1; }; - base::FlatHashMap disk_state_map_; - base::FlatHashMap irq_ids_; + base::FlatHashMapV2 disk_state_map_; + base::FlatHashMapV2 irq_ids_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/proto/track_event_extension_parser.h b/src/trace_processor/importers/proto/track_event_extension_parser.h index 66ad37fed1..970f14a619 100644 --- a/src/trace_processor/importers/proto/track_event_extension_parser.h +++ b/src/trace_processor/importers/proto/track_event_extension_parser.h @@ -109,7 +109,7 @@ class TrackEventExtensionParser { // each registered field id to its owner. struct TrackEventExtensionParserContext { std::vector> parsers; - base::FlatHashMap parsers_by_field; + base::FlatHashMapV2 parsers_by_field; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/proto/track_event_sequence_state.h b/src/trace_processor/importers/proto/track_event_sequence_state.h index 4e051c8025..a6c44a8eec 100644 --- a/src/trace_processor/importers/proto/track_event_sequence_state.h +++ b/src/trace_processor/importers/proto/track_event_sequence_state.h @@ -106,7 +106,7 @@ class TrackEventSequenceState final int64_t thread_timestamp_ns_ = 0; int64_t thread_instruction_count_ = 0; - base::FlatHashMap + base::FlatHashMapV2 incremental_counter_values_; }; diff --git a/src/trace_processor/importers/proto/track_event_tracker.h b/src/trace_processor/importers/proto/track_event_tracker.h index 7b2ea74a97..fc2a23e6e5 100644 --- a/src/trace_processor/importers/proto/track_event_tracker.h +++ b/src/trace_processor/importers/proto/track_event_tracker.h @@ -414,12 +414,12 @@ class TrackEventTracker { // Helper to record analysis errors with track_uuid arg void RecordTrackError(size_t stat_key, uint64_t track_uuid); - base::FlatHashMap descriptor_tracks_state_; + base::FlatHashMapV2 descriptor_tracks_state_; // Stores the descriptor uuid used for the primary process/thread track // for the given upid / utid. Used for pid/tid reuse detection. - base::FlatHashMap descriptor_uuids_by_upid_; - base::FlatHashMap descriptor_uuids_by_utid_; + base::FlatHashMapV2 descriptor_uuids_by_upid_; + base::FlatHashMapV2 descriptor_uuids_by_utid_; std::unordered_set sequences_with_first_packet_; diff --git a/src/trace_processor/importers/proto/user_tracker.h b/src/trace_processor/importers/proto/user_tracker.h index 71fe5a88b0..83ebe39ca8 100644 --- a/src/trace_processor/importers/proto/user_tracker.h +++ b/src/trace_processor/importers/proto/user_tracker.h @@ -35,7 +35,7 @@ class UserTracker { private: TraceProcessorContext* const context_; - base::FlatHashMap user_rows_; + base::FlatHashMapV2 user_rows_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/proto/v8_module.h b/src/trace_processor/importers/proto/v8_module.h index 8fe40a5a1d..da90b8d980 100644 --- a/src/trace_processor/importers/proto/v8_module.h +++ b/src/trace_processor/importers/proto/v8_module.h @@ -84,7 +84,7 @@ class V8Module : public ProtoImporterModule { std::unique_ptr v8_tracker_; // Caches isolate to pid associations. Used to compute the utid for code // events. - base::FlatHashMap isolate_to_pid_; + base::FlatHashMapV2 isolate_to_pid_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/proto/v8_sequence_state.h b/src/trace_processor/importers/proto/v8_sequence_state.h index 195464cd59..dcccee262a 100644 --- a/src/trace_processor/importers/proto/v8_sequence_state.h +++ b/src/trace_processor/importers/proto/v8_sequence_state.h @@ -64,12 +64,12 @@ class V8SequenceState final V8Tracker* const v8_tracker_; using InterningId = uint64_t; - base::FlatHashMap> + base::FlatHashMapV2> isolates_; - base::FlatHashMap js_scripts_; - base::FlatHashMap wasm_scripts_; - base::FlatHashMap js_functions_; - base::FlatHashMap js_function_names_; + base::FlatHashMapV2 js_scripts_; + base::FlatHashMapV2 wasm_scripts_; + base::FlatHashMapV2 js_functions_; + base::FlatHashMapV2 js_function_names_; }; template <> diff --git a/src/trace_processor/importers/proto/v8_tracker.h b/src/trace_processor/importers/proto/v8_tracker.h index fea43e3ecd..c76ca79702 100644 --- a/src/trace_processor/importers/proto/v8_tracker.h +++ b/src/trace_processor/importers/proto/v8_tracker.h @@ -155,27 +155,27 @@ class V8Tracker { TraceProcessorContext* const context_; JitTracker jit_tracker_; - base::FlatHashMap> isolates_; + base::FlatHashMapV2> isolates_; // Multiple isolates in the same process might share the code. Keep track of // those here. - base::FlatHashMap shared_code_ranges_; + base::FlatHashMapV2 shared_code_ranges_; - base::FlatHashMap, - base::MurmurHash> + base::FlatHashMapV2, + base::MurmurHash> isolate_index_; - base::FlatHashMap, - tables::V8JsScriptTable::Id, - base::MurmurHash>> + base::FlatHashMapV2, + tables::V8JsScriptTable::Id, + base::MurmurHash>> js_script_index_; - base::FlatHashMap, - tables::V8WasmScriptTable::Id, - base::MurmurHash>> + base::FlatHashMapV2, + tables::V8WasmScriptTable::Id, + base::MurmurHash>> wasm_script_index_; - base::FlatHashMap + base::FlatHashMapV2 js_function_index_; }; diff --git a/src/trace_processor/importers/simpleperf_proto/simpleperf_proto_tracker.h b/src/trace_processor/importers/simpleperf_proto/simpleperf_proto_tracker.h index 9b720cf4a1..26b7171c91 100644 --- a/src/trace_processor/importers/simpleperf_proto/simpleperf_proto_tracker.h +++ b/src/trace_processor/importers/simpleperf_proto/simpleperf_proto_tracker.h @@ -83,10 +83,10 @@ class SimpleperfProtoTracker { private: // Map from file_id to symbol table (list of symbol names) - base::FlatHashMap> symbol_tables_; + base::FlatHashMapV2> symbol_tables_; // Map from file_id to DummyMemoryMapping pointer - base::FlatHashMap file_mappings_; + base::FlatHashMapV2 file_mappings_; // List of event types indexed by event_type_id std::vector event_types_; diff --git a/src/trace_processor/importers/systrace/systrace_line_parser.cc b/src/trace_processor/importers/systrace/systrace_line_parser.cc index ea496abb1c..ace1fed94b 100644 --- a/src/trace_processor/importers/systrace/systrace_line_parser.cc +++ b/src/trace_processor/importers/systrace/systrace_line_parser.cc @@ -77,7 +77,7 @@ base::Status SystraceLineParser::ParseLine(const SystraceLine& line) { } } - base::FlatHashMap> + base::FlatHashMapV2> args; for (base::StringSplitter ss(line.args_str, ' '); ss.Next();) { std::string key; diff --git a/src/trace_processor/perfetto_sql/engine/perfetto_sql_connection.h b/src/trace_processor/perfetto_sql/engine/perfetto_sql_connection.h index ca1927bd72..1f19cd9249 100644 --- a/src/trace_processor/perfetto_sql/engine/perfetto_sql_connection.h +++ b/src/trace_processor/perfetto_sql/engine/perfetto_sql_connection.h @@ -610,7 +610,7 @@ class PerfettoSqlConnection { void* ctx; bool deterministic; }; - base::FlatHashMap + base::FlatHashMapV2 intrinsic_function_registry_; // Tracks every scalar function registered with |connection_| via @@ -633,9 +633,9 @@ class PerfettoSqlConnection { void* ctx; bool is_intrinsic; }; - base::FlatHashMap, - FunctionEntry, - base::MurmurHash>> + base::FlatHashMapV2, + FunctionEntry, + base::MurmurHash>> fn_registry_; std::unique_ptr connection_; diff --git a/src/trace_processor/perfetto_sql/engine/perfetto_sql_database.h b/src/trace_processor/perfetto_sql/engine/perfetto_sql_database.h index 3cd3f6e4bb..e7d9d720a4 100644 --- a/src/trace_processor/perfetto_sql/engine/perfetto_sql_database.h +++ b/src/trace_processor/perfetto_sql/engine/perfetto_sql_database.h @@ -79,12 +79,12 @@ class PerfettoSqlDatabase { const sql_modules::RegisteredPackage* FindPackageForModule( const std::string& key) const; std::vector> GetModules() const; - base::FlatHashMap& packages() { + base::FlatHashMapV2& packages() { return packages_; } - base::FlatHashMap& macros() { return macros_; } - const base::FlatHashMap& macros() const { + base::FlatHashMapV2& macros() { return macros_; } + const base::FlatHashMapV2& macros() const { return macros_; } size_t macro_count() const { return macros_.size(); } @@ -191,8 +191,8 @@ class PerfettoSqlDatabase { bool shared_schema_initialized_ PERFETTO_GUARDED_BY(shared_schema_mu_) = false; - base::FlatHashMap packages_; - base::FlatHashMap macros_; + base::FlatHashMapV2 packages_; + base::FlatHashMapV2 macros_; sqlite::CommittedStateManager committed_dataframes_; sqlite::CommittedStateManager committed_runtime_table_functions_; diff --git a/src/trace_processor/perfetto_sql/generator/structured_query_generator.cc b/src/trace_processor/perfetto_sql/generator/structured_query_generator.cc index 1ffefcd3ab..8596e66980 100644 --- a/src/trace_processor/perfetto_sql/generator/structured_query_generator.cc +++ b/src/trace_processor/perfetto_sql/generator/structured_query_generator.cc @@ -180,9 +180,9 @@ using QueryProto = StructuredQueryGenerator::QueryProto; class GeneratorImpl { public: - GeneratorImpl(base::FlatHashMap& protos, + GeneratorImpl(base::FlatHashMapV2& protos, std::vector& queries, - base::FlatHashMap& modules, + base::FlatHashMapV2& modules, std::vector& preambles) : query_protos_(protos), queries_(queries), @@ -265,9 +265,9 @@ class GeneratorImpl { // Index of the current query we are processing in the `state_` vector. size_t state_index_ = 0; std::vector state_; - base::FlatHashMap& query_protos_; + base::FlatHashMapV2& query_protos_; std::vector& queries_; - base::FlatHashMap& referenced_modules_; + base::FlatHashMapV2& referenced_modules_; std::vector& preambles_; std::set used_table_names_; }; @@ -1498,7 +1498,7 @@ base::StatusOr GeneratorImpl::SelectColumnsAggregates( protozero::RepeatedFieldIterator group_by_cols, protozero::RepeatedFieldIterator aggregates, protozero::RepeatedFieldIterator select_cols) { - base::FlatHashMap> output; + base::FlatHashMapV2> output; if (select_cols) { for (auto it = select_cols; it; ++it) { StructuredQuery::SelectColumn::Decoder select(*it); diff --git a/src/trace_processor/perfetto_sql/generator/structured_query_generator.h b/src/trace_processor/perfetto_sql/generator/structured_query_generator.h index ec93dbb09d..c216a127cd 100644 --- a/src/trace_processor/perfetto_sql/generator/structured_query_generator.h +++ b/src/trace_processor/perfetto_sql/generator/structured_query_generator.h @@ -89,12 +89,12 @@ class StructuredQueryGenerator { std::vector referenced_queries() const { return referenced_queries_; } private: - base::FlatHashMap query_protos_; + base::FlatHashMapV2 query_protos_; std::vector referenced_queries_; // We don't have FlatHashSet so just (ab)use FlatHashMap by storing a noop // value. - base::FlatHashMap referenced_modules_; + base::FlatHashMapV2 referenced_modules_; std::vector preambles_; }; diff --git a/src/trace_processor/perfetto_sql/intrinsics/types/counter.h b/src/trace_processor/perfetto_sql/intrinsics/types/counter.h index 093b09fc6d..2d77fc6256 100644 --- a/src/trace_processor/perfetto_sql/intrinsics/types/counter.h +++ b/src/trace_processor/perfetto_sql/intrinsics/types/counter.h @@ -37,9 +37,10 @@ struct CounterTrackPartition { struct PartitionedCounter { static constexpr char kName[] = "COUNTER_TRACK_PARTITIONS"; - base:: - FlatHashMap> - partitions_map; + base::FlatHashMapV2> + partitions_map; }; } // namespace perfetto::trace_processor::perfetto_sql diff --git a/src/trace_processor/perfetto_sql/intrinsics/types/partitioned_intervals.h b/src/trace_processor/perfetto_sql/intrinsics/types/partitioned_intervals.h index b0eee2f68e..b3c663c3a5 100644 --- a/src/trace_processor/perfetto_sql/intrinsics/types/partitioned_intervals.h +++ b/src/trace_processor/perfetto_sql/intrinsics/types/partitioned_intervals.h @@ -39,7 +39,7 @@ struct Partition { }; using Partitions = - base::FlatHashMap>; + base::FlatHashMapV2>; struct PartitionedTable { static constexpr char kName[] = "INTERVAL_TREE_PARTITIONS"; diff --git a/src/trace_processor/perfetto_sql/parser/perfetto_sql_parser.cc b/src/trace_processor/perfetto_sql/parser/perfetto_sql_parser.cc index 94a1367c62..076a5f196d 100644 --- a/src/trace_processor/perfetto_sql/parser/perfetto_sql_parser.cc +++ b/src/trace_processor/perfetto_sql/parser/perfetto_sql_parser.cc @@ -128,7 +128,7 @@ class RewriteTree { RewriteTree(SyntaqliteParser* p, const SqlSource& stmt, uint32_t stmt_doc_offset, - const base::FlatHashMap& macros) + const base::FlatHashMapV2& macros) : p_(p), stmt_(stmt), stmt_doc_offset_(stmt_doc_offset), macros_(macros) { uint32_t total = syntaqlite_result_rewrite_count(p_); no_macros_ = (total == 0); @@ -319,7 +319,7 @@ class RewriteTree { SyntaqliteParser* p_; const SqlSource& stmt_; uint32_t stmt_doc_offset_; - const base::FlatHashMap& macros_; + const base::FlatHashMapV2& macros_; // Zero macros in the whole parse — lets NodeSource fast-path. bool no_macros_ = true; // children_[parent_idx] = rewrite indices whose `parent_idx` equals that. @@ -596,7 +596,7 @@ base::StatusOr ParseStatement(SyntaqliteParser* p, // (preprocessor-compat shims) and the engine-owned user macro registry. struct PerfettoSqlParser::Impl { - Impl(const base::FlatHashMap& m, + Impl(const base::FlatHashMapV2& m, const pipeline::Catalog& c, bool allowed) : source(SqlSource::FromTraceProcessorImplementation("")), @@ -678,7 +678,7 @@ struct PerfettoSqlParser::Impl { SyntaqliteParser* synq; SqlSource source; - const base::FlatHashMap& macros; + const base::FlatHashMapV2& macros; const pipeline::Catalog* catalog; // Whether the SQL being read may use a pipeline. Set per source, so one // parser serves both the standard library and user SQL. @@ -745,7 +745,7 @@ bool PerfettoSqlParser::Impl::Next( } PerfettoSqlParser::PerfettoSqlParser( - const base::FlatHashMap& macros, + const base::FlatHashMapV2& macros, const pipeline::Catalog& catalog, bool pipelines_allowed) : impl_(std::make_unique(macros, catalog, pipelines_allowed)) {} diff --git a/src/trace_processor/perfetto_sql/parser/perfetto_sql_parser.h b/src/trace_processor/perfetto_sql/parser/perfetto_sql_parser.h index fd935cd463..fce13fef83 100644 --- a/src/trace_processor/perfetto_sql/parser/perfetto_sql_parser.h +++ b/src/trace_processor/perfetto_sql/parser/perfetto_sql_parser.h @@ -156,7 +156,7 @@ class PerfettoSqlParser { // the SQL read may use one at all; it is asked for separately because it // varies between sources sharing one parser, not between catalogs. explicit PerfettoSqlParser( - const base::FlatHashMap& macros, + const base::FlatHashMapV2& macros, const pipeline::Catalog& catalog, bool pipelines_allowed); diff --git a/src/trace_processor/perfetto_sql/parser/perfetto_sql_parser_unittest.cc b/src/trace_processor/perfetto_sql/parser/perfetto_sql_parser_unittest.cc index 5f28608f71..9bd974e85c 100644 --- a/src/trace_processor/perfetto_sql/parser/perfetto_sql_parser_unittest.cc +++ b/src/trace_processor/perfetto_sql/parser/perfetto_sql_parser_unittest.cc @@ -127,7 +127,7 @@ class PerfettoSqlParserTest : public ::testing::Test { return pipeline::LogicalPlanToString(pipeline->plan); } - base::FlatHashMap macros_; + base::FlatHashMapV2 macros_; StringPool pool_; std::unique_ptr connection_; pipeline::TestCatalog catalog_; diff --git a/src/trace_processor/perfetto_sql/pipeline/physical_plan_unittest.cc b/src/trace_processor/perfetto_sql/pipeline/physical_plan_unittest.cc index 5cf0cebf73..1aac5fe3f6 100644 --- a/src/trace_processor/perfetto_sql/pipeline/physical_plan_unittest.cc +++ b/src/trace_processor/perfetto_sql/pipeline/physical_plan_unittest.cc @@ -177,7 +177,7 @@ class PhysicalPlanTest : public ::testing::Test { StringPool pool_; std::unique_ptr connection_; TestCatalog catalog_; - base::FlatHashMap macros_; + base::FlatHashMapV2 macros_; }; TEST_F(PhysicalPlanTest, AFromAloneReadsTheSource) { diff --git a/src/trace_processor/perfetto_sql/pipeline/plan_serialization_unittest.cc b/src/trace_processor/perfetto_sql/pipeline/plan_serialization_unittest.cc index 4b455612c4..ca2f177dff 100644 --- a/src/trace_processor/perfetto_sql/pipeline/plan_serialization_unittest.cc +++ b/src/trace_processor/perfetto_sql/pipeline/plan_serialization_unittest.cc @@ -87,7 +87,7 @@ class PlanSerializationTest : public ::testing::Test { std::unique_ptr connection_; TestCatalog catalog_; std::vector> dataframes_; - base::FlatHashMap macros_; + base::FlatHashMapV2 macros_; }; const char* const kPipelines[] = { diff --git a/src/trace_processor/perfetto_sql/pipeline/test_catalog.h b/src/trace_processor/perfetto_sql/pipeline/test_catalog.h index 857b6aa01b..8809611373 100644 --- a/src/trace_processor/perfetto_sql/pipeline/test_catalog.h +++ b/src/trace_processor/perfetto_sql/pipeline/test_catalog.h @@ -126,7 +126,7 @@ class TestCatalog : public Catalog { private: StringPool* pool_; SqliteConnection* connection_; - base::FlatHashMap> + base::FlatHashMapV2> dataframes_; }; diff --git a/src/trace_processor/plugins/android_framework_track_event/android_framework_track_event.cc b/src/trace_processor/plugins/android_framework_track_event/android_framework_track_event.cc index 47dd70eefd..e4bebb0e32 100644 --- a/src/trace_processor/plugins/android_framework_track_event/android_framework_track_event.cc +++ b/src/trace_processor/plugins/android_framework_track_event/android_framework_track_event.cc @@ -105,10 +105,11 @@ class AndroidTrackEventProcessTableHolder { private: AndroidTrackEventProcessTable table_; - base::FlatHashMap upid_to_row_; + base::FlatHashMapV2 + upid_to_row_; // start_seq_id is unique per process start, so unlike the pid it still // identifies the process after it has died and its pid has been reused. - base::FlatHashMap + base::FlatHashMapV2 start_seq_id_to_row_; }; diff --git a/src/trace_processor/plugins/connected_flow/connected_flow_impl.h b/src/trace_processor/plugins/connected_flow/connected_flow_impl.h index 6ff2c2ac4c..80e13f11c2 100644 --- a/src/trace_processor/plugins/connected_flow/connected_flow_impl.h +++ b/src/trace_processor/plugins/connected_flow/connected_flow_impl.h @@ -36,9 +36,9 @@ namespace perfetto::trace_processor { // Represents the flow graph with pre-computed adjacency lists. struct FlowGraph { - base::FlatHashMap> + base::FlatHashMapV2> outgoing_flows; - base::FlatHashMap> + base::FlatHashMapV2> incoming_flows; static FlowGraph Build(const tables::FlowTable& flow_table) { diff --git a/src/trace_processor/plugins/experimental_slice_layout/experimental_slice_layout.cc b/src/trace_processor/plugins/experimental_slice_layout/experimental_slice_layout.cc index 5ee235d1c1..c1621df044 100644 --- a/src/trace_processor/plugins/experimental_slice_layout/experimental_slice_layout.cc +++ b/src/trace_processor/plugins/experimental_slice_layout/experimental_slice_layout.cc @@ -206,7 +206,7 @@ ExperimentalSliceLayout::Cursor::ComputeLayoutTable( // its children, letting us map every slice to its group in a single pass. // |id_to_group| resolves a parent id; |slice_group| records each row's group // positionally so the emit pass never has to hash. - base::FlatHashMap id_to_group; + base::FlatHashMapV2 id_to_group; std::vector slice_group; slice_group.reserve(rows.size()); std::vector groups; diff --git a/src/trace_processor/plugins/perf_text/perf_text_trace_tokenizer.h b/src/trace_processor/plugins/perf_text/perf_text_trace_tokenizer.h index 91fb9bc900..4c5751698b 100644 --- a/src/trace_processor/plugins/perf_text/perf_text_trace_tokenizer.h +++ b/src/trace_processor/plugins/perf_text/perf_text_trace_tokenizer.h @@ -41,7 +41,7 @@ class PerfTextTraceTokenizer : public ChunkedTraceReader { private: TraceProcessorContext* const context_; util::TraceBlobViewReader reader_; - base::FlatHashMap mappings_; + base::FlatHashMapV2 mappings_; std::unique_ptr> stream_; }; diff --git a/src/trace_processor/plugins/perfetto_manifest/perfetto_manifest_reader.cc b/src/trace_processor/plugins/perfetto_manifest/perfetto_manifest_reader.cc index 1850b47d88..fe5cf97429 100644 --- a/src/trace_processor/plugins/perfetto_manifest/perfetto_manifest_reader.cc +++ b/src/trace_processor/plugins/perfetto_manifest/perfetto_manifest_reader.cc @@ -457,7 +457,7 @@ base::Status PerfettoManifestReader::ApplyManifest() { // its embedded-id remap. Rows are allocated in manifest order, so machine ids // follow the order files list their machines in. auto& machine_table = *context_->storage->mutable_machine_table(); - base::FlatHashMap name_to_id; + base::FlatHashMapV2 name_to_id; int64_t next_id = kFirstManifestMachineId; auto raw_id_for_name = [&](const std::string& name) { if (int64_t* id = name_to_id.Find(name)) { diff --git a/src/trace_processor/plugins/span_join_operator/span_join_operator.h b/src/trace_processor/plugins/span_join_operator/span_join_operator.h index a813e1011d..d8280cf1d1 100644 --- a/src/trace_processor/plugins/span_join_operator/span_join_operator.h +++ b/src/trace_processor/plugins/span_join_operator/span_join_operator.h @@ -407,7 +407,7 @@ struct SpanJoinOperatorModule : public sqlite::Module { TableDefinition t1_defn; TableDefinition t2_defn; PartitioningType partitioning; - base::FlatHashMap global_index_to_column_locator; + base::FlatHashMapV2 global_index_to_column_locator; }; // Base class for a cursor on the span table. diff --git a/src/trace_processor/plugins/stack_sample_importer/module.h b/src/trace_processor/plugins/stack_sample_importer/module.h index f38de1d761..c9f6bda0c5 100644 --- a/src/trace_processor/plugins/stack_sample_importer/module.h +++ b/src/trace_processor/plugins/stack_sample_importer/module.h @@ -95,7 +95,7 @@ class StackSampleModule : public ProtoImporterModule { TraceProcessorContext* const context_; // One profiler session per packet sequence emitting StackSample packets. - base::FlatHashMap sessions_; + base::FlatHashMapV2 sessions_; // Lazily-created mapping that inline callstack frames are interned into. DummyMemoryMapping* inline_callstack_mapping_ = nullptr; diff --git a/src/trace_processor/plugins/to_ftrace/to_ftrace.h b/src/trace_processor/plugins/to_ftrace/to_ftrace.h index 49adf96e3d..c699c33136 100644 --- a/src/trace_processor/plugins/to_ftrace/to_ftrace.h +++ b/src/trace_processor/plugins/to_ftrace/to_ftrace.h @@ -42,7 +42,7 @@ class SystraceSerializer { private: using StringIdMap = - base::FlatHashMap>>; + base::FlatHashMapV2>>; void SerializePrefix(uint32_t raw_row, base::DynamicStringWriter* writer); diff --git a/src/trace_processor/plugins/video_frame_importer/video_frame_module.h b/src/trace_processor/plugins/video_frame_importer/video_frame_module.h index ee02044661..44ddc4f940 100644 --- a/src/trace_processor/plugins/video_frame_importer/video_frame_module.h +++ b/src/trace_processor/plugins/video_frame_importer/video_frame_module.h @@ -77,7 +77,7 @@ class VideoFrameModule : public ProtoImporterModule { tables::AndroidVideoFramesTable* const table_; std::vector* const au_data_; int64_t max_stream_size_bytes_ = kDefaultMaxStreamSizeBytes; - base::FlatHashMap stream_info_by_id_; + base::FlatHashMapV2 stream_info_by_id_; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/plugins/winscope_importer/protolog_message_decoder.h b/src/trace_processor/plugins/winscope_importer/protolog_message_decoder.h index fc5585de4c..0031f547cb 100644 --- a/src/trace_processor/plugins/winscope_importer/protolog_message_decoder.h +++ b/src/trace_processor/plugins/winscope_importer/protolog_message_decoder.h @@ -102,8 +102,8 @@ class ProtoLogMessageDecoder { private: TraceProcessorContext* const context_; - base::FlatHashMap tracked_groups_; - base::FlatHashMap> + base::FlatHashMapV2 tracked_groups_; + base::FlatHashMapV2> tracked_messages_; }; diff --git a/src/trace_processor/plugins/winscope_importer/viewcapture_args_parser.h b/src/trace_processor/plugins/winscope_importer/viewcapture_args_parser.h index 69cd12cf01..18099b401f 100644 --- a/src/trace_processor/plugins/winscope_importer/viewcapture_args_parser.h +++ b/src/trace_processor/plugins/winscope_importer/viewcapture_args_parser.h @@ -30,7 +30,7 @@ namespace perfetto::trace_processor::winscope { class ViewCaptureArgsParser : public ArgsParser { public: using Key = ArgsParser::Key; - using IidToStringMap = base::FlatHashMap; + using IidToStringMap = base::FlatHashMapV2; ViewCaptureArgsParser(int64_t packet_timestamp, ArgsTracker::BoundInserter& inserter, @@ -41,7 +41,7 @@ class ViewCaptureArgsParser : public ArgsParser { void AddInteger(Id flat_key, Id key, int64_t) override; void AddUnsignedInteger(Id flat_key, Id key, uint64_t) override; - base::FlatHashMap flat_key_to_iid_args; + base::FlatHashMapV2 flat_key_to_iid_args; private: bool TryAddDeinternedString(const Key&, uint64_t); diff --git a/src/trace_processor/plugins/winscope_importer/winscope_rect_tracker.h b/src/trace_processor/plugins/winscope_importer/winscope_rect_tracker.h index efb114d839..2b9c9efb8b 100644 --- a/src/trace_processor/plugins/winscope_importer/winscope_rect_tracker.h +++ b/src/trace_processor/plugins/winscope_importer/winscope_rect_tracker.h @@ -36,9 +36,9 @@ class WinscopeRectTracker { const tables::WinscopeRectTable::Id& GetOrInsertRow(geometry::Rect& rect); private: - base::FlatHashMap> + base::FlatHashMapV2> rows_; }; diff --git a/src/trace_processor/plugins/winscope_importer/winscope_transform_tracker.h b/src/trace_processor/plugins/winscope_importer/winscope_transform_tracker.h index d7fbebf7bc..9b1e12e1f5 100644 --- a/src/trace_processor/plugins/winscope_importer/winscope_transform_tracker.h +++ b/src/trace_processor/plugins/winscope_importer/winscope_transform_tracker.h @@ -37,9 +37,9 @@ class WinscopeTransformTracker { geometry::TransformMatrix& matrix); private: - base::FlatHashMap> + base::FlatHashMapV2> rows_; }; diff --git a/src/trace_processor/plugins/winscope_proto_to_args_with_defaults/winscope_proto_to_args_with_defaults.cc b/src/trace_processor/plugins/winscope_proto_to_args_with_defaults/winscope_proto_to_args_with_defaults.cc index cdd6c9f3b2..ec094f43b0 100644 --- a/src/trace_processor/plugins/winscope_proto_to_args_with_defaults/winscope_proto_to_args_with_defaults.cc +++ b/src/trace_processor/plugins/winscope_proto_to_args_with_defaults/winscope_proto_to_args_with_defaults.cc @@ -125,9 +125,9 @@ using FlatKey = StringPool::Id; using Iid = int64_t; using DeinternedValue = StringPool::Id; -using DeinternedIids = base::FlatHashMap; -using InternedData = base::FlatHashMap; -using ProtoToInternedData = base::FlatHashMap; +using DeinternedIids = base::FlatHashMapV2; +using InternedData = base::FlatHashMapV2; +using ProtoToInternedData = base::FlatHashMapV2; ProtoToInternedData GetProtoToInternedData(const std::string& table_name, TraceStorage* storage) { diff --git a/src/trace_processor/rpc/httpd.cc b/src/trace_processor/rpc/httpd.cc index 50e90181c4..8b92dd6d45 100644 --- a/src/trace_processor/rpc/httpd.cc +++ b/src/trace_processor/rpc/httpd.cc @@ -101,7 +101,8 @@ class Httpd : public base::HttpRequestHandler { static void ServeHelpPage(const base::HttpRequest&); Rpc& global_trace_processor_rpc_; - base::FlatHashMap conns_; + base::FlatHashMapV2 + conns_; base::MaybeLockFreeTaskRunner task_runner_; base::HttpServer http_srv_; std::unique_ptr reaper_; diff --git a/src/trace_processor/rpc/rpc.h b/src/trace_processor/rpc/rpc.h index 4ea802e672..2b88933ee3 100644 --- a/src/trace_processor/rpc/rpc.h +++ b/src/trace_processor/rpc/rpc.h @@ -249,7 +249,7 @@ class Rpc { size_t bytes_parsed_ = 0; // Manages Summarizer instances keyed by caller-provided ID. - base::FlatHashMap> summarizers_; + base::FlatHashMapV2> summarizers_; }; } // namespace trace_processor diff --git a/src/trace_processor/trace_processor_impl.cc b/src/trace_processor/trace_processor_impl.cc index d0bba8f312..b7f7679360 100644 --- a/src/trace_processor/trace_processor_impl.cc +++ b/src/trace_processor/trace_processor_impl.cc @@ -794,7 +794,7 @@ namespace { class StringInterner { public: StringInterner(protos::pbzero::PerfettoMetatrace& event, - base::FlatHashMap& interned_strings) + base::FlatHashMapV2& interned_strings) : event_(event), interned_strings_(interned_strings) {} ~StringInterner() { @@ -816,7 +816,7 @@ class StringInterner { private: protos::pbzero::PerfettoMetatrace& event_; - base::FlatHashMap& interned_strings_; + base::FlatHashMapV2& interned_strings_; base::SmallVector, 16> new_interned_strings_; }; @@ -835,7 +835,7 @@ base::Status TraceProcessorImpl::DisableAndReadMetatrace( } auto tid = static_cast(base::GetThreadId()); - base::FlatHashMap interned_strings; + base::FlatHashMapV2 interned_strings; metatrace::DisableAndReadBuffer( [&trace, &interned_strings, tid](metatrace::Record* record) { auto* packet = trace->add_packet(); diff --git a/src/trace_processor/trace_summary/summarizer.cc b/src/trace_processor/trace_summary/summarizer.cc index d5ff7d6d2a..027384bebf 100644 --- a/src/trace_processor/trace_summary/summarizer.cc +++ b/src/trace_processor/trace_summary/summarizer.cc @@ -246,7 +246,7 @@ base::Status SummarizerImpl::UpdateSpec(const uint8_t* spec_data, TraceSummarySpec::Decoder spec_decoder(spec_data, spec_size); // Track which query IDs are in the new spec. - base::FlatHashMap new_query_ids; + base::FlatHashMapV2 new_query_ids; // Parse all queries from the spec and store them. for (auto it = spec_decoder.query(); it; ++it) { @@ -361,7 +361,7 @@ base::Status SummarizerImpl::UpdateSpec(const uint8_t* spec_data, std::vector SummarizerImpl::CollectDependencies( const std::string& query_id) { std::vector deps; - base::FlatHashMap visited; + base::FlatHashMapV2 visited; // Walk up the dependency chain and collect in reverse order. std::vector stack; diff --git a/src/trace_processor/trace_summary/summarizer.h b/src/trace_processor/trace_summary/summarizer.h index 306a78e831..47d1b111b2 100644 --- a/src/trace_processor/trace_summary/summarizer.h +++ b/src/trace_processor/trace_summary/summarizer.h @@ -129,8 +129,8 @@ class SummarizerImpl : public Summarizer { TraceProcessor* tp_; DescriptorPool* descriptor_pool_; std::string id_; - base::FlatHashMap query_states_; - base::FlatHashMap + base::FlatHashMapV2 query_states_; + base::FlatHashMapV2 included_modules_; // Track included modules. uint32_t next_materialized_id_ = 0; }; diff --git a/src/trace_processor/trace_summary/summary.cc b/src/trace_processor/trace_summary/summary.cc index 1aaff8158d..401d877f2d 100644 --- a/src/trace_processor/trace_summary/summary.cc +++ b/src/trace_processor/trace_summary/summary.cc @@ -661,7 +661,8 @@ base::Status WriteInternedDimensionBundles( base::Status CreateQueriesAndComputeMetrics(TraceProcessor* processor, const std::vector& metrics, TraceSummary* summary) { - base::FlatHashMap> metrics_by_bundle; + base::FlatHashMapV2> + metrics_by_bundle; for (const Metric& m : metrics) { TraceMetricV2Spec::Decoder spec_decoder(m.spec); std::string bundle_id = spec_decoder.bundle_id().ToStdString(); @@ -952,7 +953,7 @@ base::Status Summarize(TraceProcessor* processor, } } - base::FlatHashMap queries_per_metric; + base::FlatHashMapV2 queries_per_metric; std::vector metrics; for (const auto& id : metric_ids) { if (base::CaseInsensitiveEqual(id, "all")) { diff --git a/src/trace_processor/types/trace_manifest_state.h b/src/trace_processor/types/trace_manifest_state.h index f8ddef2857..b393f030f5 100644 --- a/src/trace_processor/types/trace_manifest_state.h +++ b/src/trace_processor/types/trace_manifest_state.h @@ -106,7 +106,7 @@ struct TraceManifestState { // (embedded uint32 id -> synthetic raw id), which the proto dispatcher uses // to place remote machines. std::vector> machine_mappings; - base::FlatHashMap machine_remap; + base::FlatHashMapV2 machine_remap; // Set when the entry has an internal `__exported_table_schema` block // (mutually exclusive with the trace-configuration blocks above). std::optional exported_table_schema; @@ -132,7 +132,7 @@ struct TraceManifestState { // clock-referenced) machine and records it here, so references resolve to // real rows at parse time and ForkContextForTrace (via MachineTracker) reuses // the same row when the file is later forked. - base::FlatHashMap raw_id_to_table_id; + base::FlatHashMapV2 raw_id_to_table_id; FileEntry* FindEntry(const std::string& path) { for (FileEntry& entry : files) { diff --git a/src/trace_processor/types/trace_processor_context.h b/src/trace_processor/types/trace_processor_context.h index 016938d5f6..ceb57b62da 100644 --- a/src/trace_processor/types/trace_processor_context.h +++ b/src/trace_processor/types/trace_processor_context.h @@ -125,7 +125,7 @@ class TraceProcessorContext { // by the manifest state, which outlives parsing). The proto dispatcher // forks remote machines onto these instead of rejecting. Null for other // files. - const base::FlatHashMap* machine_remap = nullptr; + const base::FlatHashMapV2* machine_remap = nullptr; }; struct UuidState { @@ -320,12 +320,12 @@ class TraceProcessorContext { class TraceProcessorContext::ForkedContextState { public: using TraceIdAndMachineId = std::pair; - base::FlatHashMap, - base::MurmurHash> + base::FlatHashMapV2, + base::MurmurHash> trace_and_machine_to_context; - base::FlatHashMap trace_to_context; - base::FlatHashMap machine_to_context; + base::FlatHashMapV2 trace_to_context; + base::FlatHashMapV2 machine_to_context; }; } // namespace perfetto::trace_processor diff --git a/src/trace_processor/util/args_utils.cc b/src/trace_processor/util/args_utils.cc index 9f8d975e16..9f090c918a 100644 --- a/src/trace_processor/util/args_utils.cc +++ b/src/trace_processor/util/args_utils.cc @@ -54,7 +54,8 @@ ArgNode ArgNode::Dict() { ArgNode node(Variadic::Null()); node.type_ = Type::kDict; node.dict_ = std::make_unique>>(); - node.dict_index_ = std::make_unique>(); + node.dict_index_ = + std::make_unique>(); node.primitive_value_ = Variadic::Null(); return node; } diff --git a/src/trace_processor/util/args_utils.h b/src/trace_processor/util/args_utils.h index 1761174a66..b7798c5418 100644 --- a/src/trace_processor/util/args_utils.h +++ b/src/trace_processor/util/args_utils.h @@ -78,7 +78,7 @@ class ArgNode { // Use vector of pairs to preserve insertion order. std::unique_ptr>> dict_; // Index for O(1) lookup in dict_. Maps key -> index in dict_ vector. - std::unique_ptr> dict_index_; + std::unique_ptr> dict_index_; }; class ArgSet { diff --git a/src/trace_processor/util/interned_message_view.h b/src/trace_processor/util/interned_message_view.h index 7b10b7be7c..3984718eb4 100644 --- a/src/trace_processor/util/interned_message_view.h +++ b/src/trace_processor/util/interned_message_view.h @@ -125,8 +125,8 @@ class InternedMessageView { private: using SubMessageViewMap = - base::FlatHashMap>; + base::FlatHashMapV2>; TraceBlobView message_; diff --git a/src/trace_processor/util/profile_builder.h b/src/trace_processor/util/profile_builder.h index 1e20dd1444..56ce8b26bb 100644 --- a/src/trace_processor/util/profile_builder.h +++ b/src/trace_processor/util/profile_builder.h @@ -280,9 +280,9 @@ class GProfileBuilder { loc.data.size())); } }; - base::FlatHashMap, - base::MurmurHash> + base::FlatHashMapV2, + base::MurmurHash> samples_; }; diff --git a/src/trace_processor/util/proto_to_args_parser.h b/src/trace_processor/util/proto_to_args_parser.h index 759b725876..6074b705f4 100644 --- a/src/trace_processor/util/proto_to_args_parser.h +++ b/src/trace_processor/util/proto_to_args_parser.h @@ -404,7 +404,7 @@ class ProtoToArgsParser { uint32_t flat_generation = 0; bool flat_eligible = false; - base::FlatHashMap flat_fields; + base::FlatHashMapV2 flat_fields; // The override registered for this node's flat key, if any. Looked up // once when the node is created, so overrides must be registered before // the first parse. @@ -453,7 +453,7 @@ class ProtoToArgsParser { // DebugAnnotation / NestedValue dictionary and array entries. void InternCurrentKey(); - base::FlatHashMap field_overrides_; + base::FlatHashMapV2 field_overrides_; const DescriptorPool& pool_; StringPool& string_pool_; // Arena of traversal-tree nodes, referenced by index. Persists across parses; @@ -466,7 +466,7 @@ class ProtoToArgsParser { std::vector flag_views_; // Edge -> child node index in |path_nodes_| (see |PathEdgeKey|). Roots are // keyed by pool descriptor index under the kNoPath parent. - base::FlatHashMap path_index_; + base::FlatHashMapV2 path_index_; Key key_prefix_; // Parameters to ParseMessage that apply uniformly to every ProtoMessage // WorkItem on the stack. Set by ParseMessage; read by StepProtoMessage. diff --git a/src/trace_processor/util/sql_modules.h b/src/trace_processor/util/sql_modules.h index 2228b077d4..0c51ea5dda 100644 --- a/src/trace_processor/util/sql_modules.h +++ b/src/trace_processor/util/sql_modules.h @@ -30,8 +30,8 @@ namespace perfetto::trace_processor::sql_modules { using NameToPackage = - base::FlatHashMap>>; + base::FlatHashMapV2>>; // A package registered with |PerfettoSqlDatabase|. Each entry in |modules| // maps the include key (the string used in INCLUDE PERFETTO MODULE) to the @@ -42,7 +42,7 @@ using NameToPackage = // // The string_view bodies must outlive every connection holding this package. struct RegisteredPackage { - base::FlatHashMap modules; + base::FlatHashMapV2 modules; // Whether the package is the standard library built into the binary, as // opposed to one a caller registered. bool builtin = false; diff --git a/src/trace_processor/util/trace_type.h b/src/trace_processor/util/trace_type.h index 3e1c9f424b..d7a214726e 100644 --- a/src/trace_processor/util/trace_type.h +++ b/src/trace_processor/util/trace_type.h @@ -185,9 +185,9 @@ class TraceImporterRegistry { bool IsContainer(TraceImporterId id) const; private: - base::FlatHashMap, - TraceImporterId::Hasher> + base::FlatHashMapV2, + TraceImporterId::Hasher> importers_; };