Closed Bug 1425524 Opened 6 years ago Closed 2 years ago

[meta] move frontend content process JS code to C++ or Rust where feasible

Categories

(Firefox :: General, enhancement, P5)

enhancement

Tracking

()

RESOLVED INVALID

People

(Reporter: froydnj, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: meta, perf, Whiteboard: [MemShrink:meta][overhead:meta])

Not sure if the bug title is super-accurate, but let's go with this for now.

JS code for content processes is inefficient from the memory point of view: we're paying the cost for JS source, JS objects, bytecode, JIT code, etc. in every single content process.  In contrast, putting similar code in C++ can get shared between all processes, and the C++ objects are...probably smaller than their equivalent JS objects?  Depends on a bunch of factors, I guess.

Anyway, this was an idea we came up talking about memory usage for content processes, and talking to Gijs indicated that it wasn't a completely off-base idea.  Filing a bug for people to comment and also for people to hang dependent work off of.

See bug 1425466 for similar, but related things.
Keywords: perf
See Also: → 1350472
Whiteboard: [MemShrink]
Whiteboard: [MemShrink] → [MemShrink:meta]
Is porting things to Rust, so we don't end up trading memory for vulnerabilities, an option? Or is that blocked on us having the infrastructure for Rust to directly implement/consume interfaces?
Summary: [meta] move frontend content process JS code to C++ where feasible → [meta] move frontend content process JS code to C++ or Rust where feasible
(In reply to Alex Gaynor [:Alex_Gaynor] from comment #1)
> Is porting things to Rust, so we don't end up trading memory for
> vulnerabilities, an option? Or is that blocked on us having the
> infrastructure for Rust to directly implement/consume interfaces?

This is an option.  We have the ability to implement XPIDL interfaces in Rust nowadays, so it doesn't even have to involve writing C++ shims for things.

Bug 1356594 comment 6 contains a useful caution about doing all of this.
Nathan, do you have a rough estimate of the overhead here?
Flags: needinfo?(nfroyd)
(In reply to Eric Rahm [:erahm] (please no mozreview requests) from comment #3)
> Nathan, do you have a rough estimate of the overhead here?

I don't think that's a useful question, because it depends on the script, and each individual script would have to be ported separately. Chrome JS scripts can take anywhere from 60kb down to almost nothing. If we could magically port all chrome JS to Rust, maybe it would be megabytes of savings, but that doesn't feel very practical to me.
Just as a side note, from looking at logs, session store and telemetry stand out as two large uses of chrome JS script memory that seem like they'd be needed in every process. If the JS engine people come up with a way to share bytecode etc. memory across processes then this will be less of an issue.
(In reply to Eric Rahm [:erahm] (please no mozreview requests) from comment #3)
> Nathan, do you have a rough estimate of the overhead here?

What mccr8 said in comment 4.  kmag would have a better idea than me in any event.

(In reply to Andrew McCreight [:mccr8] from comment #5)
> Just as a side note, from looking at logs, session store and telemetry stand
> out as two large uses of chrome JS script memory that seem like they'd be
> needed in every process. If the JS engine people come up with a way to share
> bytecode etc. memory across processes then this will be less of an issue.

Session store would also gain significant efficiency from being written in C++, too.
Flags: needinfo?(nfroyd)
Whiteboard: [MemShrink:meta] → [MemShrink:meta][overhead:meta]
See Also: → 1464542
Priority: -- → P5

The meta keyword is there, the bug doesn't depend on other bugs and there is no activity for 12 months.
:mossop, maybe it's time to close this bug?

Flags: needinfo?(dtownsend)

I'm not sure that this bug really serves any purpose at this point.

Status: NEW → RESOLVED
Closed: 2 years ago
Flags: needinfo?(dtownsend)
Resolution: --- → INVALID

Yeah, there has been work along these lines since this bug was filed, but the actual meta bug doesn't seem to have done any good.

You need to log in before you can comment on or make changes to this bug.