Migrate quic_trace to use Swisstable
This was already done internally, but I redid it while switching some
instances of node_hash_map to flat_hash_map
diff --git a/WORKSPACE b/WORKSPACE
index c4ea71e..f39be31 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -22,7 +22,7 @@
git_repository(
name = "com_google_absl",
- commit = "c075ad321696fa5072e097f0a51e4fe76a6fe13e",
+ commit = "66f9becbb98ecc083f4db349b4b1e0ca9de93b15",
remote = "https://github.com/abseil/abseil-cpp.git",
)
diff --git a/lib/analysis/BUILD b/lib/analysis/BUILD
index a05e0ff..2cefd44 100644
--- a/lib/analysis/BUILD
+++ b/lib/analysis/BUILD
@@ -21,5 +21,8 @@
cc_library(
name = "numbering",
hdrs = ["trace_numbering.h"],
- deps = ["//lib:quic_trace_cc_proto"],
+ deps = [
+ "//lib:quic_trace_cc_proto",
+ "@com_google_absl//absl/container:flat_hash_map",
+ ],
)
diff --git a/lib/analysis/trace_numbering.h b/lib/analysis/trace_numbering.h
index ffae8cf..76a38ed 100644
--- a/lib/analysis/trace_numbering.h
+++ b/lib/analysis/trace_numbering.h
@@ -20,6 +20,7 @@
#include <cstdint>
#include <unordered_map>
+#include "absl/container/flat_hash_map.h"
#include "lib/quic_trace.pb.h"
namespace quic_trace {
@@ -59,7 +60,7 @@
private:
TraceOffset current_offset_ = 0;
- std::unordered_map<uint64_t, Interval> offsets_;
+ absl::flat_hash_map<uint64_t, Interval> offsets_;
};
} // namespace quic_trace
diff --git a/tools/BUILD b/tools/BUILD
index 191af25..af501f0 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -20,6 +20,8 @@
deps = [
"//lib:quic_trace_cc_proto",
"@com_github_gflags_gflags//:gflags",
+ "@com_google_absl//absl/container:flat_hash_map",
+ "@com_google_absl//absl/container:flat_hash_set",
],
)
diff --git a/tools/quic_trace_to_time_sequence_gnuplot.cc b/tools/quic_trace_to_time_sequence_gnuplot.cc
index 76d5279..7f7307c 100644
--- a/tools/quic_trace_to_time_sequence_gnuplot.cc
+++ b/tools/quic_trace_to_time_sequence_gnuplot.cc
@@ -18,6 +18,8 @@
#include <iostream>
+#include "absl/container/flat_hash_map.h"
+#include "absl/container/flat_hash_set.h"
#include "gflags/gflags.h"
#include "lib/quic_trace.pb.h"
@@ -54,7 +56,7 @@
size_t size;
};
// Map of the sent packets, keyed by packet number.
-using SentPacketMap = std::unordered_map<uint64_t, SentPacket>;
+using SentPacketMap = absl::flat_hash_map<uint64_t, SentPacket>;
void PrintSentPacket(const SentPacketMap& packet_map,
uint64_t packet_number,
@@ -78,7 +80,7 @@
size_t total_sent = 0;
SentPacketMap packet_map;
- std::unordered_set<uint64_t> already_acknowledged;
+ absl::flat_hash_set<uint64_t> already_acknowledged;
// In a single pass, compute |packet_map| and output the requested sequence.
for (const Event& event : trace.events()) {
// Track all sent packets and their offsets in the plot.
diff --git a/tools/render/BUILD b/tools/render/BUILD
index 5ceefd2..edaa29a 100644
--- a/tools/render/BUILD
+++ b/tools/render/BUILD
@@ -51,6 +51,9 @@
"//third_party/glew",
"@com_github_gflags_gflags//:gflags",
"@com_google_absl//absl/algorithm:container",
+ "@com_google_absl//absl/container:flat_hash_map",
+ "@com_google_absl//absl/container:flat_hash_set",
+ "@com_google_absl//absl/container:node_hash_map",
"@com_google_absl//absl/memory",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/types:optional",
diff --git a/tools/render/processed_trace.h b/tools/render/processed_trace.h
index f772e7c..5484a5f 100644
--- a/tools/render/processed_trace.h
+++ b/tools/render/processed_trace.h
@@ -15,6 +15,8 @@
#ifndef THIRD_PARTY_QUIC_TRACE_TOOLS_PROCESSED_TRACE_H_
#define THIRD_PARTY_QUIC_TRACE_TOOLS_PROCESSED_TRACE_H_
+#include "absl/container/flat_hash_map.h"
+#include "absl/container/flat_hash_set.h"
#include "lib/analysis/trace_numbering.h"
#include "lib/quic_trace.pb.h"
#include "tools/render/table.h"
@@ -79,12 +81,12 @@
PacketType type);
std::unique_ptr<Trace> trace_;
- std::unordered_set<uint64_t> packets_acked_;
- std::unordered_set<uint64_t> packets_lost_;
+ absl::flat_hash_set<uint64_t> packets_acked_;
+ absl::flat_hash_set<uint64_t> packets_lost_;
// Map from packet-as-drawn offset to the ack. This is required because
// unlike sent or lost packets, there could be many acks derived from the same
// Event object.
- std::unordered_map<vec2, uint64_t, VectorHash> acks_;
+ absl::flat_hash_map<vec2, uint64_t, VectorHash> acks_;
std::vector<RenderedPacket> rendered_packets_;
};
diff --git a/tools/render/text.h b/tools/render/text.h
index a57e863..abb58f8 100644
--- a/tools/render/text.h
+++ b/tools/render/text.h
@@ -18,6 +18,7 @@
#include <memory>
#include <unordered_map>
+#include "absl/container/node_hash_map.h"
#include "external/sdl2_ttf/SDL_ttf.h"
#include "tools/render/program_state.h"
#include "tools/render/sdl_util.h"
@@ -97,7 +98,7 @@
// The text cache. Used to avoid having to render the text into texture every
// frame. All entries that are not rendered within the past frame are
// evicted.
- std::unordered_map<std::string, CacheEntry> cache_;
+ absl::node_hash_map<std::string, CacheEntry> cache_;
};
} // namespace render