-
Notifications
You must be signed in to change notification settings - Fork 8
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
add configuration call #82
Conversation
Looks good. Thanks, @rhaas80 |
I feel that making the user pass a kvtree to Why not use simple config strings ( /* only accept configuration options once */
configured = 1; Also, please add a description to your PR and all your commits, and please document what the config values are and what they do. |
SCR does offer a string based configuration interface to allow for easy passing of user option. I saw the VeloC libraries as lower level building blocks that will be called from a higher level library that will to the option handling. All user codes already depend (implicitly) on kvtree since AXL does. Having that library then construct a string to pass options seems error prone since it looses any hope of type checking (not that the fact that kvtree currently stores only strings helps there). Having said all of this: duplicating the string parsing code from SCR in each VeloC component is certainly easy enough if that is desired. Right now the check is in place to reduce the chance of setting parameters, which AXL currently can assume to be constant during a run, to change in the middle of a run (at least to the amount that this is possible given that the config calls happen after |
Please let me know what the preferred option is and i will be happy to implement it. |
Yes, documentation of these options in the user docs is indeed required. Thanks for pointing that out. In the code right now the various |
I think we should develop AXL under the assumption that it's a standalone library that anyone could use, rather than just assuming that FILO and VeloC would use it. I could see UnifyFS using it for file stage-in, for example.
What I mean is that this PR would require users to
AXL would know the value type in a key=value string, so it would be able to sanity check it. Like it would check that
You wouldn't need to construct a giant string. You could set one or more values per AXL_Config(id, "debug=1");
AXL_Config(id, "file_buf_size=65536 mkdir=1") or this: AXL_Config(id, "debug=1");
AXL_Config(id, "file_buf_size=65536");
AXL_Config(id, "mkdir=1"); or this: AXL_Config(id, "debug=1 file_buf_size=65536 mkdir=1") Or any other combination you want. The result would be the same. A string-based config is also nice because it reduces the amount of boilerplate code you have to write (which also makes the code easier to read). For example, you could reduce your #include <kvtree.h>
...
kvtree* axl_config_values = kvtree_new();
...
/* check AXL configuration settings */
rc = kvtree_util_set_bytecount(axl_config_values,
AXL_KEY_CONFIG_FILE_BUF_SIZE,
old_axl_file_buf_size + 1);
if (rc != KVTREE_SUCCESS) {
printf("kvtree_util_set_bytecount failed (error %d)\n", rc);
return rc;
}
rc = kvtree_util_set_int(axl_config_values, AXL_KEY_CONFIG_DEBUG,
!old_axl_debug);
if (rc != KVTREE_SUCCESS) {
printf("kvtree_util_set_int failed (error %d)\n", rc);
return rc;
}
rc = kvtree_util_set_int(axl_config_values, AXL_KEY_CONFIG_MKDIR,
!old_axl_make_directories);
if (rc != KVTREE_SUCCESS) {
printf("kvtree_util_set_int failed (error %d)\n", rc);
return rc;
}
rc = kvtree_util_set_int(axl_config_values, AXL_KEY_CONFIG_COPY_METADATA,
!old_axl_copy_metadata);
if (rc != KVTREE_SUCCESS) {
printf("kvtree_util_set_int failed (error %d)\n", rc);
return rc;
}
rc = AXL_Config(axl_config_values);
...
kvtree_delete(&axl_config_values); To: char *config;
asprintf(&config, "file_buf_size=%d debug=%d mkdir=%d copy_metadata=%d",
old_axl_file_buf_size + 1, !old_axl_debug, !old_axl_make_directories, !old_axl_copy_metadata);
AXL_Config(config); I would also propose that
int id = 42;
AXL_Config(id, "file_buf_size=65535");
AXL_Config(-1, "debug=1");
AXL_Config("id=42 file_buf_size=65535");
AXL_Config("debug=1"); And to retrieve: char *str = AXL_Config("debug");
printf("debug=%s", str); // prints "debug=1"
char *str = AXL_Config("id=42 file_buf_size");
printf("file_buf_size=%s", str); // prints "file_buf_size=65535" |
Uff that was a lengthy comment. I guess I will have to redo my implementation.
From my point of view (as a science code developer) UnifyFS would still be a layer between AXL and "me" and would (and should do so I would think) hide the fact that it internally uses AXL and translate its own options into whatever AXL expects.
Right now one already has to link against kvtree since AXL links against it. One has to explicitly do so since the current CMake file for AXL is not reporting AXL's own dependent libraries as libraries one needs to link against (at least not that I can see and in a similar situation in er with rankstr I certainly had to manually add it). On a sufficiently old system with dynamic linking the linker will automatically link in the dynamic librraries that libAXL.so uses when one links against libAXL.so but for static linking and newer linkers (that default to not setting
Let me be more explicit: passing strings pushes type checks to runtime, while using
If I look at the discussion in #38 (eg #38 (comment)) then this does not seem to be (sanely) possible since constructs like "CKPT=0 SCHEME=XOR" are not expected to set both
I don't know. This is lacking a
which is still quite a bit shorter since it combines multiple
sure. I will implement a demo setup and let you have a look. |
Thanks for the info. Since we decided to go with the kvtree-approach in today's meeting, you can ignore my previous comments, and we should probably update #38 to say we're using a KVTree. As far as per-AXL ID vs global values go, may I suggest we mix both globals and ID specific values in one tree, with the ID specific ones in a subtree, like: // psudocode: set global debug and some ID specific values
kvtree config = {
debug = 1
kvtree {
id = 42
file_buf_size = 65536
}
kvtree {
id = 43
file_buf_size = 2097152
compression = 1
}
}
AXL_Config(config) I think there's even a way you could index the subtree by And for reading config values back, its probably easiest to have a way to return all the config values (global and ID-specific), and not worry about querying individual ones. You could extend /*
* Get/set AXL configuration values.
*
* config: The new configuration. Global variables are in top level of
* the tree, and per-ID values are subtrees. If config=NULL,
* then return a kvtree with all the configuration values (globals
* and all per-ID trees).
*
* Return value: If config != NULL, then return config on success. If
* config=NULL (you're querying the config) then return
* a new kvtree on success. Return NULL on any failures.
*/
kvtree * AXL_Config(kvtree *config) For example: kvtree *old_config;
old_config = AXL_Config(NULL);
if (!old_config)
printf("error\n");
// read back our config values into old_config In fact, you could have return not only the config values, but all kvtree values for a particular ID too (like AXL_KEY_STATUS, AXL_KEY_STATE, ... etc). |
Keeping track of things, @tonyhutter pointed out #82 (comment) with the choice of what to return for setting (the input config) and getting (a full tree of all settings). |
src/axl.c
Outdated
if (kvtree_util_get_bytecount(config, | ||
AXL_KEY_CONFIG_FILE_BUF_SIZE, &ul) == KVTREE_SUCCESS) | ||
{ | ||
axl_file_buf_size = (int) ul; |
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.
axl_file_buf_size
is a size_t
(which most likely is an unsigned long
on 64-bit), so you can remove the check against the int
. Or if you're being super-safe, check ul
against SIZE_MAX
.
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.
sorry, I had left the fix in rhaas/keyvalue_get. Cherry picked into rhaas/keyvalue. I'd rather not make assumptions about what size_t
is wrt to unsigned long
. The smallest type to be guaranteed by C to be 64bit is long long int
with long
being allowed to be 32bit.
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.
Then I would just make axl_file_buf_size
an unsigned long
and remove the check.
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.
I was reluctant to change types of existing variables given that I do now know here they are used. If you think this is safe, fine with me for sure (makes for easier code). Note that right now kvtree_util_get_bytecount
and scr_abtoull
which SCR (the original code) uses to convert byte count strings to integer variables are inconsistent. The former using unsigned long
(which is only guaranteed to be 32bit and is indeed so even on 64bit windows machines) while the latter uses unsigned long long
(which is the smallest type guaranteed to be able to hold a 64bit number). So unless those two are changed there will still be a need of checks (though it could / should actually go into kvtree_util_get_bytecount
making kvtree
's user code much simpler).
Please check that all indents are four spaces, and also add per-ID config options. |
Please also squash your commits |
f73513c
to
ae4e148
Compare
src/axl.c
Outdated
@@ -309,6 +310,92 @@ int AXL_Finalize (void) | |||
return rc; | |||
} | |||
|
|||
|
|||
/** Set a AXL config parameters */ | |||
kvtree* AXL_Config(const int id, const kvtree* config) |
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.
I would get rid of the id
arg, and make the per-ID values subtrees within the main tree. For example:
kvtree *tree;
kvtree *id;
tree = kvtree_new();
/* Add some config for AXL ID 1 */
id = kvtree_set_kv_int(tree, "id", 1);
kvtree_set_kv_int(id, "compression", 1);
kvtree_set_kv_int(id, "file_buf_size", 65536);
/* Add some config for AXL ID 42 */
id = kvtree_set_kv_int(tree, "id", 42);
kvtree_set_kv_int(id, "file_buf_size", 1048576);
printf("Whole tree ---\n");
kvtree_print(tree, 4);
/* Lookup an id 1's values */
id = kvtree_get_kv_int(tree, "id", 1);
printf("Just ID 1 ---\n");
kvtree_print(id, 4);
Whole tree ---
id
42
file_buf_size
1048576
1
file_buf_size
65536
compression
1
Just ID 1 ---
file_buf_size
65536
compression
1
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.
Uh, I have a not quite pull request (but a branch) that actually implements per transfer options. No thread locking yet. The diff can be seen here:
rhaas80/AXL@rhaas/keyvalue_get...rhaas80:rhaas/per_transfer
and the branch itself is
https://github.com/rhaas80/AXL/tree/rhaas/per_transfer
and the second last commit (rhaas80@b6a1700) is the one that goes from id
being an argument to encoding it in the kvtree. I am not sure I like that solution, but it is certainly doable and the commit nicely shows the differences this implies to taking an int id
argument in AXL_Config
.
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.
in call on 2020-10-07:
- go with
kvtree
only argument test - combine all 3 pull requests for
set
,get
andper_transfer
into single pull request - might keep commits separate
9647abd
to
37ea86a
Compare
Double check that your indents are all four spaces. |
Will do. I believe i asked this before: is there an actual document (or even better, a clang format file and an offical clang version to use) for the desired coding style? Right now SCR uses 2 spaces, AXL spaces 4 and there may well be subtle other differences. |
Yea, the inconsistency is annoying, and no, there's no style docs. We've talked a little about enforcing style in Travis: |
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.
Looks good!
Based on the discussion in today's call I verified that with AXL at rhaas/keyvalue (ie this pull request) and all other VeloC components on master and SCR on develop, no more tests fail on my workstation than with AXL on master (some tests fail due to they assuming SLURM and / or multiple nodes). |
d5a21cb
to
e9e3fb4
Compare
No description provided.