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

fix(nns): Avoid cloning heap_neurons to avoid performance penalty #2726

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

max-dfinity
Copy link
Contributor

@max-dfinity max-dfinity commented Nov 20, 2024

This PR fixes a regression in a previous change that causes performance for heartbeats to drop while still using heap neurons. This fixes the method to use Cow instead, so that heap neurons are not unnecessarily cloned.

@max-dfinity max-dfinity changed the title fix(nns) Avoid cloning heap_neurons to avoid performance penalty before migration to stable memory fix(nns): Avoid cloning heap_neurons to avoid performance penalty Nov 20, 2024
@github-actions github-actions bot added the fix label Nov 20, 2024
@max-dfinity max-dfinity marked this pull request as ready for review November 20, 2024 19:38
@max-dfinity max-dfinity requested a review from a team as a code owner November 20, 2024 19:38
@max-dfinity max-dfinity added this pull request to the merge queue Nov 21, 2024
Merged via the queue into master with commit 2f63d24 Nov 21, 2024
30 of 31 checks passed
@max-dfinity max-dfinity deleted the fix-performance-drop branch November 21, 2024 16:27
github-merge-queue bot pushed a commit that referenced this pull request Nov 22, 2024
# Why

There was a recent regression on how we list neurons ready to unstake
maturity or spawn. Adding benchmarks for those will help prevent them in
the future (although, currently they are not enabled in CI yet).

# What

Adding benchmarks for `list_ready_to_spawn_neuron_ids` and
`list_neurons_ready_to_unstake_maturity`. Additional dimensions are: (1)
whether the "active neuron in stable memory" is enabled (2) whether
there are actually meaningful return value.

# Testing

When running against changes in #2726
, we get the following results:

---------------------------------------------------
Benchmark: list_ready_to_spawn_neuron_ids_heap
  total:
    instructions: 455.22 K (improved by 86.76%)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: list_ready_to_spawn_neuron_ids_stable
  total:
    instructions: 710.56 M (0.00%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: list_neurons_ready_to_unstake_maturity_heap
  total:
    instructions: 463.15 K (improved by 86.54%)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------

Benchmark: list_neurons_ready_to_unstake_maturity_stable
  total:
    instructions: 710.57 M (0.00%) (change within noise threshold)
    heap_increase: 0 pages (no change)
    stable_memory_increase: 0 pages (no change)

---------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants