Skip to content
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

Heap growth strategies #771

Merged
merged 1 commit into from
Sep 14, 2023
Merged

Conversation

pguyot
Copy link
Collaborator

@pguyot pguyot commented Aug 20, 2023

Strategies can be selected with spawn_opt/2,4 and affect how heap is grown.
Three strategies are implemented:

  • bounded free: keep free space within bounds (this is the old implementation)
  • minimum: always try to mimimize free space
  • fibonacci: grow heap following fibonacci up to a certain point
    (inspired from Erlang/OTP)

Also fix allocation with min_heap_size (a bug in strategy generated a lot of
useless garbage collections).
Also fix semantic of heap_size for process_info and add total_heap_size.

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 pguyot marked this pull request as draft August 20, 2023 13:55
pguyot added a commit to pguyot/AtomVM that referenced this pull request Aug 20, 2023
Cache last module in scheduler loop to reduce lookups of modules by index
Also fix a bug in stacktraces where the lock was not held
Also remove pointer to GlobalContext from modules

This optimization, in addition to PRs atomvm#766, atomvm#770, atomvm#771 and atomvm#772, bring an
additional gain of 2-3% on Sudoku benchmark

Signed-off-by: Paul Guyot <[email protected]>
pguyot added a commit to pguyot/AtomVM that referenced this pull request Aug 20, 2023
Cache last module in scheduler loop to reduce lookups of modules by index
Also fix a bug in stacktraces where the lock was not held
Also remove pointer to GlobalContext from modules

This optimization, in addition to PRs atomvm#766, atomvm#770, atomvm#771 and atomvm#772, bring an
additional gain of 2-3% on Sudoku benchmark

Signed-off-by: Paul Guyot <[email protected]>
pguyot added a commit to pguyot/AtomVM that referenced this pull request Aug 20, 2023
Cache last module in scheduler loop to reduce lookups of modules by index
Also fix a bug in stacktraces where the lock was not held
Also remove pointer to GlobalContext from modules

This optimization, in addition to PRs atomvm#766, atomvm#770, atomvm#771 and atomvm#772, bring an
additional gain of 2-3% on Sudoku benchmark

Signed-off-by: Paul Guyot <[email protected]>
pguyot added a commit to pguyot/AtomVM that referenced this pull request Aug 20, 2023
Cache last module in scheduler loop to reduce lookups of modules by index
Also fix a bug in stacktraces where the lock was not held
Also remove pointer to GlobalContext from modules

This optimization, in addition to PRs atomvm#766, atomvm#770, atomvm#771 and atomvm#772, bring an
additional gain of 2-3% on Sudoku benchmark

Signed-off-by: Paul Guyot <[email protected]>
@pguyot pguyot force-pushed the w33/heap-growth-strategies branch from 801b4bc to 07cb05a Compare August 20, 2023 20:50
pguyot added a commit to pguyot/AtomVM that referenced this pull request Aug 21, 2023
Cache last module in scheduler loop to reduce lookups of modules by index
Also fix a bug in stacktraces where the lock was not held
Also remove pointer to GlobalContext from modules

This optimization, in addition to PRs atomvm#766, atomvm#770, atomvm#771 and atomvm#772, bring an
additional gain of 2-3% on Sudoku benchmark

Signed-off-by: Paul Guyot <[email protected]>
pguyot added a commit to pguyot/AtomVM that referenced this pull request Aug 21, 2023
Cache last module in scheduler loop to reduce lookups of modules by index
Also fix a bug in stacktraces where the lock was not held
Also remove pointer to GlobalContext from modules

This optimization, in addition to PRs atomvm#766, atomvm#770, atomvm#771 and atomvm#772, bring an
additional gain of 2-3% on Sudoku benchmark

Signed-off-by: Paul Guyot <[email protected]>
pguyot added a commit to pguyot/AtomVM that referenced this pull request Aug 24, 2023
Cache last module in scheduler loop to reduce lookups of modules by index
Also fix a bug in stacktraces where the lock was not held
Also remove pointer to GlobalContext from modules

This optimization, in addition to PRs atomvm#766, atomvm#770, atomvm#771 and atomvm#772, bring an
additional gain of 2-3% on Sudoku benchmark

Signed-off-by: Paul Guyot <[email protected]>
pguyot added a commit to pguyot/AtomVM that referenced this pull request Aug 25, 2023
Cache last module in scheduler loop to reduce lookups of modules by index
Also fix a bug in stacktraces where the lock was not held
Also remove pointer to GlobalContext from modules

This optimization, in addition to PRs atomvm#766, atomvm#770, atomvm#771 and atomvm#772, bring an
additional gain of 2-3% on Sudoku benchmark

Signed-off-by: Paul Guyot <[email protected]>
pguyot added a commit to pguyot/AtomVM that referenced this pull request Aug 25, 2023
Cache last module in scheduler loop to reduce lookups of modules by index
Also fix a bug in stacktraces where the lock was not held
Also remove pointer to GlobalContext from modules

This optimization, in addition to PRs atomvm#766, atomvm#770, atomvm#771 and atomvm#772, bring an
additional gain of 2-3% on Sudoku benchmark

Signed-off-by: Paul Guyot <[email protected]>
@pguyot pguyot force-pushed the w33/heap-growth-strategies branch 2 times, most recently from 7bdab8c to fd06c29 Compare August 27, 2023 05:41
pguyot added a commit to pguyot/AtomVM that referenced this pull request Aug 27, 2023
Cache last module in scheduler loop to reduce lookups of modules by index
Also fix a bug in stacktraces where the lock was not held
Also remove pointer to GlobalContext from modules

This optimization, in addition to PRs atomvm#766, atomvm#770, atomvm#771 and atomvm#772, bring an
additional gain of 2-3% on Sudoku benchmark

Signed-off-by: Paul Guyot <[email protected]>
pguyot added a commit to pguyot/AtomVM that referenced this pull request Aug 27, 2023
Cache last module in scheduler loop to reduce lookups of modules by index
Also fix a bug in stacktraces where the lock was not held
Also remove pointer to GlobalContext from modules

This optimization, in addition to PRs atomvm#766, atomvm#770, atomvm#771 and atomvm#772, bring an
additional gain of 2-3% on Sudoku benchmark

Signed-off-by: Paul Guyot <[email protected]>
bettio added a commit that referenced this pull request Sep 1, 2023
Optimize usage of temporary stack by allocating first words on C stack

This change, combined with a Fibonacci heap growth strategy (#771),
approximatively divides execution time by two with the Sudoku benchmark.

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
bettio added a commit that referenced this pull request Sep 1, 2023
…ule-index

Reduce lock contention on GlobalContext.module_locks

Cache last module in scheduler loop to reduce lookups of modules by index
Also fix a bug in stacktraces where the lock was not held
Also remove pointer to GlobalContext from modules

This optimization, in addition to PRs #766, #770, #771 and #772, brings an
additional gain of 2-3% on Sudoku benchmark

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 pguyot force-pushed the w33/heap-growth-strategies branch from fd06c29 to 7836b02 Compare September 7, 2023 16:55
@pguyot pguyot marked this pull request as ready for review September 7, 2023 16:56
libs/estdlib/src/erlang.erl Outdated Show resolved Hide resolved
@pguyot pguyot force-pushed the w33/heap-growth-strategies branch 2 times, most recently from 053fe93 to 2f3ed6e Compare September 8, 2023 18:14
Strategies can be selected with `spawn_opt/2,4` and affect how heap is grown.
Three strategies are implemented:
- bounded free: keep free space within bounds (this is the old implementation)
- minimum: always try to mimimize free space
- fibonacci: grow heap following fibonacci up to a certain point
  (inspired from Erlang/OTP)

Also fix allocation with min_heap_size (a bug in strategy generated a lot of
useless garbace collections).
Also fix semantic of `heap_size` for process_info and add `total_heap_size`.

Signed-off-by: Paul Guyot <[email protected]>
@pguyot pguyot force-pushed the w33/heap-growth-strategies branch from 2f3ed6e to 30259fe Compare September 10, 2023 18:40
@bettio bettio merged commit df24dfe into atomvm:master Sep 14, 2023
80 checks passed
@pguyot pguyot deleted the w33/heap-growth-strategies branch September 15, 2023 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants