Skip to content
This repository was archived by the owner on Jan 24, 2023. It is now read-only.

Commit 4393721

Browse files
committed
modified speed section
1 parent 9c6e284 commit 4393721

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

_posts/2018-08-09-gsoc-generic-servo.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
## Introduction
1010

11-
I am Peter Hrvola (retep007) [Twitter](https://twitter.com/retep007) [Github](https://github.com/retep007). During my GSoC project, I have been working on investigating the monolithic nature of Servo's script crate and prototyping separation to smaller crates. My goal was to improve the use of resources during compilation. Current debug build consumes over 5GB of memory and takes 347s.
11+
I am Peter Hrvola (retep007) [Twitter](https://twitter.com/retep007) [Github](https://github.com/retep007). During my Google Summer of Code (GSoC) project, I have been working on investigating the monolithic nature of Servo's script crate and prototyping separation to smaller crates. My goal was to improve the use of resources during compilation. Current debug build consumes over 5GB of memory and takes 347s.
1212

13-
The solution introduces a *TypeHolder* trait which contains associated types, and makes many structures in the script crate generic over this new trait. This allows the generic structs to refer to the new trait's associated types, while the actual concrete types can be extracted into a separate crate. Testing shows significant improvement in memory consumption (25% lower) and build time (33% faster).
13+
The solution introduces a *TypeHolder* trait which contains associated types, and makes many structures in the script crate generic over this new trait. This allows the generic structs to refer to the new trait's associated types, while the actual concrete types can be extracted into a separate crate. Testing shows significant improvement in memory consumption (25% lower) and build time (27% faster).
1414

1515
## The process
1616

@@ -63,16 +63,27 @@ Due to lack of Rust support for generic static variables at many places I had to
6363
6464
I have done testing on MacBook Pro 2015, High Sierra, 2,7 GHz i5 dual core, 16 GB RAM using `/usr/bin/time cargo build`, which shows maximal memory usage during compilation. Results may vary depending on build machine.
6565

66+
Cargo recompiles only crates that have been modified and crates that depend on modified crates. I have separated script crate to script and script_servoparser. We have taken three samples. One for original Servo. Two after separation I have made. For separated script crate compilation times were measured for each crate separately. Only one crate was modified at a time. However, change in script crate also forces recompilation of script_servoparser.
67+
6668
Resources were measured in this way:
6769

6870
1. compile full servo
69-
2. modify Attr.rs file and ServoParser.rs files so I force recompilatiion of crates. After separation Attr.rs and ServoParser.rs are in different crates.
71+
2. modify files
7072
3. measure resources used to build a full servo
7173

72-
| | Servo with multiple script crates | Servo with one script crate |
73-
| --------- | ------------- | -------------------------- |
74-
| RAM | 3.74GB | 5.1GB |
75-
| Real time | 231s | 347s |
74+
Unchanged Servo:
75+
76+
| | Servo |
77+
| --------- | ------------- |
78+
| RAM | 5.1GB |
79+
| Real time | 3:49m |
80+
81+
Servo after separation to two crates:
82+
83+
| | Modified script crate | Modified script_servoparser crate |
84+
| - | - | - |
85+
| RAM | 3.74 GB | 2 GB |
86+
| Real time | 2:56m | 1:48m |
7687

7788
As we can see in the table above, resource usage during compilation has drastically changed. The main reason is that because of a large number of generic structures which postpone parts of compilation to later monomorphization. In future, actual separation of dom structs to upstream crates will lower this number even more. In the current version, only six dom structs were moved outside the script crate.
7889

0 commit comments

Comments
 (0)