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: optimize allocations in writable CoW accounts #4846

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bmuddha
Copy link

@bmuddha bmuddha commented Feb 7, 2025

Problem

Unnecessary allocations in CoW accounts' data field, during the first write access from within the SVM. Potentially, instruction might just write to an account without reallocating, and thus premature call to Vec::reserve introduces an overhead which could be avoided.

Summary of Changes

This performance optimization removes the unnecessary calls to Vec::reserve (on AccountSharedData.data field). Instead when realloc is detected during deserialization of SVM buffer back into account, extra allocation happens on demand. This should decrease the pressure on allocator when instructions writing to the account do not reallocate, by avoiding allocation where possible.

This feature removes the unnecessary calls to Vec::reserve
(AccountSharedData.data field) Instead when realloc is detected during
deserialization of SVM buffer back into account, extra allocation
happens on demand. This should decrease the pressure on allocator when
transactions writing to the account do not reallocate, by avoiding
allocation where possible.
@bmuddha bmuddha requested a review from a team as a code owner February 7, 2025 09:11
Copy link

mergify bot commented Feb 7, 2025

The Firedancer team maintains a line-for-line reimplementation of the
native programs, and until native programs are moved to BPF, those
implementations must exactly match their Agave counterparts.
If this PR represents a change to a native program implementation (not
tests), please include a reviewer from the Firedancer team. And please
keep refactors to a minimum.

@Lichtso Lichtso requested a review from seanyoung February 7, 2025 13:21
@LucasSte
Copy link

LucasSte commented Feb 7, 2025

I believe some benchmarks could be run to make the case for this change. Maybe @seanyoung has some suggestions.

@alessandrod alessandrod self-requested a review February 7, 2025 14:10
@seanyoung
Copy link

Needs a careful review. I'll go over it a few times.

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