AtomVM icon indicating copy to clipboard operation
AtomVM copied to clipboard

Move x registers from contexts to schedulers

Open pguyot opened this issue 2 years ago • 1 comments

X registers are saved in context on context switching but are otherwise allocated only once per scheduler thread, thus allowing up to 1024 registers as the compiler allows

These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

pguyot avatar Nov 13 '23 21:11 pguyot

This approach is one of the 2 I was thinking about. The other was offloading x regs > to a linked list, which is very slow, but it might be ok since they are not frequently used. This approach has the con of using 4K for each executor thread, so 8K on ESP32. Anyway I would like to benchmark this approach against other alternatives so we can make a good decision about it. Last final thought on it: this is a big change in terms of C API, so we might target it for master.

In https://github.com/atomvm/AtomVM/pull/954/commits/1c99c770a007a246cd7816ff7906c4e92d16c217 I propose to limit allocation to the number of x registers used by modules so far.

pguyot avatar Nov 19 '23 22:11 pguyot