astropy-project icon indicating copy to clipboard operation
astropy-project copied to clipboard

Proposal: strive to be a carbon-neutral project

Open astrofrog opened this issue 6 years ago • 24 comments

This is an idea that was discussed in Socorro (the 2019 Coordination Meeting) and started out from whether we want to scale back our CI builds to reduce our carbon footprint.

The suggestion we came up with is that regardless of whether or not we scale back the CI, we could consider trying to offset project specific CO2-emissions, such as for travel of project members to conferences or meetings, or also the CI itself. It would be good to figure out what kind of costs we'd be looking at, and also we would need to make sure that any carbon offsetting project we use is actually beneficial. If the costs are reasonable, we could aim to be a 'carbon-neutral open source project'!

Just an idea for discussion and investigation at this stage.

astrofrog avatar Dec 12 '19 21:12 astrofrog

I'm in favor of this idea broadly.

To give a bit more context of the cost for CI, prompted by a suggestion from @saimn, here is a back-of-the-envelop estimate:

  • The average desktop or laptop with 2-6 cores takes ~100 W, so ~50 W per core. CI is probably on servers, but it's very hard to get an estimate of this - the best I could find via a few minutes google is https://www.zdnet.com/article/toolkit-calculate-datacenter-server-power-usage/, which says ~1 kW for a datacenter server, which generally has tens of cores. So as an upper-limit, 50 W per core seems fairly reasonable.
  • If a single CI job takes ~10 min, that's ~8 Wh (or 0.008 kWh)
  • According to https://www.epa.gov/energy/greenhouse-gas-equivalencies-calculator that's ~ 5 g of CO2.
  • There are about 6000 PRs in astropy/astropy, and if we assume an average of 5 builds per PR (probably a high estimate), and 10 jobs per build, that's 300,000 jobs, or 1500 kg of CO2 = 1.5 metric tons.
  • Looking at some random site, carbon offsets average $3 per tonne of CO2. So offsetting all our CI from the core package would cost $5.

So we should definitely do that!

eteq avatar Dec 12 '19 23:12 eteq

Thanks for opening this issue, I think it's an important topic with all the current discussions about global warming. When I mentioned this topic I had no idea about the carbon footprint of all the CI stuff in the cloud, so @eteq numbers are interesting. Other topics like travels are of course very important as well, and probably easier to measure.

To stay on the CI topic, what I had in mind was to find some numbers about the carbon footprint of the cloud providers. I had a look, and found nothing too specific yet, but this is a hot topic. Then, I wanted to find some statistics about the number of builds triggered for astropy. http://scribu.net/travis-stats/#astropy/astropy/master gives an idea (https://github.com/scribu/travis-stats). I will try to go more in detail into this.

And finally, even if astropy's footprint is probably not too high, as shown above (or if we compare to watching series on netflix :trollface: ), I think we should keep this in mind when thinking about adding new builds etc. And this relates also to the ideas of speeding up the test suite and the doc build. It is important that the tests and docs can be run easily on people's laptop, which means that these should run fast enough. For the CI runs I think we will see some improvement thanks to the switch to tox and removal of conda, but maybe we can also make some additional efforts to speedup the tests and docs themselves (though there was already various efforts in the past).

saimn avatar Dec 13 '19 01:12 saimn

Re: tox -- It is already happening with the acceptance of APE 17. 😉

pllim avatar Dec 13 '19 16:12 pllim

If I did the calculation correctly, the carbon footprint for our flights for the Socorro coordination meeting is around 14.2 metric tonne (appropriate airport hack).

crawfordsm avatar Dec 13 '19 23:12 crawfordsm

The number I got, including the connections, is around 20t, though I ignored the fact that a few of us combined different meetings in their trip.

bsipocz avatar Dec 14 '19 21:12 bsipocz

Also (somewhat ironically while I was on an airplane...), I thought a bit more about the CI and @saimn's comments - I think I probably low-balled by maybe a factor of 2 or 3 because I didn't account for cooling/infrastructure costs, which another set of random web pages put at between 30 and 75% depending on where you look. But nothing I read indicated I was off by an order-of-magnitude.

That said, I think @saimn's underlying point is that we should always be considering this as at least "another" reason to keep our CI usage under control, which I'm 100% on board with. I was doing the exercise hoping to see that the offsetting cost would be feasible for us to pay as a project at our current scale, and if my estimate is right then we should figure out how to do that, since we definitely can!

eteq avatar Dec 16 '19 17:12 eteq

CI also has the element that it's a lot easier to truly offset it via renewable energy, since I'm pretty sure a large fraction of the carbon is just from electricity (as opposed to, say, flights, where there's really no practical way to do it "renewably" as opposed to sequestration/offsets/whatever).

eteq avatar Dec 16 '19 17:12 eteq

Might be relevant: http://arxiver.moonhats.com/2019/12/13/the-imperative-to-reduce-carbon-emissions-in-astronomy-ima/

Cadair avatar Dec 17 '19 17:12 Cadair

Comparing the simple estimates above show that travel is about an order of magnitude more important than CI jobs. I'm totally on board with reducing CI load as much as we can, but we can have a much bigger impact by reducing travel through online participation (video streaming emits significant CO2 too, but much less than flying), choosing meeting locations that reduce total travel distance, or attaching coordination meetings to existing meetings where many participants travel already (e.g. the week after a AAS meeting).

Of course, this is a comment from someone who never attended a coordination meeting in the first place. I'd like to say that that's purely because I want to reduce the carbon footprint, but I would be lying.

hamogu avatar Jan 03 '20 15:01 hamogu

There is a great benefit to meet in-person though, so 👎 on fully remote coordination meeting, but 👍 to taking steps to reduce carbon footprint of traveling.

pllim avatar Jan 03 '20 23:01 pllim

If we all switch to Windows products, maybe will help a little? 🤷‍♀

https://blogs.microsoft.com/blog/2020/01/16/microsoft-will-be-carbon-negative-by-2030/

pllim avatar Jan 17 '20 15:01 pllim

Probably worth mentioning here the recent Nature article series about carbon footprint in Astronomy (Observatories, HPC, meetings, and Python rant): https://www.nature.com/articles/s41550-020-01216-9

saimn avatar Oct 02 '20 14:10 saimn

Running Python on a single CPU core of a powerful workstation has a relatively high environmental cost; instead, prefer C++ — it is faster anyway.

Hahah... Spending 100 hours trying to debug C++ also has a cost (all the coffee you drink, all the lights that are not off because you are not sleeping, etc). I am not convinced by that sentence alone.

pllim avatar Oct 02 '20 14:10 pllim

FWIW I've been playing around with scraping GH actions stats and combining them with info from https://www.green-algorithms.org/ to estimate CI emissions - over at sunpy I estimated ~50kg CO2 across the whole of 2022, and for the last month of astropy these are my results:

astropy_ci_co2

Code here: https://github.com/dstansby/ci-impact

dstansby avatar Jan 05 '23 18:01 dstansby

@dstansby , thanks! Is this good or bad news?

pllim avatar Jan 23 '23 20:01 pllim

I'd say this is good news, astropy is making a negligible contribution to CO2 emissions from what I've seen. This looks like around 200 kg/year.

  • The average American contributes 25000 kg/year.
  • A single Boston/LA flight is likely around 300,000 - 400,000 kg [1]

The snow falling outside right now in Boston has probably cancelled enough flights to make up for the CI for every major open source project for many years.

[1] https://www.carbonindependent.org/22.html#:~:text=CO2%20emissions%3A%20101%20g%20per,CO2%20per%20passenger%20per%20hour

I'll confess that 300,000 kg of carbon coming from a single plane seems not credible since a 747-400 has a fuel capacity of 216,840 liters. But anyway a single flight generates literally tons of carbon.

taldcroft avatar Jan 23 '23 21:01 taldcroft

I'd agree with ☝️ - I went into looking into investigating thinking CI would have a large footprint, and came out of it thinking that it's practically at the bottom of the list of things to worry about.

dstansby avatar Jan 23 '23 21:01 dstansby

I'll confess that 300,000 kg of carbon coming from a single plane seems not credible since a 747-400 has a fuel capacity of 216,840 liters. But anyway a single flight generates literally tons of carbon.

That's per flight, not per person. 1 liter of fuel is just under 1 kg. Fuel is a hydrocarbon, and since H has a atomic weight of 1, most of the weight is actually carbon. CO2 on on the other hand has a much higher weight because of the 2 O. So, 1 liter of fuel makes ~ 3 kg of CO2. A Boston-LA flight is below the max range of a 747, so that works out.

"CO2 per passenger" is in the range of 2000-4000 kg CO2 depending on average filling factor of the plane, ticket class (business seat takes more space) etc. Often, calculators with "CO2 equivalent" which for flights is 2-3 times CO2 by weight to account for the fact that that CO2 is emitted very high in the atmosphere where is acts more strongly than at ground level.

hamogu avatar Jan 23 '23 23:01 hamogu

I'd also take that as a rather positive (mild) surprise (had expected the impact to be moderate, but not that modest).

"CO2 per passenger" is in the range of 2000-4000 kg CO2 depending on average filling factor of the plane, ticket class (business seat takes more space) etc.

That's also the typical number I had in mind for transatlantic flights, generally a bit longer than East to West coast.

Often, calculators with "CO2 equivalent" which for flights is 2-3 times CO2 by weight to account for the fact that that CO2 is emitted very high in the atmosphere where is acts more strongly than at ground level.

I rather doubt that's a strong factor; CO2 having a life time in the atmosphere of ~centuries will fully mix long before that. I think some factors are applied to account for the additional positive or negative warming effect due to aerosol nucleation at high altitudes (which is not very well known and probably even depends on what climate zone etc. the plane moves in).

dhomeier avatar Jan 23 '23 23:01 dhomeier

Often, calculators with "CO2 equivalent" which for flights is 2-3 times CO2 by weight to account for the fact that that CO2 is emitted very high in the atmosphere where is acts more strongly than at ground level.

I rather doubt that's a strong factor; CO2 having a life time in the atmosphere of ~centuries will fully mix long before that. I think some factors are applied to account for the additional positive or negative warming effect due to aerosol nucleation at high altitudes (which is not very well known and probably even depends on what climate zone etc. the plane moves in).

A factor of 2-3 is currently considered best practice. See discussion here https://travel-footprint-calculator.irap.omp.eu/home.html and in particular section 2.3 of Barret (2020).

hamogu avatar Jan 24 '23 00:01 hamogu

So, 1 liter of fuel makes ~ 3 kg of CO2. A Boston-LA flight is below the max range of a 747, so that works out.

Of course, makes sense. I didn't consider pulling in atmospheric oxygen to end up emitting more CO2 mass than the mass of the fuel.

taldcroft avatar Jan 24 '23 10:01 taldcroft

But back to the actual issue here, can we close this?

taldcroft avatar Jan 24 '23 10:01 taldcroft

can we close this?

Should we at least document this finding somewhere more official (Zenodo? website? blog?) before closing the issue?

pllim avatar Jan 24 '23 11:01 pllim