OpenDataPlane / odp-dpdk

OpenDataPlane DPDK platform implementation
https://opendataplane.org
Other
80 stars 40 forks source link

Power saving API #235

Open bogdanPricope opened 11 months ago

bogdanPricope commented 11 months ago

Hi,

Have you consider adding API/implementation to reduce power consumption: e.g. sleeping the workers when there is not traffic and awake them on RX interrupts?

DPDK was some API for that: rte_eth_dev_rx_intr_enable()/rte_eth_dev_rx_intr_disable()/rte_eth_dev_rx_intr_ctl_q()/rte_epoll_wait().

Best regards

MatiasElo commented 11 months ago

Hi,

So far we haven't seen application use-cases, but I can see these being useful for certain applications. We'll add this to our backlog.

Currently, the logical place for power saving is odp_schedule() implementation. @JereLeppanen has actually been testing this and there is a configuration option (sched_basic: powersave), which enables worker threads to sleep for a certain time when no work is available.

bogdanPricope commented 11 months ago

Hi @MatiasElo,

One can imagine some cases:

I am not saying 'to save the planet' but to reduce power consumption (costs) when it makes sense... and frankly 'some' setups may overheat at full power on all cores.

Now, odp_schedule() will be ideal but an API at pktin level may cover part of the cases...

FYI next release of nfp (my ofp) will provide a 'power' example and a patch on top of odp-dpdk/linux-generic.

bogdanPricope commented 10 months ago

Hi @MatiasElo,

Please have a look at the odp-dpdk patch and API utilization example:

https://github.com/NetInoSoftware/nfp/blob/master/example/fpm_power/0001-pktin-Add-RX-interrupt-management-API.patch https://github.com/NetInoSoftware/nfp/blob/master/example/fpm_power/app_main.c

As you said, odp_schedule() would be the logical place for power saving but the API proposed by this patch may suffice for 'direct mode' implementations.

Best regards

MatiasElo commented 10 months ago

Hi @bogdanPricope, thanks for the examples. Adding the new APIs will be a bigger task, but perhaps this functionality could be added to odp_pktin_recv_tmo() implementation without any API changes. Initially the functionality could be enabled/disabled using the config file.

MatiasElo commented 10 months ago

Based on quick testing this seems to work: https://github.com/MatiasElo/odp-dpdk/commit/c29b8b1cbe42224afbcb403bb3d24e9bad2a029f

bogdanPricope commented 10 months ago

Hi @MatiasElo, a requirement for my use case is to wait for multiple pktins (maybe from different interfaces). I guess a change on odp_pktin_recv_mq_tmo() is also needed.

MatiasElo commented 10 months ago

Okay, implementing that will be more complex but should still be possible.