gramineproject / gramine-tdx

A library OS for Linux multi-process applications, with Intel TDX support (experimental)
GNU Lesser General Public License v3.0
16 stars 2 forks source link

[PAL/vm-common] Do not malloc/free timeout objects but instead use an ever-growing array #2

Open dimakuv opened 9 months ago

dimakuv commented 9 months ago

Description of the feature

Timeouts can be very frequent, and each timeout is malloced and later freed, which is a rather expensive op. See https://github.com/gramineproject/gramine-tdx/blob/intel_tdx/pal/src/host/vm-common/kernel_time.c, functions register_timeout() and deregister_timeout().

Instead, we can re-use the timeout objects, similarly to how we re-use thread stacks.

Why Gramine should implement it?

Timeouts are extensively used in futex() syscalls. And futex syscalls may be very frequent.

We may implement this optimization, but need to first make sure it can be a real bottleneck.