Skip to content

BAAS-35403 use func over bool for runtime shouldTrackMaxMemOnStack#131

Merged
kpatel71716 merged 2 commits into
mongodb-forks:realmfrom
kpatel71716:BAAS-35403
Apr 11, 2025
Merged

BAAS-35403 use func over bool for runtime shouldTrackMaxMemOnStack#131
kpatel71716 merged 2 commits into
mongodb-forks:realmfrom
kpatel71716:BAAS-35403

Conversation

@kpatel71716
Copy link
Copy Markdown

Memory checking on the vm stack push was more expensive than anticipated with certain functions so refactoring to allow BAAS to declare what should be checked.

If we just check specific functions based on the function name, we can significantly reduce when the memory checks need to happen. We can pass in the function name of our microtask logic in the upstream event loop to more accurately capture memory usage with the drawback that this only works for asynchronous functions. Though this should cover the majority of our use cases so this should be ok.

@kpatel71716 kpatel71716 marked this pull request as draft April 11, 2025 16:54
@kpatel71716 kpatel71716 marked this pull request as ready for review April 11, 2025 16:56
@Gabri3l Gabri3l requested a review from Copilot April 11, 2025 17:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

vm.go:863

  • Consider reviewing the usage of 'string(vm.funcName)' to ensure that 'vm.funcName' is of a type that actually requires conversion. If it is already a string, the conversion may be unnecessary and could indicate a type inconsistency.
if !vm.r.shouldTrackMaxMemOnStack(string(vm.funcName)) {

vm_test.go:830

  • [nitpick] Consider extracting the inline lambda assignment into a helper function since it appears in multiple test cases. This can reduce code duplication and improve clarity.
vmRuntime.shouldTrackMaxMemOnStack = func(_ string) bool {

@kpatel71716 kpatel71716 merged commit 7c07cb7 into mongodb-forks:realm Apr 11, 2025
2 of 6 checks passed
@kpatel71716 kpatel71716 deleted the BAAS-35403 branch April 11, 2025 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants