-
Notifications
You must be signed in to change notification settings - Fork 106
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
Using the cache for function bindings and not deleting shared memory resources upon request to close #844
Conversation
…ates if the maps should be deleted or just the reference should be dropped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor comments. Also, can you please add testing for cache-enabled scenarios? to see if the same shared mem is reused or not?
azure_functions_worker/bindings/shared_memory_data_transfer/shared_memory_manager.py
Outdated
Show resolved
Hide resolved
That's a very good point. |
Co-authored-by: Varad Meru <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit changes. otherwise, LGTM. 🚢
azure_functions_worker/dispatcher.py
Outdated
if self._function_data_cache_enabled: | ||
# If the cache is enabled, let the host decide when to | ||
# delete the resources. | ||
# Just drop the reference from the worker. | ||
to_delete = False | ||
else: | ||
# If the cache is not enabled, the worker should free | ||
# the resources as at this point the host has read the | ||
# memory maps and does not need them. | ||
to_delete = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self._function_data_cache_enabled: | |
# If the cache is enabled, let the host decide when to | |
# delete the resources. | |
# Just drop the reference from the worker. | |
to_delete = False | |
else: | |
# If the cache is not enabled, the worker should free | |
# the resources as at this point the host has read the | |
# memory maps and does not need them. | |
to_delete = True | |
to_delete_reference = False if self._function_data_cache_enabled else True |
And please add the comment in the python docs section of this method itself.
azure_functions_worker/dispatcher.py
Outdated
# the resources as at this point the host has read the | ||
# memory maps and does not need them. | ||
to_delete = True | ||
success = self._shmem_mgr.free_mem_map(map_name, to_delete) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
success = self._shmem_mgr.free_mem_map(map_name, to_delete) | |
success = self._shmem_mgr.free_mem_map(map_name, to_delete_reference) |
If above suggestion is included, please include this and also check if there is any other place to_delete
is mentioned.
Description
When the host sends a message to close shared memory resources, instead of deleting the shared memory resources (i.e. files in the case of Linux) just drop the handle and let the worker delete the resources.
When the host advertises the capability for using FunctionDataCache, use that even for small objects (without imposing the minimum size constraint.)
This PR is part of the work described in Azure/azure-functions-host#7310
PR information
Quality of Code and Contribution Guidelines