Closed Bug 1479250 Opened 6 years ago Closed 5 years ago

Style threads are allocated with eagerly committed stacks on Windows

Categories

(Core :: CSS Parsing and Computation, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED

People

(Reporter: kmag, Assigned: xidorn)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [overhead:1.5M])

This also applies to other Rust threads, but Stylo threads are the biggest chunk of that.

All of the non-Rust threads we create on Windows use the STACK_SIZE_PARAM_IS_A_RESERVATION flag, which causes us to reserve stack space, but not commit it until it's used. std::thread doesn't do that, which means that all of the thread stack space is eagerly committed, and immediately consumes resources.

With 6 Stylo threads at 256KiB each, that's 1.5MiB per process.
Would this become irrelevant if we can fix bug 1475091?
(In reply to Kris Maglione [:kmag] from comment #0)
> This also applies to other Rust threads, but Stylo threads are the biggest
> chunk of that.
> 
> All of the non-Rust threads we create on Windows use the
> STACK_SIZE_PARAM_IS_A_RESERVATION flag, which causes us to reserve stack
> space, but not commit it until it's used. std::thread doesn't do that, which
> means that all of the thread stack space is eagerly committed, and
> immediately consumes resources.
> 
> With 6 Stylo threads at 256KiB each, that's 1.5MiB per process.

Do you think just modifying libstd to pass the flag by default is feasible / desirable? Or should we try to add an API to configure it the same way as thread names can be configured?
Flags: needinfo?(kmaglione+bmo)
(In reply to Emilio Cobos Álvarez (:emilio) from comment #2)
> Do you think just modifying libstd to pass the flag by default is feasible /
> desirable? Or should we try to add an API to configure it the same way as
> thread names can be configured?

I think having libstd pass the flag by default probably makes the most sense. That would make the behavior on Windows match other platforms, and is pretty standard practice for threading libraries on Windows anyway.
Flags: needinfo?(kmaglione+bmo)
Discussed with emilio on IRC, I'm going to send a patch to Rust to fix this.
Assignee: nobody → xidorn+moz
Submitted rust-lang/rust#52847 for the change.
The Rust PR has been merged, should be in 1.30.
Priority: -- → P3
Depends on: 1494387
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.