NNS Update, November 21, 2024

The NNS Team submitted the following proposals. DFINITY plans to vote on these proposals the sooner than usual because of its urgency. More details are in the proposal.

Proposals to be Submitted

NNS Governance: https://dashboard.internetcomputer.org/proposal/134249


# Upgrade the Governance Canister to Commit fa14955

__Proposer__: jason.zhu at dfinity.org

__Source code__: [fa149557c44967f621c03224460eb6639f5c03c6][new-commit]

[new-commit]: https://github.com/dfinity/ic/tree/fa149557c44967f621c03224460eb6639f5c03c6

## Urgent Release

This is to fix a performance degradation introduced by the previous release. Therefore DFINITY intends to vote on it sooner than usual.

Because we do not want to introduce more changes than what's necessary, this release is not built from master, but a branch based on the previous release (proposal 134193) with only the bug fix applied on top of it.

## New Commits

```

$ git log --format="%C(auto) %h %s" f5a63fd41933eee24ab3a6c71e43c67c1048e0db..fa149557c44967f621c03224460eb6639f5c03c6 -- ./rs/nns/governance ./rs/sns/init

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

```

## Current Version

__Current git hash__: f5a63fd41933eee24ab3a6c71e43c67c1048e0db

__Current wasm hash__: c7cd011d711edadc024d2673c090cea17688eca1748648d04c0c0afbdaebdbdc

## Verification

See the general instructions on [how to verify] proposals like this. A "quick

start" guide is provided here.

[how to verify]: https://github.com/dfinity/ic/tree/fa149557c44967f621c03224460eb6639f5c03c6/rs/nervous_system/docs/proposal_verification.md

### WASM Verification

See ["Building the code"][prereqs] for prerequisites.

[prereqs]: https://github.com/dfinity/ic/tree/fa149557c44967f621c03224460eb6639f5c03c6/README.adoc#building-the-code

```

# 1. Get a copy of the code.

git clone git@github.com:dfinity/ic.git

cd ic

# Or, if you already have a copy of the ic repo,

git fetch

git checkout fa149557c44967f621c03224460eb6639f5c03c6

# 2. Build canisters.

./ci/container/build-ic.sh -c

# 3. Fingerprint the result.

sha256sum ./artifacts/canisters/governance-canister.wasm.gz

```

This should match `wasm_module_hash` field of this proposal.

Note: the proposal https://dashboard.internetcomputer.org/proposal/134248 should be rejected as there is some problem with reproducibility.

1 Like

Proposal #134249

Vote: Adopted
Reason: Builds fine and the hash matches.

Review:

The branch is this one.
fa149557c4 fix(nns): Avoid cloning heap_neurons to avoid performance penalty (#43)

The with_active_neurons_iter_sections function is used for iterating over active neurons in sections, depending if stable memory store or heap-based memory store is in use.
When use_stable_memory_for_all_neurons is true it accesses neurons using the with_stable_neuron_store function.
Filters neurons to include only those that are active, using range_neurons_sections(.., sections) retrieves neurons within the specified sections.
.filter(|n| !n.is_inactive(now)) excludes inactive neurons based on the current time (self.now()). it converts neurons from the stable memory store to owned Cow (Copy on Write) types via Cow::Owned.
Chains these with neurons from the heap memory store (self.heap_neurons.values()), converted to borrowed Cow using Cow::Borrowed.
When use_stable_memory_for_all_neurons is false the function directly iterates over all heap neurons (self.heap_neurons.values()) and converts them into borrowed Cow types (Cow::Borrowed) to avoid unnecessary cloning.

1 Like

proposal - 134249

Vote: ADOPT

Reason:

I have successfully built cycles ledger and validated the hash, confirming that all commit messages accurately describe the corresponding modifications in the code.

Hash Match: MATCH

Feedback: NONE

Proposer Check: MATCH

Commits

fa149557c4
Replaces unnecessary cloning of neuron objects with more efficient borrowing using Cow<Neuron>. This reduces performance overhead and improves memory management by preventing the duplication of large neuron data structures.

1 Like

Proposal Review

Args, canister id and install mode are correct.

Canister hash is reproducible

Screenshot 2024-11-22 at 16.47.07

Code Changes

This change refactors NeuronStore to use Cow<Neuron> for iterators, enabling efficient borrowing or cloning of neurons as needed. By avoiding unnecessary cloning, it reduces memory overhead and improves performance. Methods now process neurons as references (&Neuron), and neurons from stable memory are wrapped as Cow::Owned while heap neurons are Cow::Borrowed. This ensures flexibility and resource efficiency while maintaining existing functionality.

1 Like

Proposal 133249

Vote: ADOPT

Reason: Build is successful and both code changes and hashes match.

134249

fa149557c4 Avoid unnecessary clones of heap neurons when iterating from the NeuronStore, to do this the callbacks passed to with_active_neurons_iter and with_active_neurons_iter_sections now take in a Neuron wrapped into a clone on write smart pointer, which allows to return either a reference or an owned value with stable store neurons mapped as Cow:Owned and heap neurons as Borrowed

1 Like