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

TrieStore to Channels #7845

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

TrieStore to Channels #7845

wants to merge 2 commits into from

Conversation

benaadams
Copy link
Member

Changes

  • Wrapping a ConcurrentQueue in a BlockingCollection burns a ton of CPU spinning; whereas its a pattern ideally suited to Channels; and using true async

Types of changes

What types of changes does your code introduce?

  • Optimization
  • Refactoring

Testing

Requires testing

  • No

}
});
}
await foreach (var disposable in disposeQueue.Reader.ReadAllAsync())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will it correctly partition items from channel between 4 tasks/threads here?

writeBatch = _nodeStorage.StartWriteBatch();
}
}

tn.CallRecursively(DoPersist, address2, ref path, GetTrieStore(address2), true, _logger);
disposeQueue.Add(writeBatch);
await tn.CallRecursivelyAsync(DoPersist, address2, path, GetTrieStore(address2), true, _logger);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this can break anything... probably not

Comment on lines +1012 to +1014
int previousLength = AppendChildPath(ref currentPath, i);
await child.CallRecursivelyAsync(action, storageAddress, currentPath, resolver, skipPersisted, logger, maxPathLength, resolveStorageRoot);
currentPath.TruncateMut(previousLength);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No point to mutate the path as we have to do the copy anyways?

@benaadams
Copy link
Member Author

Will wait on this as might be better way to do it with #7787 without introducing a second code path

@benaadams benaadams marked this pull request as draft December 2, 2024 10:32
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