-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve performance of conservative routine #42
Comments
Originally posted by @slevang in #39 (comment) |
I've been trying out the conservative method on some more realistic workloads, and found the performance comparisons with xesmf not super compelling. Here's a basic example: import dask.array as da
import xarray as xr
import xarray_regrid
bounds = dict(south=-90, north=90, west=-180, east=180)
source = xarray_regrid.Grid(
resolution_lat=0.25,
resolution_lon=0.25,
**bounds,
).create_regridding_dataset()
target = xarray_regrid.Grid(
resolution_lat=1,
resolution_lon=1,
**bounds,
).create_regridding_dataset()
n_times = 1000
data = da.random.random(
size=(n_times, source.latitude.size, source.longitude.size),
chunks=(1, -1, -1),
).astype("float32")
source = xr.DataArray(
data,
dims=["time", "latitude", "longitude"],
coords={
"time": xr.date_range("2000-01-01", periods=n_times, freq="D"),
"latitude": source.latitude,
"longitude": source.longitude,
}
) xarray-regrid: %time source.regrid.conservative(target, skipna=False).compute();
%time source.regrid.conservative(target, skipna=True).compute();
vs xesmf: import xesmf as xe
regridder = xe.Regridder(source, target, "conservative")
%time regridder(source, skipna=False).compute()
%time regridder(source, skipna=True).compute();
|
Hm, I get much better performance on a small XPS13 laptop (19 seconds wall time for xarray-regrid with skipna=False, 164 seconds for xESMF). What is your Dask setup? Have you tried setting up dask.distributed? import dask.distributed
client = dask.distributed.Client() I am using the latest (non-released) xarray-regrid code, and latest xESMF. For both regridders all CPU threads are 100% occupied during most of the benchmark run. Dask is complaining about large graph sizes with xESMF though. |
Interesting! Do you have I ran these on a 32 core GCP VM, and only with the default threaded scheduler, so it's definitely worth profiling across other uses. I'll try distributed but wouldn't expect much difference since this is a very straightforward task graph and no impact from the GIL. With dense weights I definitely see all CPUs churning at full speed, but there are a massive number of 0s in those einsums. Sparse multiplication is algorithmically less efficient but we have a lot less numbers to multiply. |
I did not. Installing it also did not seem to matter.
I would have expected a much better performance then. I use a 4-core/8 thread Intel i7, and my compute time was <40% of yours for the same code.
I stopped using that one due to finding it not as reliable (sometimes it's a lot less performant) and more difficult to debug vs the distributed scheduler https://dask-local.readthedocs.io/en/latest/setup/single-distributed.html#single-machine-dask-distributed
Yeah it makes sense. I did not notice an improvement, but also not drop in performance. |
Originally posted by @slevang in #39 (comment)
The text was updated successfully, but these errors were encountered: