mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
script: Reduce ScriptThread TLS usage (#38875)
We store a pointer to the ScriptThread singleton for a thread in thread-local storage. While we don't have yet have profiles pointing to this TLS access as a hot spot, we can remove a potential performance footgun without a lot of effort by passing around small pieces of data that we otherwise need to fetch from the ScriptThread. Testing: Existing WPT is sufficient Fixes: part of #37969 --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
d1da1a995c
commit
c97ec1b2fb
17 changed files with 129 additions and 68 deletions
|
@ -5,6 +5,7 @@
|
|||
use core::fmt;
|
||||
#[cfg(feature = "webgpu")]
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashSet;
|
||||
use std::option::Option;
|
||||
use std::result::Result;
|
||||
|
||||
|
@ -397,10 +398,11 @@ impl ScriptThreadReceivers {
|
|||
&self,
|
||||
task_queue: &TaskQueue<MainThreadScriptMsg>,
|
||||
timer_scheduler: &TimerScheduler,
|
||||
fully_active: &HashSet<PipelineId>,
|
||||
) -> MixedMessage {
|
||||
select! {
|
||||
recv(task_queue.select()) -> msg => {
|
||||
task_queue.take_tasks(msg.unwrap());
|
||||
task_queue.take_tasks(msg.unwrap(), fully_active);
|
||||
let event = task_queue
|
||||
.recv()
|
||||
.expect("Spurious wake-up of the event-loop, task-queue has no tasks available");
|
||||
|
@ -437,6 +439,7 @@ impl ScriptThreadReceivers {
|
|||
pub(crate) fn try_recv(
|
||||
&self,
|
||||
task_queue: &TaskQueue<MainThreadScriptMsg>,
|
||||
fully_active: &HashSet<PipelineId>,
|
||||
) -> Option<MixedMessage> {
|
||||
if let Ok(message) = self.constellation_receiver.try_recv() {
|
||||
let message = message
|
||||
|
@ -449,7 +452,7 @@ impl ScriptThreadReceivers {
|
|||
.ok()?;
|
||||
return MixedMessage::FromConstellation(message).into();
|
||||
}
|
||||
if let Ok(message) = task_queue.take_tasks_and_recv() {
|
||||
if let Ok(message) = task_queue.take_tasks_and_recv(fully_active) {
|
||||
return MixedMessage::FromScript(message).into();
|
||||
}
|
||||
if let Ok(message) = self.devtools_server_receiver.try_recv() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue