Use absl::flat_hash_map in dawn/native

This patch replaces std:unordered_map and std::map with
absl::flat_hash_map in dawn/native when possible.

Bug: dawn:1513
Change-Id: I061253a20976de8c713d075b46cc314cc0b3c272
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/168801
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Loko Kung <lokokung@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/ApplyClearColorValueWithDrawHelper.cpp b/src/dawn/native/ApplyClearColorValueWithDrawHelper.cpp
index add41f1..59a4f65 100644
--- a/src/dawn/native/ApplyClearColorValueWithDrawHelper.cpp
+++ b/src/dawn/native/ApplyClearColorValueWithDrawHelper.cpp
@@ -175,7 +175,7 @@
 
     Ref<RenderPipelineBase> pipeline;
     DAWN_TRY_ASSIGN(pipeline, device->CreateRenderPipeline(&renderPipelineDesc));
-    store->applyClearColorValueWithDrawPipelines.insert({key, std::move(pipeline)});
+    store->applyClearColorValueWithDrawPipelines.emplace(key, std::move(pipeline));
 
     return GetCachedPipeline(store, key);
 }
diff --git a/src/dawn/native/ApplyClearColorValueWithDrawHelper.h b/src/dawn/native/ApplyClearColorValueWithDrawHelper.h
index ddf7179..b1a2a05 100644
--- a/src/dawn/native/ApplyClearColorValueWithDrawHelper.h
+++ b/src/dawn/native/ApplyClearColorValueWithDrawHelper.h
@@ -29,7 +29,8 @@
 #define SRC_DAWN_NATIVE_APPLYCLEARVALUEWITHDRAWHELPER_H_
 
 #include <bitset>
-#include <unordered_map>
+
+#include "absl/container/flat_hash_map.h"
 #include "dawn/common/ityp_array.h"
 #include "dawn/common/ityp_bitset.h"
 #include "dawn/native/Error.h"
@@ -54,10 +55,10 @@
                     const KeyOfApplyClearColorValueWithDrawPipelines key2) const;
 };
 using ApplyClearColorValueWithDrawPipelinesCache =
-    std::unordered_map<KeyOfApplyClearColorValueWithDrawPipelines,
-                       Ref<RenderPipelineBase>,
-                       KeyOfApplyClearColorValueWithDrawPipelinesHashFunc,
-                       KeyOfApplyClearColorValueWithDrawPipelinesEqualityFunc>;
+    absl::flat_hash_map<KeyOfApplyClearColorValueWithDrawPipelines,
+                        Ref<RenderPipelineBase>,
+                        KeyOfApplyClearColorValueWithDrawPipelinesHashFunc,
+                        KeyOfApplyClearColorValueWithDrawPipelinesEqualityFunc>;
 
 bool ShouldApplyClearBigIntegerColorValueWithDraw(const DeviceBase* device,
                                                   const RenderPassDescriptor* renderPassDescriptor);
diff --git a/src/dawn/native/AsyncTask.cpp b/src/dawn/native/AsyncTask.cpp
index 42bec37..45ac2e2 100644
--- a/src/dawn/native/AsyncTask.cpp
+++ b/src/dawn/native/AsyncTask.cpp
@@ -60,14 +60,11 @@
 
 void AsyncTaskManager::HandleTaskCompletion(WaitableTask* task) {
     std::lock_guard<std::mutex> lock(mPendingTasksMutex);
-    auto iter = mPendingTasks.find(task);
-    if (iter != mPendingTasks.end()) {
-        mPendingTasks.erase(iter);
-    }
+    mPendingTasks.erase(task);
 }
 
 void AsyncTaskManager::WaitAllPendingTasks() {
-    std::unordered_map<WaitableTask*, Ref<WaitableTask>> allPendingTasks;
+    absl::flat_hash_map<WaitableTask*, Ref<WaitableTask>> allPendingTasks;
 
     {
         std::lock_guard<std::mutex> lock(mPendingTasksMutex);
diff --git a/src/dawn/native/AsyncTask.h b/src/dawn/native/AsyncTask.h
index 454c848..8e465ca 100644
--- a/src/dawn/native/AsyncTask.h
+++ b/src/dawn/native/AsyncTask.h
@@ -31,8 +31,8 @@
 #include <functional>
 #include <memory>
 #include <mutex>
-#include <unordered_map>
 
+#include "absl/container/flat_hash_map.h"
 #include "dawn/common/Ref.h"
 #include "dawn/common/RefCounted.h"
 
@@ -73,7 +73,7 @@
     void HandleTaskCompletion(WaitableTask* task);
 
     std::mutex mPendingTasksMutex;
-    std::unordered_map<WaitableTask*, Ref<WaitableTask>> mPendingTasks;
+    absl::flat_hash_map<WaitableTask*, Ref<WaitableTask>> mPendingTasks;
     dawn::platform::WorkerTaskPool* mWorkerTaskPool;
 };
 
diff --git a/src/dawn/native/BlitBufferToDepthStencil.cpp b/src/dawn/native/BlitBufferToDepthStencil.cpp
index 382029c..64146f9 100644
--- a/src/dawn/native/BlitBufferToDepthStencil.cpp
+++ b/src/dawn/native/BlitBufferToDepthStencil.cpp
@@ -227,7 +227,7 @@
 
     InternalPipelineStore::BlitR8ToStencilPipelines pipelines{std::move(clearPipeline),
                                                               std::move(setStencilPipelines)};
-    store->blitR8ToStencilPipelines[format] = pipelines;
+    store->blitR8ToStencilPipelines.emplace(format, pipelines);
     return pipelines;
 }
 
