-
Notifications
You must be signed in to change notification settings - Fork 51
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
Missing API function ldms_record_free() #1052
Comments
@nichamon, I thought we had this or a similar interface...can you confirm or comment? |
@narategithub Added Narate as he was the one who implemented most of the APIs. I checked and found that we don't have an API to free up a record instance's heap memory. The closest API we have to free a record instance is |
I believe that we don't have such an API to prevent the case that the sampler authors call the API to destroy a record instance that has been appended to a list. We could provide the API. It will behave as @narategithub Correct me here if adding the API may lead us down a rabbit hole. |
@nichamon historically before we have the record, elements in the list are created and appended in one go with When the record feature is introduced, the Or, maybe we should change the /**
* \retval rec_inst The record instance to use with `ldms_record_metric_set/get`
*/
ldms_mval_t ldms_list_append_record(ldms_set_t set, ldms_mval_t lh, int rec_def_idx); that will allocate + append in one go like the primitive elements and get rid of |
The combined allocate+append sounds reasonable to me. Also, speaking of ldms_list_remove_item(), it might be good to expand the comment to mention records or something. It was not clear to me how to remove a record from a list since there is a custom ldms_list_append_record(), but no matching ldms_list_remove_record(). |
@narategithub, @nichamon, @morrone I am inclined to keep the API as designed/written and update the documentation to make it clear exactly what is being done so that it is obvious to users such as @morrone what exactly the interface does with primitive and record types. I'm not inclined to splitting the interfaces because I think it makes the code more complex and introduces the possibility of programming errors where a list element is de-allocated while there is a still a reference on the item. |
@morrone, @narategithub, @nichamon we implemented arrays of records only because we could. I think we should consider whether or not this is wise. Arrays are fixed size and this means that users of the array have to know what an 'empty' entry means and how it is encoded, 0, for example. But I think in general the coding involved with reasonably handling arrays of records in stores, for example, is more of a challenge than lists. Please comment with your perspectives. |
@tom95858 if this comment is only in reference to having adding "ldms_list_remove_record()", that is fine with me. Code comments could certainly address my confusion. @narategithub's suggested API change to ldms_list_append_record() and the associated removal of ldms_record_alloc() seems like a good one. That simplifies the API, and removes an opportunity for programming error. |
My use cases all involve lists of records at this point. The fact that I need to know a record array's length at schema creation time rather than metric set creation time makes record arrays unusable for any of the use cases that I currently have in mind. Getting rid of the record arrays would also also eliminate an inconsistency in the API naming that was a bit confusing. There are a number of function names that start with "ldms_record_array_" but operate on distinctly different things. These functions operate on an array of records:
But these functions operate on an array that is inside of a record:
|
Hi @morrone, @nichamon is going to propose an updated API that will hopefully make the API symmetric regarding how lists of primitive types and record types are handled. But we need to coordinate on the use cases (what we are doing) to ensure we get this "right" before more people are using it and we need to refactor larger sections of code. |
I am inclined to get rid of the record arrays. Lists of records can be used in place of record arrays. Let me propose a change regarding the creation and deletion of a record according to our discussion here.
|
@morrone Thank you for pointing out the API inconsistency for lists, records, and record arrays. |
Moving to v.4.5.1 |
The ldms.h API is missing an ldms_record_free() function to match up with the ldms_record_alloc() function. This would be very useful to sampler implementers to allow us to cease the use of a record instance if a problem is encountered during the process of filling in metric values in the record.
The text was updated successfully, but these errors were encountered: