storage: Move storage related backend threads to their own crate (#39418)

This PR moves storage related APIs (currently just webstorage and
indexeddb) into their own crate. This reduces the congestion in the net
thread.

Related Zulip thread:
https://servo.zulipchat.com/#narrow/channel/263398-general/topic/indexedDB.20location/with/535911631

Sub PRs:
- [x] Move shared storage/net stuff to base (`IpcSend` and
`CoreResourcePool`) #39419

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Ashwin Naren 2025-09-28 01:00:20 -07:00 committed by GitHub
parent ba5f36b671
commit d12dc23083
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
60 changed files with 378 additions and 280 deletions

View file

@ -55,6 +55,7 @@ servo-tracing = { workspace = true }
servo_config = { path = "../config" }
servo_rand = { path = "../rand" }
servo_url = { path = "../url" }
storage_traits = { workspace = true }
stylo = { workspace = true }
stylo_traits = { workspace = true }
tracing = { workspace = true, optional = true }

View file

@ -151,7 +151,6 @@ use net::image_cache::ImageCacheImpl;
use net_traits::image_cache::ImageCache;
use net_traits::pub_domains::reg_host;
use net_traits::request::Referrer;
use net_traits::storage_thread::{StorageThreadMsg, StorageType};
use net_traits::{
self, AsyncRuntime, ReferrerPolicy, ResourceThreads, exit_fetch_thread, start_fetch_thread,
};
@ -167,6 +166,8 @@ use servo_config::prefs::{self, PrefValue};
use servo_config::{opts, pref};
use servo_rand::{Rng, ServoRng, SliceRandom, random};
use servo_url::{Host, ImmutableOrigin, ServoUrl};
use storage_traits::StorageThreads;
use storage_traits::storage_thread::{StorageThreadMsg, StorageType};
use style::global_style_data::StyleThreadPool;
#[cfg(feature = "webgpu")]
use webgpu::canvas_context::WGPUImageMap;
@ -347,6 +348,17 @@ pub struct Constellation<STF, SWF> {
/// browsing.
private_resource_threads: ResourceThreads,
/// Channels for the constellation to send messages to the public
/// storage-related threads. There are two groups of storage threads: one
/// for public browsing, and one for private browsing.
public_storage_threads: StorageThreads,
/// Channels for the constellation to send messages to the private
/// storage-related threads. There are two groups of storage
/// threads: one for public browsing, and one for private
/// browsing.
private_storage_threads: StorageThreads,
/// A channel for the constellation to send messages to the font
/// cache thread.
system_font_service: Arc<SystemFontServiceProxy>,
@ -520,6 +532,12 @@ pub struct InitialConstellationState {
/// A channel to the resource thread.
pub private_resource_threads: ResourceThreads,
/// A channel to the storage thread.
pub public_storage_threads: StorageThreads,
/// A channel to the storage thread.
pub private_storage_threads: StorageThreads,
/// A channel to the time profiler thread.
pub time_profiler_chan: time::ProfilerChan,
@ -697,6 +715,8 @@ where
bluetooth_ipc_sender: state.bluetooth_thread,
public_resource_threads: state.public_resource_threads,
private_resource_threads: state.private_resource_threads,
public_storage_threads: state.public_storage_threads,
private_storage_threads: state.private_storage_threads,
system_font_service: state.system_font_service,
sw_managers: Default::default(),
swmanager_receiver,
@ -979,6 +999,11 @@ where
} else {
self.public_resource_threads.clone()
};
let storage_threads = if is_private {
self.private_storage_threads.clone()
} else {
self.public_storage_threads.clone()
};
let embedder_chan = self.embedder_proxy.sender.clone();
let eventloop_waker = self.embedder_proxy.event_loop_waker.clone();
@ -1009,6 +1034,7 @@ where
swmanager_thread: self.swmanager_ipc_sender.clone(),
system_font_service: self.system_font_service.clone(),
resource_threads,
storage_threads,
time_profiler_chan: self.time_profiler_chan.clone(),
mem_profiler_chan: self.mem_profiler_chan.clone(),
viewport_details: initial_viewport_details,
@ -2676,7 +2702,7 @@ where
debug!("Exiting storage resource threads.");
if let Err(e) = generic_channel::GenericSend::send(
&self.public_resource_threads,
&self.public_storage_threads,
StorageThreadMsg::Exit(storage_ipc_sender),
) {
warn!("Exit storage thread failed ({})", e);

View file

@ -51,6 +51,7 @@ use serde::{Deserialize, Serialize};
use servo_config::opts::{self, Opts};
use servo_config::prefs::{self, Preferences};
use servo_url::ServoUrl;
use storage_traits::StorageThreads;
use crate::event_loop::EventLoop;
use crate::process_manager::Process;
@ -168,6 +169,9 @@ pub struct InitialPipelineState {
/// Channels to the resource-related threads.
pub resource_threads: ResourceThreads,
/// Channels to the storage-related threads.
pub storage_threads: StorageThreads,
/// A channel to the time profiler thread.
pub time_profiler_chan: time::ProfilerChan,
@ -297,6 +301,7 @@ impl Pipeline {
swmanager_thread: state.swmanager_thread,
system_font_service: state.system_font_service.to_sender(),
resource_threads: state.resource_threads,
storage_threads: state.storage_threads,
time_profiler_chan: state.time_profiler_chan,
mem_profiler_chan: state.mem_profiler_chan,
viewport_details: state.viewport_details,
@ -495,6 +500,7 @@ pub struct UnprivilegedPipelineContent {
swmanager_thread: GenericSender<SWManagerMsg>,
system_font_service: SystemFontServiceProxySender,
resource_threads: ResourceThreads,
storage_threads: StorageThreads,
time_profiler_chan: time::ProfilerChan,
mem_profiler_chan: profile_mem::ProfilerChan,
viewport_details: ViewportDetails,
@ -551,6 +557,7 @@ impl UnprivilegedPipelineContent {
#[cfg(feature = "bluetooth")]
bluetooth_sender: self.bluetooth_thread,
resource_threads: self.resource_threads,
storage_threads: self.storage_threads,
image_cache,
time_profiler_sender: self.time_profiler_chan.clone(),
memory_profiler_sender: self.mem_profiler_chan.clone(),