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

kvs: remove internal treq api #6604

Merged
merged 8 commits into from
Feb 7, 2025
Merged

Conversation

chu11
Copy link
Member

@chu11 chu11 commented Feb 4, 2025

effectively "squash" the treq api into the kvsroot API since there was almost nothing left in the treq api. Removing a whole sub-library within the kvs. woot!

@chu11 chu11 changed the title kvs: remove treq api kvs: remove internal treq api Feb 4, 2025
@chu11 chu11 force-pushed the kvs_refactor2 branch 7 times, most recently from cbee6fe to a1cdb05 Compare February 6, 2025 08:55
Copy link
Member

@garlick garlick left a comment

Choose a reason for hiding this comment

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

LGTM!

Just a couple of questions inline for your consideration - nothing that should hold this up necessarily.

Comment on lines 1785 to 1786
if (asprintf (&name, "transaction_req.%u.%u", ctx->rank, ctx->seq++) < 0)
goto error;
Copy link
Member

Choose a reason for hiding this comment

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

Seems like maybe name could be a small static buffer and this malloc could be avoided?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh that's a good idea, since we aren't allocating a treq_t anymore we don't have to allocate it .

Comment on lines 269 to 270
if (asprintf (&name, "transaction_req.%u.%u", rank, seq) < 0)
goto error;
Copy link
Member

Choose a reason for hiding this comment

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

static buffer?

Comment on lines 278 to 272
if (zhash_insert (root->transaction_requests,
name,
(void *)flux_msg_incref (request)) < 0) {
errno = EEXIST;
goto error;
}
Copy link
Member

Choose a reason for hiding this comment

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

Just wondering if this is the best container? I think we decided of the hashes, zhashx had more sane growth management than zhash. I guess if the number of messages stored in the hash is always small that may not come into it.

Would a flux_msglist_t possibly be a better fit or is the lookup by name important?

Sorry I'm not entirely remembering how this code works so I'm just asking the question.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking of that. But left it as a zhash just because that was what was there before. Could think of that for some potential cleanup / improvement.

I had contemplated a zlist b/c now that we only support commits, the "transactions" should reasonably be done in order. So name matching should always occur with the first entry. But not sure if that's worth it vs a hash since we would want to double check and match names anyways.

@chu11 chu11 mentioned this pull request Feb 7, 2025
chu11 added 8 commits February 7, 2025 09:45
Problem: "future" is typoed as "futre" in several places.
"content" was typoed as "confent" in one place.

Fix the typos.
Problem: Several kvsroot convenience functions do not have invalid
input tests.

Add tests to kvs/test/kvsroot.c to ensure invalid inputs to
kvsroot_setroot() and kvsroot_check_user() are checked.
Problem: In a kvsroot_check_user() test, the cred is not initialized
before it is first used.

Initialize it to avoid a warning.
Problem: In the function finalize_transaction_req() a parameter is
passed in that is never used.

Remove the unused parameter.
Problem: The flags stored in a transaction request are never used/accessed.

Remove the flags parameter to treq_create().  Remove the function treq_get_flags().

Remove unit tests.

Update callers accordingly.
Problem: The treq_t convenience type for storing a transaction request
is now a struct of just two values: a message request and a name created
for that request.  Having a unique struct and an API for it is now excessive.

Solution: Remove the treq_t type and API for its creation and
access of internal variables.  Remove all related unit tests.

Change the treq_mgr_add_transaction() function take the message request and
a name.  Have treq_mgr_lookup_transaction() return a flux_msg_t now.

Update tests and users accordingly.
Problem: The treq_mgr_t struct is now just a zhash.  So there's no need
to use it and the treq-mgr api vs a zhash directly.

Convert kvsroot to use a zhash instead of a treq manager.  Add convenience
function kvsroot_save_transaction_request() with unit tests.  Update all callers
that previously used treq mgr functions to directly use zhash functions
instead.
Problem: The treq API is no longer used.

Remove it and related unit tests.
@chu11
Copy link
Member Author

chu11 commented Feb 7, 2025

re-pushed with the static buffer fix recommended above. It ends up I did have a rebase mistake in my commit history which I also fixed. I'll set MWP

@mergify mergify bot merged commit 74bb8ae into flux-framework:master Feb 7, 2025
34 of 35 checks passed
Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 71.42857% with 8 lines in your changes missing coverage. Please review.

Project coverage is 79.50%. Comparing base (d9cde83) to head (77adbaf).
Report is 9 commits behind head on master.

Files with missing lines Patch % Lines
src/modules/kvs/kvsroot.c 60.00% 6 Missing ⚠️
src/modules/kvs/kvs.c 84.61% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6604   +/-   ##
=======================================
  Coverage   79.50%   79.50%           
=======================================
  Files         531      530    -1     
  Lines       88363    88300   -63     
=======================================
- Hits        70251    70207   -44     
+ Misses      18112    18093   -19     
Files with missing lines Coverage Δ
src/modules/kvs/kvs.c 73.18% <84.61%> (+0.38%) ⬆️
src/modules/kvs/kvsroot.c 63.75% <60.00%> (-0.74%) ⬇️

... and 5 files with indirect coverage changes

@chu11 chu11 deleted the kvs_refactor2 branch February 7, 2025 21:02
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.

2 participants