-
Notifications
You must be signed in to change notification settings - Fork 618
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime: temporarily workaround the LimitedMemoryPool limiting the co…
…ncurrency of the contract runtime too much (#10733) See individual commits and their descriptions for an easier review experience. This PR is intended to be easily backportable with a minimal risk, with perhaps only the 2nd commit being superfluous in that context. There are definitely things that we can do to make the reliability and sensibility of this area much better, but they would result in a much more invasive change. My belief is that we should land both this workaround *and* fix #10732 as a follow-up. cc #10732 cc @posvyatokum we will want this backported to 1.37.1, let me know if you'd like me to prepare a backport and/or where you want it to end up at. --- runtime: hotfix to allow up-to 256 concurrent runtime invocations This is not a proper fix as certain configuration settings can still make this number to be exceeded, but the changes there are a little more involved than what I'd be comfortable with making in a rush, especially for a backport to the 1.37 release. In order to keep the initial memory use reasonably bounded, I have chosen to reduce the initial size of each map to a smaller number. Since the runtime reuses most recently returned memories first, in use-cases where there are few concurrent accesses, only that many memories will get resized to fit all the required contracts over time, thus keeping the memory use reasonably limited. This will result in slightly less predictable function call performance for the first invocation of the very few first contract invocations that require more memory, but this seems like a required tradeoff to avoid preallocating dozens of GB of mappings that will later go mostly unused. --- runtime: avoid losing memories when failing to resize them This is not something that I am aware of happening but a fresh look at the code immediately spotted it as icky part of the code. The new ordering will still fail to resize and most likely lead to the termination of the node, but if the caller chooses to do something else about the error, this new setup will correctly handle returning the previous memory to the memory pool. --- runtime: switch LimitedMemoryPool to a LIFO queue crossbeam's implementation is a FIFO queue, which will repeatedly touch all of the memories, regardless of the concurrency which then can result in more memory use than strictly necessary in low-concurrency scenarios.
- Loading branch information
Showing
6 changed files
with
60 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters