green-coding-solutions / green-metrics-tool

Measure energy and carbon consumption of software
https://metrics.green-coding.io
GNU Affero General Public License v3.0
166 stars 22 forks source link

Adding a no-backend option for checking a site #792

Open mrchrisadams opened 4 months ago

mrchrisadams commented 4 months ago

Hi folks, I'm creating this issue as a result of some discussion in PR 487 on the Wagtail bakery Demo repo.

Here's the key quote:

Qn1. Is there a way to manually trigger a run for a given project to see how it's working, outside of pushing new code to a branch?

I'm thinking of something along the lines of the use case in the original README for @thibaudcolas 's fork - where he demonstrated how to run a specific scenario on their remote dedicated testing hardware. A bit like this:

greenframe analyze http://localhost:8000/ homepage-landing.js

The idea here is that spinning up a full docker container, with browser and puppeteer is more than many teams are able to take on, but also getting the directly measured energy figures from a browser itself is a useful thing, that many existing tools don't offer.

The only example I DO know that supports exposing CPU usage figures is Sitespeed.io (see this issue for more), and that works by using Firefox's own profiler's own per-process figures, rather than inspecting the whole machine from the outside. When I spoke to the Firefox folks, I think that because it uses a per-process focussed approach that lists only processes the browser "owns", it was harder to see when work was offloaded to a GPU, like for video and so on.

However, please don't take that at face value though - I'm not sure if that is correct.

Anyway, something a bit like this would be really helpful and I think lower the barrier to starting with GMT:

gmt one-off focussed-usage-scenario.yml green-coding-puppeteer-container https://path-to-website-to-check

Where:

ArneTR commented 4 months ago

Hmm, now reading this I am not exactly sure anymore if I understood you correct initially:

mrchrisadams commented 3 months ago

Hi @arne

It might help to look at the workshop I delivered at Djangocon 2024 when showing folks how to use some of these tools:

Here's the link to the deck (it's quite long - see slides 46 - 60 for a little more context). https://docs.google.com/presentation/d/1mn1Qsr_vZ0lkFvIDZu5aEOginHFCpr4V/edit#slide=id.p1

That workshop introduces people to using some tools to look at a website, and use the information recorded to draw some conclusions about the carbon footprint of usage, starting with tooling like WebPageTest, then introducing people to GMT as a way to look at the full stack, instead of only relying on data transfer:

If it helps, I used this diagram below to explain how people with existing django apps can implement some of this, but as the diagram suggests, there are really two separate things people need to get meaningful numbers for web apps:

  1. an easily reproducible set of server-side components, that are somewhat representative of a live site prepopulated with data (the stuff on the left)
  2. some knowledge of how to drive a browser with code for repeatable steps, and some understanding of the usage_scenario.yml file format

PUBLIC_ DjangoconEU 2024 - Greening Digital Workshop pptx

I'm suggesting something on the right hand side - so that people can start using GMT to try running measurement runs in a setup that doesn't just rely on data transfer as the proxy, but still provides a degree of reproducibility.

I'm hoping the repo linked below gives some extra context at what I'm after, but I'll also be in Berlin next week. I'm happy to chat over lunch 👍

https://github.com/mrchrisadams/gmt-check-a-website