View
81
Download
1
Category
Tags:
Preview:
Citation preview
A ShortIntroduction
to ServoWeb Engines Hackfest 2014
Martin Robinsonn@abandonedwig
The Modern BrowserFast JavaScript enginesOptimized layout routinesRapidly evolving rendering pipelinesEver increasing concurrency
Not Good EnoughMemory safety issues leave users exposedWeb application complexity increasesLow amount of parallelism, leaving idle cores
Web Engine ParallelismWeb engines use fine-grained concurrency, but littleparallelismData structures not designed for parallelismDifficult to be parallel while ensuring memory safetyNative concurrency primitives not flexible
RustInitially Graydon Hoare's personal project, but adopted byMozilla Research in 2009.Fast, concurrent, safe compiled system languageThe compiler protects you from common memory issuesFast approaching version 1.0
Compile-time MemorySafety
fn main() { let mut vector = vec!(1i, 2i, 3i, 4i); let first_element = &vector[0]; vector.clear();
println!("Derferenced pointer to cleared value: {}", *first_element);}
error: cannot borrow ̀vector̀ as mutable because it is also borrowed as immutable...error: aborting due to previous error
Easy Concurrencylet (tx, rx) = channel();
spawn(proc() { tx.send("Hello from a task!".to_string());});
let message = rx.recv();println!("{}", message);
Task Data Safetylet mut x = vec!(1i, 2i, 3i);
spawn(proc() { println!("The value of x[0] is: {}", x[0]);});
println!("The value of x[0] is: {}", x[0]);
error: use of moved value: ̀x̀note: in expansion of format_args!<std macros>:2:23: 2:77 note: expansion site<std macros>:1:1: 3:2 note: in expansion of println!error: aborting due to previous error
ServoParallel layout design from the startWork-stealing algorithm for task schedulingUse of green threads to allow creating many tasksModern rendering pipeline
ArchitectureConstellationConstellation
PipelinePipelineRenderRender Task Task
ScriptScript Task Task
LayoutLayout Task Task
PipelinePipelineRenderRender Task Task
ScriptScript Task Task
LayoutLayout Task Task
PipelinePipelineRenderRender Task Task
ScriptScript Task Task
LayoutLayout Task Task
Optimistically ParallelLayout
Parallelize layout as much as possibleA series of bottom-up and top-down passes on a flow treeSerialize when necessary, but hopefully uncommon orlimited casesSee speedup from parallelism on typical pages
Rendering PipelineAlways composited, no legacy approachesWorks divided into tasks
Layout Task: convert flow tree to display listRender Task: rasterize display list to shared surfacesCompositor Task: render rasterized content
Compositor layers are tiled and double-bufferedPinch zoom and panning support
StatusMissing many CSS features and HTTP cachingForm interaction only in the early stagesHas evolving support for vertical writing modesVery close to dog-foodableCEF API for embedding
Get InvolvedDevelopment happens in the open, including roadmapOutside contributors very welcomeEverything available on Building is easy and fast compared to other enginesLook for bugs marked E-EasyDiscussion at #servo on irc.mozilla.org
Github
Recommended