diff --git a/src/dawn/native/BlitColorToColorWithDraw.cpp b/src/dawn/native/BlitColorToColorWithDraw.cpp
index 908eab5..3d9605e 100644
--- a/src/dawn/native/BlitColorToColorWithDraw.cpp
+++ b/src/dawn/native/BlitColorToColorWithDraw.cpp
@@ -155,7 +155,7 @@
     Ref<RenderPipelineBase> pipeline;
     DAWN_TRY_ASSIGN(pipeline, device->CreateRenderPipeline(&renderPipelineDesc));
 
-    store->msaaRenderToSingleSampledColorBlitPipelines[pipelineKey] = pipeline;
+    store->msaaRenderToSingleSampledColorBlitPipelines.emplace(pipelineKey, pipeline);
     return pipeline;
 }
 
diff --git a/src/dawn/native/BlitColorToColorWithDraw.h b/src/dawn/native/BlitColorToColorWithDraw.h
index ea4be55..a292226 100644
--- a/src/dawn/native/BlitColorToColorWithDraw.h
+++ b/src/dawn/native/BlitColorToColorWithDraw.h
@@ -28,8 +28,7 @@
 #ifndef SRC_DAWN_NATIVE_BLITCOLORTOCOLORWITHDRAW_H_
 #define SRC_DAWN_NATIVE_BLITCOLORTOCOLORWITHDRAW_H_
 
-#include <unordered_map>
-
+#include "absl/container/flat_hash_map.h"
 #include "dawn/native/Error.h"
 
 namespace dawn::native {
@@ -55,10 +54,10 @@
 };
 
 using BlitColorToColorWithDrawPipelinesCache =
-    std::unordered_map<BlitColorToColorWithDrawPipelineKey,
-                       Ref<RenderPipelineBase>,
-                       BlitColorToColorWithDrawPipelineKey::HashFunc,
-                       BlitColorToColorWithDrawPipelineKey::EqualityFunc>;
+    absl::flat_hash_map<BlitColorToColorWithDrawPipelineKey,
+                        Ref<RenderPipelineBase>,
+                        BlitColorToColorWithDrawPipelineKey::HashFunc,
+                        BlitColorToColorWithDrawPipelineKey::EqualityFunc>;
 
 // In a MSAA render to single sampled render pass, a color attachment will be used as resolve
 // target internally and an implicit MSAA texture will be used as the actual color attachment.
diff --git a/src/dawn/native/BlitDepthToDepth.cpp b/src/dawn/native/BlitDepthToDepth.cpp
index 1f71cdb..79d3da8 100644
--- a/src/dawn/native/BlitDepthToDepth.cpp
+++ b/src/dawn/native/BlitDepthToDepth.cpp
@@ -99,7 +99,7 @@
     Ref<RenderPipelineBase> pipeline;
     DAWN_TRY_ASSIGN(pipeline, device->CreateRenderPipeline(&renderPipelineDesc));
 
-    store->depthBlitPipelines[format] = pipeline;
+    store->depthBlitPipelines.emplace(format, pipeline);
     return pipeline;
 }
 
diff --git a/src/dawn/native/BlitTextureToBuffer.cpp b/src/dawn/native/BlitTextureToBuffer.cpp
index dad753c..ab04f78b 100644
--- a/src/dawn/native/BlitTextureToBuffer.cpp
+++ b/src/dawn/native/BlitTextureToBuffer.cpp
@@ -580,8 +580,8 @@
 
     Ref<ComputePipelineBase> pipeline;
     DAWN_TRY_ASSIGN(pipeline, device->CreateComputePipeline(&computePipelineDescriptor));
-    store->blitTextureToBufferComputePipelines.insert(
-        {std::make_pair(format.format, viewDimension), pipeline});
+    store->blitTextureToBufferComputePipelines.emplace(std::make_pair(format.format, viewDimension),
+                                                       pipeline);
     return pipeline;
 }
 
diff --git a/src/dawn/native/CommandBufferStateTracker.cpp b/src/dawn/native/CommandBufferStateTracker.cpp
index 4f6de48..2a24eed 100644
--- a/src/dawn/native/CommandBufferStateTracker.cpp
+++ b/src/dawn/native/CommandBufferStateTracker.cpp
@@ -30,10 +30,10 @@
 #include <limits>
 #include <optional>
 #include <type_traits>
-#include <unordered_map>
 #include <utility>
 #include <variant>
 
+#include "absl/container/flat_hash_map.h"
 #include "dawn/common/Assert.h"
 #include "dawn/common/BitSetIterator.h"
 #include "dawn/common/StackContainer.h"
@@ -349,8 +349,8 @@
 }
 
 MaybeError CommandBufferStateTracker::ValidateNoDifferentTextureViewsOnSameTexture() {
-    // TODO(dawn:1855): Look into optimizations as unordered_map does many allocations
-    std::unordered_map<const TextureBase*, VectorOfTextureViews> textureToViews;
+    // TODO(dawn:1855): Look into optimizations as flat_hash_map does many allocations
+    absl::flat_hash_map<const TextureBase*, VectorOfTextureViews> textureToViews;
 
     for (BindGroupIndex groupIndex :
          IterateBitSet(mLastPipelineLayout->GetBindGroupLayoutsMask())) {
diff --git a/src/dawn/native/CopyTextureForBrowserHelper.cpp b/src/dawn/native/CopyTextureForBrowserHelper.cpp
index c6202314..dba4ec4 100644
--- a/src/dawn/native/CopyTextureForBrowserHelper.cpp
+++ b/src/dawn/native/CopyTextureForBrowserHelper.cpp
@@ -367,7 +367,7 @@
         Ref<RenderPipelineBase> pipeline;
         DAWN_TRY_ASSIGN(
             pipeline, CreateCopyForBrowserPipeline(device, dstFormat, shaderModule, "copyTexture"));
-        store->copyTextureForBrowserPipelines.insert({dstFormat, std::move(pipeline)});
+        store->copyTextureForBrowserPipelines.emplace(dstFormat, std::move(pipeline));
     }
 
     return GetCachedCopyTexturePipeline(store, dstFormat);
@@ -383,7 +383,7 @@
         Ref<RenderPipelineBase> pipeline;
         DAWN_TRY_ASSIGN(pipeline, CreateCopyForBrowserPipeline(device, dstFormat, shaderModule,
                                                                "copyExternalTexture"));
-        store->copyExternalTextureForBrowserPipelines.insert({dstFormat, std::move(pipeline)});
+        store->copyExternalTextureForBrowserPipelines.emplace(dstFormat, std::move(pipeline));
     }
 
     return GetCachedCopyExternalTexturePipeline(store, dstFormat);
diff --git a/src/dawn/native/EventManager.h b/src/dawn/native/EventManager.h
index 2ffa16a..fec82b4 100644
--- a/src/dawn/native/EventManager.h
+++ b/src/dawn/native/EventManager.h
@@ -32,9 +32,9 @@
 #include <cstdint>
 #include <mutex>
 #include <optional>
-#include <unordered_map>
 #include <variant>
 
+#include "absl/container/flat_hash_map.h"
 #include "dawn/common/FutureUtils.h"
 #include "dawn/common/MutexProtected.h"
 #include "dawn/common/NonCopyable.h"
@@ -88,7 +88,7 @@
 
     // Freed once the user has dropped their last ref to the Instance, so can't call WaitAny or
     // ProcessEvents anymore. This breaks reference cycles.
-    using EventMap = std::unordered_map<FutureID, Ref<TrackedEvent>>;
+    using EventMap = absl::flat_hash_map<FutureID, Ref<TrackedEvent>>;
     std::optional<MutexProtected<EventMap>> mEvents;
 };
 
diff --git a/src/dawn/native/Features.h b/src/dawn/native/Features.h
index f94b24f..be1a88b 100644
--- a/src/dawn/native/Features.h
+++ b/src/dawn/native/Features.h
@@ -30,7 +30,6 @@
 
 #include <bitset>
 #include <string>
-#include <unordered_map>
 #include <vector>
 
 #include "dawn/common/ityp_bitset.h"
diff --git a/src/dawn/native/Format.cpp b/src/dawn/native/Format.cpp
index e41945b..756245a 100644
--- a/src/dawn/native/Format.cpp
+++ b/src/dawn/native/Format.cpp
@@ -28,7 +28,6 @@
 #include "dawn/native/Format.h"
 
 #include <bitset>
-#include <unordered_map>
 #include <utility>
 
 #include "dawn/common/TypedInteger.h"
diff --git a/src/dawn/native/InternalPipelineStore.cpp b/src/dawn/native/InternalPipelineStore.cpp
index b57b41a..52d8ee4 100644
--- a/src/dawn/native/InternalPipelineStore.cpp
+++ b/src/dawn/native/InternalPipelineStore.cpp
@@ -27,8 +27,6 @@
 
 #include "dawn/native/InternalPipelineStore.h"
 
-#include <unordered_map>
-
 #include "dawn/native/ComputePipeline.h"
 #include "dawn/native/Device.h"
 #include "dawn/native/RenderPipeline.h"
diff --git a/src/dawn/native/InternalPipelineStore.h b/src/dawn/native/InternalPipelineStore.h
index 0ae1e16..74cbde4 100644
--- a/src/dawn/native/InternalPipelineStore.h
+++ b/src/dawn/native/InternalPipelineStore.h
@@ -28,9 +28,9 @@
 #ifndef SRC_DAWN_NATIVE_INTERNALPIPELINESTORE_H_
 #define SRC_DAWN_NATIVE_INTERNALPIPELINESTORE_H_
 
-#include <unordered_map>
 #include <utility>
 
+#include "absl/container/flat_hash_map.h"
 #include "dawn/common/HashUtils.h"
 #include "dawn/native/ApplyClearColorValueWithDrawHelper.h"
 #include "dawn/native/BlitColorToColorWithDraw.h"
@@ -50,8 +50,9 @@
     explicit InternalPipelineStore(DeviceBase* device);
     ~InternalPipelineStore();
 
-    std::unordered_map<wgpu::TextureFormat, Ref<RenderPipelineBase>> copyTextureForBrowserPipelines;
-    std::unordered_map<wgpu::TextureFormat, Ref<RenderPipelineBase>>
+    absl::flat_hash_map<wgpu::TextureFormat, Ref<RenderPipelineBase>>
+        copyTextureForBrowserPipelines;
+    absl::flat_hash_map<wgpu::TextureFormat, Ref<RenderPipelineBase>>
         copyExternalTextureForBrowserPipelines;
 
     Ref<ShaderModuleBase> copyForBrowser;
@@ -86,18 +87,18 @@
             return hash;
         }
     };
-    std::unordered_map<BlitTextureToBufferComputePipelineKeyType,
-                       Ref<ComputePipelineBase>,
-                       BlitTextureToBufferComputePipelineHash>
+    absl::flat_hash_map<BlitTextureToBufferComputePipelineKeyType,
+                        Ref<ComputePipelineBase>,
+                        BlitTextureToBufferComputePipelineHash>
         blitTextureToBufferComputePipelines;
 
     struct BlitR8ToStencilPipelines {
         Ref<RenderPipelineBase> clearPipeline;
         std::array<Ref<RenderPipelineBase>, 8> setStencilPipelines;
     };
-    std::unordered_map<wgpu::TextureFormat, BlitR8ToStencilPipelines> blitR8ToStencilPipelines;
+    absl::flat_hash_map<wgpu::TextureFormat, BlitR8ToStencilPipelines> blitR8ToStencilPipelines;
 
-    std::unordered_map<wgpu::TextureFormat, Ref<RenderPipelineBase>> depthBlitPipelines;
+    absl::flat_hash_map<wgpu::TextureFormat, Ref<RenderPipelineBase>> depthBlitPipelines;
 
     BlitColorToColorWithDrawPipelinesCache msaaRenderToSingleSampledColorBlitPipelines;
 };
diff --git a/src/dawn/native/PassResourceUsageTracker.cpp b/src/dawn/native/PassResourceUsageTracker.cpp
index c6de5da..b75e695 100644
--- a/src/dawn/native/PassResourceUsageTracker.cpp
+++ b/src/dawn/native/PassResourceUsageTracker.cpp
@@ -70,11 +70,10 @@
                                                wgpu::ShaderStage shaderStages) {
     // Get or create a new TextureSubresourceSyncInfo for that texture (initially filled with
     // wgpu::TextureUsage::None and WGPUShaderStage_None)
-    auto it = mTextureSyncInfos.emplace(
-        std::piecewise_construct, std::forward_as_tuple(texture),
-        std::forward_as_tuple(texture->GetFormat().aspects, texture->GetArrayLayers(),
-                              texture->GetNumMipLevels(),
-                              TextureSyncInfo{wgpu::TextureUsage::None, wgpu::ShaderStage::None}));
+    auto it = mTextureSyncInfos.try_emplace(
+        texture, texture->GetFormat().aspects, texture->GetArrayLayers(),
+        texture->GetNumMipLevels(),
+        TextureSyncInfo{wgpu::TextureUsage::None, wgpu::ShaderStage::None});
     TextureSubresourceSyncInfo& textureSyncInfo = it.first->second;
 
     textureSyncInfo.Update(
@@ -89,11 +88,10 @@
     const TextureSubresourceSyncInfo& textureSyncInfo) {
     // Get or create a new TextureSubresourceSyncInfo for that texture (initially filled with
     // wgpu::TextureUsage::None and WGPUShaderStage_None)
-    auto it = mTextureSyncInfos.emplace(
-        std::piecewise_construct, std::forward_as_tuple(texture),
-        std::forward_as_tuple(texture->GetFormat().aspects, texture->GetArrayLayers(),
-                              texture->GetNumMipLevels(),
-                              TextureSyncInfo{wgpu::TextureUsage::None, wgpu::ShaderStage::None}));
+    auto it = mTextureSyncInfos.try_emplace(
+        texture, texture->GetFormat().aspects, texture->GetArrayLayers(),
+        texture->GetNumMipLevels(),
+        TextureSyncInfo{wgpu::TextureUsage::None, wgpu::ShaderStage::None});
     TextureSubresourceSyncInfo* passTextureSyncInfo = &it.first->second;
 
     passTextureSyncInfo->Merge(
@@ -288,7 +286,7 @@
 
     // Gets the iterator for that querySet or create a new vector of bool set to false
     // if the querySet wasn't registered.
-    auto it = mQueryAvailabilities.emplace(querySet, querySet->GetQueryCount()).first;
+    auto it = mQueryAvailabilities.try_emplace(querySet, querySet->GetQueryCount()).first;
     it->second[queryIndex] = true;
 }
 
diff --git a/src/dawn/native/PassResourceUsageTracker.h b/src/dawn/native/PassResourceUsageTracker.h
index 78e37ae..905f797 100644
--- a/src/dawn/native/PassResourceUsageTracker.h
+++ b/src/dawn/native/PassResourceUsageTracker.h
@@ -28,9 +28,9 @@
 #ifndef SRC_DAWN_NATIVE_PASSRESOURCEUSAGETRACKER_H_
 #define SRC_DAWN_NATIVE_PASSRESOURCEUSAGETRACKER_H_
 
-#include <map>
 #include <vector>
 
+#include "absl/container/flat_hash_map.h"
 #include "dawn/native/PassResourceUsage.h"
 
 #include "absl/container/flat_hash_set.h"
@@ -44,7 +44,7 @@
 class QuerySetBase;
 class TextureBase;
 
-using QueryAvailabilityMap = std::map<QuerySetBase*, std::vector<bool>>;
+using QueryAvailabilityMap = absl::flat_hash_map<QuerySetBase*, std::vector<bool>>;
 
 // Helper class to build SyncScopeResourceUsages
 class SyncScopeUsageTracker {
@@ -75,8 +75,8 @@
     SyncScopeResourceUsage AcquireSyncScopeUsage();
 
   private:
-    std::map<BufferBase*, BufferSyncInfo> mBufferSyncInfos;
-    std::map<TextureBase*, TextureSubresourceSyncInfo> mTextureSyncInfos;
+    absl::flat_hash_map<BufferBase*, BufferSyncInfo> mBufferSyncInfos;
+    absl::flat_hash_map<TextureBase*, TextureSubresourceSyncInfo> mTextureSyncInfos;
     absl::flat_hash_set<ExternalTextureBase*> mExternalTextureUsages;
 };
 
diff --git a/src/dawn/native/ShaderModule.cpp b/src/dawn/native/ShaderModule.cpp
index 6154cf3..2117673 100644
--- a/src/dawn/native/ShaderModule.cpp
+++ b/src/dawn/native/ShaderModule.cpp
@@ -926,8 +926,8 @@
                                 ReflectEntryPointUsingTint(device, &inspector, entryPoint),
                                 "processing entry point \"%s\".", entryPoint.name);
 
-        DAWN_ASSERT(entryPointMetadataTable->count(entryPoint.name) == 0);
-        (*entryPointMetadataTable)[entryPoint.name] = std::move(metadata);
+        DAWN_ASSERT(!entryPointMetadataTable->contains(entryPoint.name));
+        entryPointMetadataTable->emplace(entryPoint.name, std::move(metadata));
     }
     return {};
 }
