Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/trace_processor/containers/string_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<StringHash,
Id,
base::AlreadyHashed<StringHash>,
base::LinearProbe,
/*AppendOnly=*/true>
base::FlatHashMapV2<StringHash, Id, base::AlreadyHashed<StringHash>>
string_index_ PERFETTO_GUARDED_BY(mutex_){/*initial_capacity=*/4096u};
};

Expand Down
2 changes: 1 addition & 1 deletion src/trace_processor/core/common/string_ranks.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class StringRanks {
void Clear() { ranks_.Clear(); }

private:
base::FlatHashMap<StringPool::Id, uint32_t> ranks_;
base::FlatHashMapV2<StringPool::Id, uint32_t> ranks_;
};

} // namespace perfetto::trace_processor::core
Expand Down
2 changes: 1 addition & 1 deletion src/trace_processor/core/dataframe/arrow_serializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct ArrowSerializer::BodyPlan {

struct ArrowSerializer::DictionaryPlan {
std::vector<StringPool::Id> values;
base::FlatHashMap<uint32_t, uint32_t> index_by_id;
base::FlatHashMapV2<uint32_t, uint32_t> index_by_id;
uint32_t data_length = 0;
uint64_t body_size = 0;
std::vector<arrow_internal::ArrowBuffer> buffers;
Expand Down
2 changes: 1 addition & 1 deletion src/trace_processor/core/dataframe/bytecode_lowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class BytecodeLowering {
IndicesReg indices_reg_;

// Tracks which columns have had PrefixPopcount bytecode emitted.
base::FlatHashMap<uint32_t, bool> prefix_popcount_emitted_;
base::FlatHashMapV2<uint32_t, bool> prefix_popcount_emitted_;

// Last scratch registers returned by GetOrCreateScratchSpanRegister.
std::optional<Scratch> scratch_;
Expand Down
4 changes: 2 additions & 2 deletions src/trace_processor/core/dataframe/dataframe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<int64_t, uint32_t>& counts,
uint32_t EstimateDistinct(base::FlatHashMapV2<int64_t, uint32_t>& counts,
const Column& c) {
if (!c.duplicate_state.Is<HasDuplicates>()) {
return 0;
Expand Down Expand Up @@ -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<int64_t, uint32_t> distinct_counts;
base::FlatHashMapV2<int64_t, uint32_t> distinct_counts;
for (const auto& c : columns_) {
switch (c->storage.type().index()) {
case StorageType::GetTypeIndex<Uint32>():
Expand Down
2 changes: 1 addition & 1 deletion src/trace_processor/core/exec/tree_number_nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class TreeNumberNodes final : public Transform {
// so the map stays empty.
bool dense = true;
uint32_t numbered = 0;
base::FlatHashMap<Key, uint32_t> numbers;
base::FlatHashMapV2<Key, uint32_t> 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.
Expand Down
4 changes: 2 additions & 2 deletions src/trace_processor/core/plugin/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ PluginSet BuildPluginSet() {
}

// Build a map from plugin_id -> index in |regs|.
base::FlatHashMap<const void*, size_t> id_to_idx;
base::FlatHashMapV2<const void*, size_t> id_to_idx;
for (size_t i = 0; i < regs.size(); ++i) {
id_to_idx[regs[i]->plugin_id] = i;
}
Expand Down Expand Up @@ -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<const void*, size_t> id_to_sorted_idx;
base::FlatHashMapV2<const void*, size_t> 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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/trace_processor/core/tree/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct Tree {
std::vector<uint32_t> 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<base::FlatHashMap<int64_t, uint32_t>> hash;
std::optional<base::FlatHashMapV2<int64_t, uint32_t>> 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
Expand Down
4 changes: 2 additions & 2 deletions src/trace_processor/core/util/ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct RowLayoutKey {
} // namespace

template <typename T>
uint32_t EstimateDistinctCount(base::FlatHashMap<int64_t, uint32_t>* counts,
uint32_t EstimateDistinctCount(base::FlatHashMapV2<int64_t, uint32_t>* counts,
Span<const T> values) {
const uint64_t total = values.size();
if (total == 0) {
Expand Down Expand Up @@ -169,7 +169,7 @@ void SortRowLayout(Span<const uint8_t> row_layout,

#define PERFETTO_INSTANTIATE_DISTINCT(type) \
template uint32_t EstimateDistinctCount<type>( \
base::FlatHashMap<int64_t, uint32_t>*, Span<const type>);
base::FlatHashMapV2<int64_t, uint32_t>*, Span<const type>);
PERFETTO_INSTANTIATE_DISTINCT(uint32_t)
PERFETTO_INSTANTIATE_DISTINCT(int32_t)
PERFETTO_INSTANTIATE_DISTINCT(int64_t)
Expand Down
4 changes: 2 additions & 2 deletions src/trace_processor/core/util/ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void GatherNullableRows(Span<const T> source,

// Estimates the number of distinct values using a bounded strided sample.
template <typename T>
uint32_t EstimateDistinctCount(base::FlatHashMap<int64_t, uint32_t>* counts,
uint32_t EstimateDistinctCount(base::FlatHashMapV2<int64_t, uint32_t>* counts,
Span<const T> values);

// Removes duplicate fixed-width rows and compacts |indices| in place. Rows in
Expand All @@ -92,7 +92,7 @@ void SortRowLayout(Span<const uint8_t> row_layout,

#define PERFETTO_DECLARE_DISTINCT(type) \
extern template uint32_t EstimateDistinctCount<type>( \
base::FlatHashMap<int64_t, uint32_t>*, Span<const type>);
base::FlatHashMapV2<int64_t, uint32_t>*, Span<const type>);
PERFETTO_DECLARE_DISTINCT(uint32_t)
PERFETTO_DECLARE_DISTINCT(int32_t)
PERFETTO_DECLARE_DISTINCT(int64_t)
Expand Down
2 changes: 1 addition & 1 deletion src/trace_processor/core/util/ops_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ TEST(OpsTest, GatherNullableRowsInPlace) {
}

TEST(OpsTest, EstimateDistinctCount) {
base::FlatHashMap<int64_t, uint32_t> counts;
base::FlatHashMapV2<int64_t, uint32_t> counts;
const int32_t values[] = {1, 2, 1, 3};
EXPECT_EQ(EstimateDistinctCount(&counts, MakeSpan(values)), 3u);

Expand Down
4 changes: 2 additions & 2 deletions src/trace_processor/export_json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,8 @@ class JsonExporter {
}

const TraceStorage* storage_;
base::FlatHashMap<ArgSetId, Dom> args_sets_;
base::FlatHashMap<ArgSetId, int64_t> legacy_trace_ids_;
base::FlatHashMapV2<ArgSetId, Dom> args_sets_;
base::FlatHashMapV2<ArgSetId, int64_t> legacy_trace_ids_;
const Dom empty_value_;
};

Expand Down
12 changes: 6 additions & 6 deletions src/trace_processor/importers/art_hprof/art_heap_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint64_t, ClassDefinition> cls) {
void SetClasses(base::FlatHashMapV2<uint64_t, ClassDefinition> cls) {
classes_ = std::move(cls);
}
void SetStrings(base::FlatHashMap<uint64_t, StringId> strs) {
void SetStrings(base::FlatHashMapV2<uint64_t, StringId> strs) {
strings_ = std::move(strs);
}

Expand All @@ -59,7 +59,7 @@ class HeapGraph {

uint32_t GetIdSize() const { return id_size_; }

const base::FlatHashMap<uint64_t, ClassDefinition>& GetClasses() const {
const base::FlatHashMapV2<uint64_t, ClassDefinition>& GetClasses() const {
return classes_;
}

Expand Down Expand Up @@ -114,9 +114,9 @@ class HeapGraph {
private:
ObjectStore objects_;
ClassFieldLayouts class_fields_;
base::FlatHashMap<uint64_t, ClassDefinition> classes_;
base::FlatHashMap<uint64_t, StringId> strings_;
base::FlatHashMap<uint32_t, std::string> heap_id_to_name_;
base::FlatHashMapV2<uint64_t, ClassDefinition> classes_;
base::FlatHashMapV2<uint64_t, StringId> strings_;
base::FlatHashMapV2<uint32_t, std::string> heap_id_to_name_;
uint64_t timestamp_;
uint32_t id_size_ = 4;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ class HeapGraphResolver {
HeapGraphResolver(TraceProcessorContext* context,
HprofHeader& header,
ObjectStore& objects,
base::FlatHashMap<uint64_t, ClassDefinition>& classes,
base::FlatHashMap<uint64_t, HprofHeapRootTag>& roots,
base::FlatHashMapV2<uint64_t, ClassDefinition>& classes,
base::FlatHashMapV2<uint64_t, HprofHeapRootTag>& roots,
ClassFieldLayouts& class_fields,
uint64_t string_class_id,
DebugStats& stats);
Expand All @@ -134,8 +134,8 @@ class HeapGraphResolver {
TraceProcessorContext* context_;
HprofHeader& header_;
ObjectStore& objects_;
base::FlatHashMap<uint64_t, HprofHeapRootTag>& roots_;
base::FlatHashMap<uint64_t, ClassDefinition>& classes_;
base::FlatHashMapV2<uint64_t, HprofHeapRootTag>& roots_;
base::FlatHashMapV2<uint64_t, ClassDefinition>& classes_;
ClassFieldLayouts& class_fields_;
DebugStats& stats_;

Expand Down Expand Up @@ -251,15 +251,15 @@ class HeapGraphBuilder {
StringId current_heap_;

// Data collections
base::FlatHashMap<uint64_t, StringId> strings_;
base::FlatHashMap<uint64_t, ClassDefinition> classes_;
base::FlatHashMapV2<uint64_t, StringId> strings_;
base::FlatHashMapV2<uint64_t, ClassDefinition> classes_;
ObjectStore objects_;
ClassFieldLayouts class_fields_;

// Type mapping and root tracking
std::array<uint64_t, 12> prim_array_class_ids_ = {};
uint64_t string_class_id_ = 0;
base::FlatHashMap<uint64_t, HprofHeapRootTag> roots_;
base::FlatHashMapV2<uint64_t, HprofHeapRootTag> roots_;

// Debug statistics
DebugStats stats_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ HeapGraphResolver::HeapGraphResolver(
TraceProcessorContext* context,
HprofHeader& header,
ObjectStore& objects,
base::FlatHashMap<uint64_t, ClassDefinition>& classes,
base::FlatHashMap<uint64_t, HprofHeapRootTag>& roots,
base::FlatHashMapV2<uint64_t, ClassDefinition>& classes,
base::FlatHashMapV2<uint64_t, HprofHeapRootTag>& roots,
ClassFieldLayouts& class_fields,
uint64_t string_class_id,
DebugStats& stats)
Expand Down Expand Up @@ -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<uint64_t, bool> weak_ref_classes;
base::FlatHashMapV2<uint64_t, bool> weak_ref_classes;
{
base::FlatHashMap<uint64_t, bool> base_refs;
base::FlatHashMapV2<uint64_t, bool> base_refs;
for (auto it = classes_.GetIterator(); it; ++it) {
const auto& name = it.value().GetName();
if (name == "java.lang.ref.WeakReference" ||
Expand Down
4 changes: 2 additions & 2 deletions src/trace_processor/importers/art_hprof/art_hprof_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ struct ClassFieldLayout {
std::vector<ObjectFieldRef> object_fields;
};

using ClassFieldLayouts = base::FlatHashMap<uint64_t, ClassFieldLayout>;
using ClassFieldLayouts = base::FlatHashMapV2<uint64_t, ClassFieldLayout>;

// 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
Expand Down Expand Up @@ -370,7 +370,7 @@ class ObjectStore {
}

private:
base::FlatHashMap<uint64_t, ObjectIndex> index_;
base::FlatHashMapV2<uint64_t, ObjectIndex> index_;
std::vector<Object> objects_;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ void ArtHprofParser::PopulateClasses(const HeapGraph& graph) {
// "referent" field during BFS.
{
// Find base reference type class IDs
base::FlatHashMap<uint64_t, const char*> base_ref_kinds;
base::FlatHashMapV2<uint64_t, const char*> base_ref_kinds;
for (auto it = graph.GetClasses().GetIterator(); it; ++it) {
const auto& name = it.value().GetName();
if (name == "java.lang.ref.WeakReference") {
Expand Down
6 changes: 3 additions & 3 deletions src/trace_processor/importers/art_hprof/art_hprof_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ class ArtHprofParser : public ChunkedTraceReader {
std::unique_ptr<HeapGraphBuilder> parser_;

// HPROF ID → table row ID mappings, used during PopulateObjects/References.
base::FlatHashMap<uint64_t, tables::HeapGraphClassTable::Id> class_map_;
base::FlatHashMap<uint64_t, tables::HeapGraphClassTable::Id>
base::FlatHashMapV2<uint64_t, tables::HeapGraphClassTable::Id> class_map_;
base::FlatHashMapV2<uint64_t, tables::HeapGraphClassTable::Id>
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<uint32_t>::max();
std::vector<uint32_t> object_rows_;
base::FlatHashMap<uint64_t, std::string> class_name_map_;
base::FlatHashMapV2<uint64_t, std::string> class_name_map_;
};
} // namespace perfetto::trace_processor::art_hprof
#endif // SRC_TRACE_PROCESSOR_IMPORTERS_ART_HPROF_ART_HPROF_PARSER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ class ArtMethodTokenizer : public ChunkedTraceReader {
uint32_t version_ = std::numeric_limits<uint32_t>::max();
int64_t ts_ = std::numeric_limits<int64_t>::max();
uint32_t record_size_ = std::numeric_limits<uint32_t>::max();
base::FlatHashMap<uint32_t, Method> method_map_;
base::FlatHashMap<uint32_t, Thread> thread_map_;
base::FlatHashMapV2<uint32_t, Method> method_map_;
base::FlatHashMapV2<uint32_t, Thread> thread_map_;
std::unique_ptr<TraceSorter::Stream<ArtMethodEvent>> stream_;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class ArtMethodV2Tokenizer : public ChunkedTraceReader {
uint64_t tsc_frequency_ = 0;
std::string summary_;

base::FlatHashMap<uint64_t, ThreadInfo> thread_map_;
base::FlatHashMap<uint64_t, MethodInfo> method_map_;
base::FlatHashMapV2<uint64_t, ThreadInfo> thread_map_;
base::FlatHashMapV2<uint64_t, MethodInfo> method_map_;
};

} // namespace perfetto::trace_processor::art_method
Expand Down
2 changes: 1 addition & 1 deletion src/trace_processor/importers/common/args_tracker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ ArgsInserter& ArgsInserter::AddArg(StringId flat_key,
Variadic value,
UpdatePolicy update_policy) {
std::vector<CompactArg>& args = buffer_->args;
base::FlatHashMap<StringId, uint32_t>& key_index = buffer_->key_index;
base::FlatHashMapV2<StringId, uint32_t>& 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.
Expand Down
15 changes: 8 additions & 7 deletions src/trace_processor/importers/common/args_translation_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ArgsTranslationTable {
const DeobfuscationMappingTable::PackageId& package,
StringId obfuscated_class,
StringId deobfuscated_class,
base::FlatHashMap<StringId, StringId> members) {
base::FlatHashMapV2<StringId, StringId> members) {
deobfuscation_mapping_table_.AddClassTranslation(
package, obfuscated_class, deobfuscated_class, std::move(members));
}
Expand Down Expand Up @@ -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<uint64_t, std::string> chrome_histogram_hash_to_name_;
base::FlatHashMap<uint64_t, std::string> chrome_user_event_hash_to_action_;
base::FlatHashMap<uint64_t, std::string>
base::FlatHashMapV2<uint64_t, std::string> chrome_histogram_hash_to_name_;
base::FlatHashMapV2<uint64_t, std::string> chrome_user_event_hash_to_action_;
base::FlatHashMapV2<uint64_t, std::string>
chrome_performance_mark_site_hash_to_name_;
base::FlatHashMap<uint64_t, std::string>
base::FlatHashMapV2<uint64_t, std::string>
chrome_performance_mark_mark_hash_to_name_;
base::FlatHashMap<uint64_t, std::string> chrome_study_hash_to_name_;
base::FlatHashMap<NativeSymbolKey, SourceLocation> native_symbol_to_location_;
base::FlatHashMapV2<uint64_t, std::string> chrome_study_hash_to_name_;
base::FlatHashMapV2<NativeSymbolKey, SourceLocation>
native_symbol_to_location_;
// A translation mapping for obfuscated Java class names and its members.
DeobfuscationMappingTable deobfuscation_mapping_table_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ TEST(ArgsTranslationTable, TranslateClassName) {
DeobfuscationMappingTable deobfuscation_mapping;
deobfuscation_mapping.AddClassTranslation(
DeobfuscationMappingTable::PackageId{"app", 123}, xyz_id, class_x_id,
base::FlatHashMap<StringId, StringId>{});
base::FlatHashMapV2<StringId, StringId>{});
ArgsTranslationTable table(&storage);
table.AddDeobfuscationMappingTable(std::move(deobfuscation_mapping));

Expand Down
2 changes: 1 addition & 1 deletion src/trace_processor/importers/common/clock_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ClockConverter {

TraceProcessorContext* context_;
bool is_initialized = false;
base::FlatHashMap<ClockId, Timeline> timelines_;
base::FlatHashMapV2<ClockId, Timeline> timelines_;
};

} // namespace trace_processor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ bool DeobfuscationMappingTable::AddClassTranslation(
const PackageId& package,
StringId obfuscated_class_name,
StringId deobfuscated_class_name,
base::FlatHashMap<StringId, StringId> obfuscated_to_deobfuscated_members) {
base::FlatHashMapV2<StringId, StringId>
obfuscated_to_deobfuscated_members) {
if (PERFETTO_UNLIKELY(!default_package_id_)) {
default_package_id_ = package;
}
Expand Down
Loading
Loading