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

feat(nns): Avoid cloning large fields when listing proposals #3505

Merged
merged 2 commits into from
Jan 28, 2025

Conversation

jasonz-dfinity
Copy link
Contributor

@jasonz-dfinity jasonz-dfinity commented Jan 17, 2025

Why

When converting from ProposalData to ProposalInfo, the large fields (e.g. canister WASMs, logos) are "omitted" in a way that those fields are first cloned then cleared. It indeed saves space in the response by not including them, but the instructions are nevertheless wasted for the clone, and this can be significant for certain queries (e.g. listing only proposals including canister WASMs).

What

  • Make ProposalInfo/ListProposalInfoResponse pure API types, by removing its corresponding internal type
  • Add conversion method proposal_data_to_info from the ProposalData internal type to ProposalInfo API type
  • Implement the equivalent behavior of omit_large_fields in the conversion code
  • Let Governance::list_proposals use the new conversion method and return ListProposalInfoResponse(API type)
  • Update benchmark results (98% improvement on list_proposals)

Tests

rs/nns/governance/tests/governance.rs already tests various cases for omit_large_fields

@jasonz-dfinity jasonz-dfinity requested a review from a team as a code owner January 17, 2025 17:39
@github-actions github-actions bot added the feat label Jan 17, 2025
@jasonz-dfinity jasonz-dfinity force-pushed the jason/NNS1-2973-2 branch 2 times, most recently from 95c8e2a to 4d9e416 Compare January 21, 2025 21:26
Base automatically changed from jason/NNS1-2973-2 to master January 22, 2025 21:29
@jasonz-dfinity jasonz-dfinity requested a review from a team as a code owner January 23, 2025 20:12
@jasonz-dfinity jasonz-dfinity force-pushed the jason/NNS1-2973-3 branch 3 times, most recently from e6ccd24 to bd89934 Compare January 24, 2025 00:03
@jasonz-dfinity jasonz-dfinity requested a review from a team as a code owner January 24, 2025 00:03
@kpop-dfinity
Copy link
Contributor

//rs/tests/consensus changes LGTM

@jasonz-dfinity jasonz-dfinity force-pushed the jason/NNS1-2973-3 branch 2 times, most recently from a20bff2 to f751e43 Compare January 24, 2025 21:55
@jasonz-dfinity jasonz-dfinity requested a review from a team as a code owner January 24, 2025 21:55
@jasonz-dfinity jasonz-dfinity added this pull request to the merge queue Jan 28, 2025
Merged via the queue into master with commit 3aa3266 Jan 28, 2025
25 checks passed
@jasonz-dfinity jasonz-dfinity deleted the jason/NNS1-2973-3 branch January 28, 2025 19:09
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.

6 participants