performance-memory
Proposal to expose more detailed memory metrics to the web.
Authors: [email protected], [email protected]
License: Other
Proposal to expose more detailed memory metrics to the web.
Authors: [email protected], [email protected]
In Chrome, the IDL appears to use a MemoryInfo interface: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/timing/MemoryInfo.idl?q=MemoryInfo.idl&sq=package:chromium&l=1
A dictionary has significantly different semantics, e.g. you can modify the properties of dictionaries, and they use data properties instead of the getters of an interface.
https://github.com/erikchen/performance-memory/blob/master/explainer.md#proposed-api does not contain valid IDL, but appears to gesture toward it by using the term "dictionary" (see #3).
Tim, Hannes and I spoke with the GSuite & Gmail teams offline. They were happy with the introduction of PrivateMemoryFootprint, but had concerns about the "accurate or null" proposal. Their concern was that their properties might disproportionately end up in the "null" bucket, due to usage patterns of their users.
They suggested the following:
Users that want the "accurate or null" property can simply ignore results with numberOfSharedRenderers > 1.
There's a slight caveat - as per discussion with Boris Z on blink-dev@chromium, we will actually need to report:
which has different semantics, but will usually provide a similar result. This seems like a reasonable request.
Tim, Hannes and I brainstormed how to appropriately change the API to support this without introducing a foot-gun. It seems likely that some developers will accidentally ignore the numberOfNonEmptyFrameTrees field and get incorrect results.
We failed to come up with an answer that wasn't too clunky, so we're going to just drop in the field for now, and consider the ergonomics later.
Appendix C suggests shared memory should be attributed to a single owner:
https://github.com/WICG/performance-memory/blob/master/explainer.md#-appendix-c---shared-memory
How would this work for web platform features like SharedWorker and ServiceWorker?
SharedWorker instances may be attached to multiple iframes of the same origin across any number of processes. None of these connections is considered "primary". Where is the SharedWorker memory attributed?
ServiceWorker threads spawn in reaction to events from clients like iframes, but is not directly connected to any clients. The ServiceWorker is considered to "control" clients, but same-origin clients that are not controlled can also activate the ServiceWorker using postMessage, etc. The ServiceWorker can also be activated without any client interaction via things like push messages or background sync. How is this ServiceWorker memory attributed?
One possible solution is to convert the proposal to report memory per environment instead of per "iframe". An environment is:
https://html.spec.whatwg.org/multipage/webappapis.html#environment
Each window, iframe, worker (dedicated/shared/service) is a separate environment. This would avoid having to deal with how these environments interconnect.
I think any spec in this space should make it very clear that the API cannot be reliably used to compare numbers across browsers, OSes, or possibly even across different versions of a given browser. For example, if Chrome makes an implementation change one release that moves some graphics related memory from the GPU process into the renderer process, developers should not treat this as a regression in their site. Similarly, as tempting as it will be, you can't meaningfully benchmark browsers against eachother based on the data from this API.
So maybe even word this positively as a Goal like: "Enable memory usage comparison between two versions of an application running in substantially identical environments". And then make a recommendation of the properties developers should use to key their aggregation of data against. Eg: comparisons are likely valid only across environments where the following properties are identical:
[NoInterfaceObject] is generally deprecated and should be avoided. But, maybe this is a legacy use case where we'd want to keep it.
I've been discussing the proposal with some Apple engineers. The preliminary feedback has been really helpful, and I wanted to start updating the spec based on that feedback.
In light of:
mozilla/standards-positions#85 (comment)
Should we archive this repo?
This is an important thing to include in any spec.
The answer should be yes, if at all possible.
This is feedback from Benoit and Vlad, Nate will reply separately.
We really like this proposal: private memory footprint makes a lot of sense, "accurate or null" is a huge improvement, and it seems like most privacy issues have been addressed.
For privateMemoryFootprint, totalJSHeapSize, and usedJSHeapSize we only have accurate accounting when the process is hosting a single top level frame. As such, we return null anytime the process is hosting more than a single top level frame.
What will be returned when two Facebook.com tabs are in the same render process? We would prefer null for this situation, since it is very hard to interpret a single memory usage number from multiple tabs.
One strange thing in this proposal is that web authors will need to handle that some instances of Chrome (e.g. on mobile) won’t have full site isolation and others (e.g. on desktop) will. It’s a bit ugly, but they can detect this by looking at cases where all the values in that page ended in four zeros. If all calls to performance.memory result in quantized values, then it’s almost guaranteed to be the quantized numbers.
This is from the proposal in the Google Doc https://docs.google.com/document/d/1iC9-sra-vdz0c18qM9H_El_k4yGzd6TdIItIfs3p-8Q/edit#
So does this mean that mobile Chrome will ALWAYS quantize and delay memory measurements?
What if there is a single tab in mobile Chrome, will it return the accurate measurement?
In the past, we have used the quantized/delayed performance.memory API and have not gotten benefit out of it. So we would prefer "accurate or null" again -- either the measurement is from a single tab or it is null.
The results are non-null if and only if all frames hosted by the process are part of a single frame tree.
Can you clarify, perhaps in the explainer, exactly what this means for the following scenarios:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.