@@ -1266,7 +1266,7 @@
 }
 
 bool ShaderModuleBase::HasEntryPoint(const std::string& entryPoint) const {
-    return mEntryPoints.count(entryPoint) > 0;
+    return mEntryPoints.contains(entryPoint);
 }
 
 ShaderModuleEntryPoint ShaderModuleBase::ReifyEntryPointName(const char* entryPointName,
diff --git a/src/dawn/native/ShaderModule.h b/src/dawn/native/ShaderModule.h
index 81b6188..a9ce0a2 100644
--- a/src/dawn/native/ShaderModule.h
+++ b/src/dawn/native/ShaderModule.h
@@ -32,10 +32,10 @@
 #include <map>
 #include <memory>
 #include <string>
-#include <unordered_map>
 #include <utility>
 #include <vector>
 
+#include "absl/container/flat_hash_map.h"
 #include "absl/container/flat_hash_set.h"
 #include "dawn/common/Constants.h"
 #include "dawn/common/ContentLessObjectCacheable.h"
@@ -102,7 +102,7 @@
 
 // A map from name to EntryPointMetadata.
 using EntryPointMetadataTable =
-    std::unordered_map<std::string, std::unique_ptr<EntryPointMetadata>>;
+    absl::flat_hash_map<std::string, std::unique_ptr<EntryPointMetadata>>;
 
 // Source for a tint program
 class TintSource;
@@ -260,7 +260,7 @@
         bool isInitialized;
     };
 
-    using OverridesMap = std::unordered_map<std::string, Override>;
+    using OverridesMap = absl::flat_hash_map<std::string, Override>;
 
     // Map identifier to override variable
     // Identifier is unique: either the variable name or the numeric ID if specified
diff --git a/src/dawn/native/d3d/BackendD3D.h b/src/dawn/native/d3d/BackendD3D.h
index c24ffe7..98d5ef9 100644
--- a/src/dawn/native/d3d/BackendD3D.h
+++ b/src/dawn/native/d3d/BackendD3D.h
@@ -30,11 +30,11 @@
 
 #include <memory>
 #include <string>
-#include <unordered_map>
 #include <utility>
 #include <variant>
 #include <vector>
 
+#include "absl/container/flat_hash_map.h"
 #include "dawn/common/TypedInteger.h"
 #include "dawn/native/BackendConnection.h"
 
@@ -137,7 +137,8 @@
     // Map of LUID to physical device.
     // The LUID is guaranteed to be uniquely identify an adapter on the local
     // machine until restart.
-    std::unordered_map<LUID, Ref<PhysicalDeviceBase>, LUIDHashFunc, LUIDEqualFunc> mPhysicalDevices;
+    absl::flat_hash_map<LUID, Ref<PhysicalDeviceBase>, LUIDHashFunc, LUIDEqualFunc>
+        mPhysicalDevices;
 };
 
 }  // namespace dawn::native::d3d
diff --git a/src/dawn/native/opengl/ShaderModuleGL.h b/src/dawn/native/opengl/ShaderModuleGL.h
index 86e238e..91efd24 100644
--- a/src/dawn/native/opengl/ShaderModuleGL.h
+++ b/src/dawn/native/opengl/ShaderModuleGL.h
@@ -30,7 +30,6 @@
 
 #include <memory>
 #include <string>
-#include <unordered_map>
 #include <vector>
 
 #include "include/tint/tint.h"
diff --git a/src/dawn/native/vulkan/BackendVk.cpp b/src/dawn/native/vulkan/BackendVk.cpp
index 9a3fb8a..f174ac7 100644
--- a/src/dawn/native/vulkan/BackendVk.cpp
+++ b/src/dawn/native/vulkan/BackendVk.cpp
@@ -528,7 +528,7 @@
 
 void VulkanInstance::StartListeningForDeviceMessages(Device* device) {
     std::lock_guard<std::mutex> lock(mMessageListenerDevicesMutex);
-    mMessageListenerDevices.insert({device->GetDebugPrefix(), device});
+    mMessageListenerDevices.emplace(device->GetDebugPrefix(), device);
 }
 void VulkanInstance::StopListeningForDeviceMessages(Device* device) {
     std::lock_guard<std::mutex> lock(mMessageListenerDevicesMutex);
diff --git a/src/dawn/native/vulkan/BackendVk.h b/src/dawn/native/vulkan/BackendVk.h
index ad4d3ee..5e74098 100644
--- a/src/dawn/native/vulkan/BackendVk.h
+++ b/src/dawn/native/vulkan/BackendVk.h
@@ -30,11 +30,11 @@
 
 #include <mutex>
 #include <string>
-#include <unordered_map>
 #include <vector>
 
 #include "dawn/native/BackendConnection.h"
 
+#include "absl/container/flat_hash_map.h"
 #include "dawn/common/DynamicLib.h"
 #include "dawn/common/Ref.h"
 #include "dawn/common/RefCounted.h"
@@ -96,7 +96,7 @@
 
     // Devices keep the VulkanInstance alive, so as long as devices remove themselves from this
     // map on destruction the pointers it contains should remain valid.
-    std::unordered_map<std::string, Device*> mMessageListenerDevices;
+    absl::flat_hash_map<std::string, Device*> mMessageListenerDevices;
     std::mutex mMessageListenerDevicesMutex;
 };
 
diff --git a/src/dawn/native/vulkan/BindGroupLayoutVk.cpp b/src/dawn/native/vulkan/BindGroupLayoutVk.cpp
index 9bd14e7..0a79620 100644
--- a/src/dawn/native/vulkan/BindGroupLayoutVk.cpp
+++ b/src/dawn/native/vulkan/BindGroupLayoutVk.cpp
@@ -27,9 +27,9 @@
 
 #include "dawn/native/vulkan/BindGroupLayoutVk.h"
 
-#include <map>
 #include <utility>
 
+#include "absl/container/flat_hash_map.h"
 #include "dawn/common/BitSetIterator.h"
 #include "dawn/common/ityp_vector.h"
 #include "dawn/native/CacheKey.h"
@@ -136,12 +136,12 @@
                             "CreateDescriptorSetLayout"));
 
     // Compute the size of descriptor pools used for this layout.
-    std::map<VkDescriptorType, uint32_t> descriptorCountPerType;
+    absl::flat_hash_map<VkDescriptorType, uint32_t> descriptorCountPerType;
 
     for (BindingIndex bindingIndex{0}; bindingIndex < GetBindingCount(); ++bindingIndex) {
         VkDescriptorType vulkanType = VulkanDescriptorType(GetBindingInfo(bindingIndex));
 
-        // map::operator[] will return 0 if the key doesn't exist.
+        // absl:flat_hash_map::operator[] will return 0 if the key doesn't exist.
         descriptorCountPerType[vulkanType]++;
     }
 
diff --git a/src/dawn/native/vulkan/ComputePipelineVk.cpp b/src/dawn/native/vulkan/ComputePipelineVk.cpp
index a21050d..8dd75cc 100644
--- a/src/dawn/native/vulkan/ComputePipelineVk.cpp
+++ b/src/dawn/native/vulkan/ComputePipelineVk.cpp
@@ -85,7 +85,7 @@
                 : std::nullopt));
 
     createInfo.stage.module = moduleAndSpirv.module;
-    createInfo.stage.pName = moduleAndSpirv.remappedEntryPoint;
+    createInfo.stage.pName = moduleAndSpirv.remappedEntryPoint.c_str();
 
     if (IsFullSubgroupsRequired()) {
         // Workgroup size validation is handled in ValidateComputeStageWorkgroupSize when compiling
diff --git a/src/dawn/native/vulkan/DescriptorSetAllocator.cpp b/src/dawn/native/vulkan/DescriptorSetAllocator.cpp
index 42bb0c4..2937177 100644
--- a/src/dawn/native/vulkan/DescriptorSetAllocator.cpp
+++ b/src/dawn/native/vulkan/DescriptorSetAllocator.cpp
@@ -42,13 +42,13 @@
 // static
 Ref<DescriptorSetAllocator> DescriptorSetAllocator::Create(
     BindGroupLayout* layout,
-    std::map<VkDescriptorType, uint32_t> descriptorCountPerType) {
+    absl::flat_hash_map<VkDescriptorType, uint32_t> descriptorCountPerType) {
     return AcquireRef(new DescriptorSetAllocator(layout, descriptorCountPerType));
 }
 
 DescriptorSetAllocator::DescriptorSetAllocator(
     BindGroupLayout* layout,
-    std::map<VkDescriptorType, uint32_t> descriptorCountPerType)
+    absl::flat_hash_map<VkDescriptorType, uint32_t> descriptorCountPerType)
     : ObjectBase(layout->GetDevice()), mLayout(layout) {
     DAWN_ASSERT(layout != nullptr);
 
diff --git a/src/dawn/native/vulkan/DescriptorSetAllocator.h b/src/dawn/native/vulkan/DescriptorSetAllocator.h
index ef60b8a..f260414 100644
--- a/src/dawn/native/vulkan/DescriptorSetAllocator.h
+++ b/src/dawn/native/vulkan/DescriptorSetAllocator.h
@@ -28,9 +28,9 @@
 #ifndef SRC_DAWN_NATIVE_VULKAN_DESCRIPTORSETALLOCATOR_H_
 #define SRC_DAWN_NATIVE_VULKAN_DESCRIPTORSETALLOCATOR_H_
 
-#include <map>
 #include <vector>
 
+#include "absl/container/flat_hash_map.h"
 #include "dawn/common/SerialQueue.h"
 #include "dawn/common/vulkan_platform.h"
 #include "dawn/native/Error.h"
@@ -49,7 +49,7 @@
   public:
     static Ref<DescriptorSetAllocator> Create(
         BindGroupLayout* layout,
-        std::map<VkDescriptorType, uint32_t> descriptorCountPerType);
+        absl::flat_hash_map<VkDescriptorType, uint32_t> descriptorCountPerType);
 
     ResultOrError<DescriptorSetAllocation> Allocate();
     void Deallocate(DescriptorSetAllocation* allocationInfo);
@@ -57,7 +57,7 @@
 
   private:
     DescriptorSetAllocator(BindGroupLayout* layout,
-                           std::map<VkDescriptorType, uint32_t> descriptorCountPerType);
+                           absl::flat_hash_map<VkDescriptorType, uint32_t> descriptorCountPerType);
     ~DescriptorSetAllocator() override;
 
     MaybeError AllocateDescriptorPool();
diff --git a/src/dawn/native/vulkan/RenderPassCache.h b/src/dawn/native/vulkan/RenderPassCache.h
index 46acc5d..e206008 100644
--- a/src/dawn/native/vulkan/RenderPassCache.h
+++ b/src/dawn/native/vulkan/RenderPassCache.h
@@ -31,8 +31,8 @@
 #include <array>
 #include <bitset>
 #include <mutex>
-#include <unordered_map>
 
+#include "absl/container/flat_hash_map.h"
 #include "dawn/common/Constants.h"
 #include "dawn/common/ityp_array.h"
 #include "dawn/common/ityp_bitset.h"
@@ -100,13 +100,13 @@
     // Does the actual VkRenderPass creation on a cache miss.
     ResultOrError<VkRenderPass> CreateRenderPassForQuery(const RenderPassCacheQuery& query) const;
 
-    // Implements the functors necessary for to use RenderPassCacheQueries as unordered_map
+    // Implements the functors necessary for to use RenderPassCacheQueries as absl::flat_hash_map
     // keys.
     struct CacheFuncs {
         size_t operator()(const RenderPassCacheQuery& query) const;
         bool operator()(const RenderPassCacheQuery& a, const RenderPassCacheQuery& b) const;
     };
-    using Cache = std::unordered_map<RenderPassCacheQuery, VkRenderPass, CacheFuncs, CacheFuncs>;
+    using Cache = absl::flat_hash_map<RenderPassCacheQuery, VkRenderPass, CacheFuncs, CacheFuncs>;
 
     Device* mDevice = nullptr;
 
diff --git a/src/dawn/native/vulkan/RenderPipelineVk.cpp b/src/dawn/native/vulkan/RenderPipelineVk.cpp
index 1c269d3..28d4072 100644
--- a/src/dawn/native/vulkan/RenderPipelineVk.cpp
+++ b/src/dawn/native/vulkan/RenderPipelineVk.cpp
@@ -28,6 +28,7 @@
 #include "dawn/native/vulkan/RenderPipelineVk.h"
 
 #include <memory>
+#include <string>
 #include <utility>
 #include <vector>
 
@@ -380,6 +381,7 @@
 
     // There are at most 2 shader stages in render pipeline, i.e. vertex and fragment
     std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages;
+    std::array<std::string, 2> shaderStageEntryPoints;
     uint32_t stageCount = 0;
 
     auto AddShaderStage = [&](SingleShaderStage stage, VkShaderStageFlagBits vkStage,
@@ -400,7 +402,8 @@
         shaderStage->flags = 0;
         shaderStage->pSpecializationInfo = nullptr;
         shaderStage->stage = vkStage;
-        shaderStage->pName = moduleAndSpirv.remappedEntryPoint;
+        shaderStageEntryPoints[stageCount] = moduleAndSpirv.remappedEntryPoint;
+        shaderStage->pName = shaderStageEntryPoints[stageCount].c_str();
 
         stageCount++;
         return {};
diff --git a/src/dawn/native/vulkan/ShaderModuleVk.cpp b/src/dawn/native/vulkan/ShaderModuleVk.cpp
index cddaaf3..f27f4d9 100644
--- a/src/dawn/native/vulkan/ShaderModuleVk.cpp
+++ b/src/dawn/native/vulkan/ShaderModuleVk.cpp
@@ -31,6 +31,7 @@
 #include <string>
 #include <vector>
 
+#include "absl/container/flat_hash_map.h"
 #include "dawn/native/CacheRequest.h"
 #include "dawn/native/PhysicalDevice.h"
 #include "dawn/native/Serializable.h"
@@ -147,9 +148,9 @@
 
     Device* mDevice;
     std::mutex mMutex;
-    std::unordered_map<TransformedShaderModuleCacheKey,
-                       Entry,
-                       TransformedShaderModuleCacheKeyHashFunc>
+    absl::flat_hash_map<TransformedShaderModuleCacheKey,
+                        Entry,
+                        TransformedShaderModuleCacheKeyHashFunc>
         mTransformedShaderModuleCache;
 };
 
diff --git a/src/dawn/native/vulkan/ShaderModuleVk.h b/src/dawn/native/vulkan/ShaderModuleVk.h
index 1060fa6..1e86d14 100644
--- a/src/dawn/native/vulkan/ShaderModuleVk.h
+++ b/src/dawn/native/vulkan/ShaderModuleVk.h
@@ -32,7 +32,6 @@
 #include <mutex>
 #include <optional>
 #include <string>
-#include <unordered_map>
 #include <utility>
 
 #include "dawn/common/HashUtils.h"
@@ -68,7 +67,7 @@
         VkShaderModule module;
         const uint32_t* spirv;
         size_t wordCount;
-        const char* remappedEntryPoint;
+        std::string remappedEntryPoint;
     };
 
     static ResultOrError<Ref<ShaderModule>> Create(
diff --git a/src/dawn/native/vulkan/VulkanExtensions.cpp b/src/dawn/native/vulkan/VulkanExtensions.cpp
index 2485a13..8f0634a 100644
--- a/src/dawn/native/vulkan/VulkanExtensions.cpp
+++ b/src/dawn/native/vulkan/VulkanExtensions.cpp
@@ -74,10 +74,10 @@
     return sInstanceExtInfos[index];
 }
 
-std::unordered_map<std::string, InstanceExt> CreateInstanceExtNameMap() {
-    std::unordered_map<std::string, InstanceExt> result;
+absl::flat_hash_map<std::string, InstanceExt> CreateInstanceExtNameMap() {
+    absl::flat_hash_map<std::string, InstanceExt> result;
     for (const InstanceExtInfo& info : sInstanceExtInfos) {
-        result[info.name] = info.index;
+        result.emplace(info.name, info.index);
     }
     return result;
 }
@@ -200,10 +200,10 @@
     return sDeviceExtInfos[index];
 }
 
-std::unordered_map<std::string, DeviceExt> CreateDeviceExtNameMap() {
-    std::unordered_map<std::string, DeviceExt> result;
+absl::flat_hash_map<std::string, DeviceExt> CreateDeviceExtNameMap() {
+    absl::flat_hash_map<std::string, DeviceExt> result;
     for (const DeviceExtInfo& info : sDeviceExtInfos) {
-        result[info.name] = info.index;
+        result.emplace(info.name, info.index);
     }
     return result;
 }
@@ -364,10 +364,10 @@
     return sVulkanLayerInfos[index];
 }
 
-std::unordered_map<std::string, VulkanLayer> CreateVulkanLayerNameMap() {
-    std::unordered_map<std::string, VulkanLayer> result;
+absl::flat_hash_map<std::string, VulkanLayer> CreateVulkanLayerNameMap() {
+    absl::flat_hash_map<std::string, VulkanLayer> result;
     for (const VulkanLayerInfo& info : sVulkanLayerInfos) {
-        result[info.name] = info.layer;
+        result.emplace(info.name, info.layer);
     }
     return result;
 }
diff --git a/src/dawn/native/vulkan/VulkanExtensions.h b/src/dawn/native/vulkan/VulkanExtensions.h
index 3237475..cce482a 100644
--- a/src/dawn/native/vulkan/VulkanExtensions.h
+++ b/src/dawn/native/vulkan/VulkanExtensions.h
@@ -29,8 +29,8 @@
 #define SRC_DAWN_NATIVE_VULKAN_VULKANEXTENSIONS_H_
 
 #include <string>
-#include <unordered_map>
 
+#include "absl/container/flat_hash_map.h"
 #include "dawn/common/ityp_bitset.h"
 
 namespace dawn::native::vulkan {
@@ -75,7 +75,7 @@
 // Returns the information about a known InstanceExt
 const InstanceExtInfo& GetInstanceExtInfo(InstanceExt ext);
 // Returns a map that maps a Vulkan extension name to its InstanceExt.
-std::unordered_map<std::string, InstanceExt> CreateInstanceExtNameMap();
+absl::flat_hash_map<std::string, InstanceExt> CreateInstanceExtNameMap();
 
 // Sets entries in `extensions` to true if that entry was promoted in Vulkan version `version`
 void MarkPromotedExtensions(InstanceExtSet* extensions, uint32_t version);
@@ -148,7 +148,7 @@
 // Returns the information about a known DeviceExt
 const DeviceExtInfo& GetDeviceExtInfo(DeviceExt ext);
 // Returns a map that maps a Vulkan extension name to its DeviceExt.
-std::unordered_map<std::string, DeviceExt> CreateDeviceExtNameMap();
+absl::flat_hash_map<std::string, DeviceExt> CreateDeviceExtNameMap();
 
 // Sets entries in `extensions` to true if that entry was promoted in Vulkan version `version`
 void MarkPromotedExtensions(DeviceExtSet* extensions, uint32_t version);
@@ -183,7 +183,7 @@
 // Returns the information about a known VulkanLayer
 const VulkanLayerInfo& GetVulkanLayerInfo(VulkanLayer layer);
 // Returns a map that maps a Vulkan layer name to its VulkanLayer.
-std::unordered_map<std::string, VulkanLayer> CreateVulkanLayerNameMap();
+absl::flat_hash_map<std::string, VulkanLayer> CreateVulkanLayerNameMap();
 
 }  // namespace dawn::native::vulkan
 
diff --git a/src/dawn/native/vulkan/VulkanInfo.cpp b/src/dawn/native/vulkan/VulkanInfo.cpp
index 32c3d1e..fcb2419 100644
--- a/src/dawn/native/vulkan/VulkanInfo.cpp
+++ b/src/dawn/native/vulkan/VulkanInfo.cpp
@@ -29,9 +29,9 @@
 
 #include <cstring>
 #include <string>
-#include <unordered_map>
 #include <utility>
 
+#include "absl/container/flat_hash_map.h"
 #include "dawn/native/vulkan/BackendVk.h"
 #include "dawn/native/vulkan/PhysicalDeviceVk.h"
 #include "dawn/native/vulkan/UtilsVulkan.h"
@@ -43,7 +43,7 @@
 ResultOrError<InstanceExtSet> GatherInstanceExtensions(
     const char* layerName,
     const dawn::native::vulkan::VulkanFunctions& vkFunctions,
-    const std::unordered_map<std::string, InstanceExt>& knownExts) {
+    const absl::flat_hash_map<std::string, InstanceExt>& knownExts) {
     uint32_t count = 0;
     VkResult vkResult = VkResult::WrapUnsafe(
         vkFunctions.EnumerateInstanceExtensionProperties(layerName, &count, nullptr));
@@ -109,7 +109,7 @@
             vkFunctions.EnumerateInstanceLayerProperties(&count, layersProperties.data()),
             "vkEnumerateInstanceLayerProperties"));
 
-        std::unordered_map<std::string, VulkanLayer> knownLayers = CreateVulkanLayerNameMap();
+        absl::flat_hash_map<std::string, VulkanLayer> knownLayers = CreateVulkanLayerNameMap();
         for (const VkLayerProperties& layer : layersProperties) {
             auto it = knownLayers.find(layer.layerName);
             if (it != knownLayers.end()) {
@@ -120,7 +120,7 @@
 
     // Gather the info about the instance extensions
     {
-        std::unordered_map<std::string, InstanceExt> knownExts = CreateInstanceExtNameMap();
+        absl::flat_hash_map<std::string, InstanceExt> knownExts = CreateInstanceExtNameMap();
 
         DAWN_TRY_ASSIGN(info.extensions, GatherInstanceExtensions(nullptr, vkFunctions, knownExts));
         MarkPromotedExtensions(&info.extensions, info.apiVersion);
@@ -220,7 +220,7 @@
                                     vkPhysicalDevice, nullptr, &count, extensionsProperties.data()),
                                 "vkEnumerateDeviceExtensionProperties"));
 
-        std::unordered_map<std::string, DeviceExt> knownExts = CreateDeviceExtNameMap();
+        absl::flat_hash_map<std::string, DeviceExt> knownExts = CreateDeviceExtNameMap();
 
         for (const VkExtensionProperties& extension : extensionsProperties) {
             auto it = knownExts.find(extension.extensionName);