Skip to content

Commit 958d6bb

Browse files
committed
Modify the key-index support
Utilize a pointer array instead of a hash table for faster retrieval. Let the key's index correspond to the index in the array. Append user-defined keys to the standard ones. Use that relative location to reduce the search space/time when retrieving an index from a key. Add some missing static initializers for internal structures. Signed-off-by: Ralph Castain <rhc@pmix.org>
1 parent ec77b2b commit 958d6bb

File tree

10 files changed

+159
-630
lines changed

10 files changed

+159
-630
lines changed

include/pmix_deprecated.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ PMIX_EXPORT pmix_status_t PMIx_tool_connect_to_server(pmix_proc_t *proc,
196196

197197
/* attributes for GDS */
198198
#define PMIX_GDS_MODULE "pmix.gds.mod" // (char*) ***** DEPRECATED ***** comma-delimited string of desired modules
199-
199+
#define PMIX_BFROPS_MODULE "pmix.bfrops.mod" // (char*) ***** INTERNAL ***** name of bfrops plugin in-use by a given nspace
200+
#define PMIX_PNET_SETUP_APP "pmix.pnet.setapp" // (pmix_byte_object_t) ***** INTERNAL ***** blob containing info to be given to pnet framework on remote nodes
200201

201202
#define PMIX_IOF_STOP "pmix.iof.stop" // (bool) ***** DEPRECATED ***** Stop forwarding the specified channel(s)
202203
#define PMIX_NOTIFY_LAUNCH "pmix.note.lnch" // (bool) ***** DEPRECATED ***** notify the requestor upon launch of the child job and return

src/class/pmix_hotel.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,20 @@ typedef struct pmix_hotel_t {
138138
} pmix_hotel_t;
139139
PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_hotel_t);
140140

141+
#define PMIX_HOTEL_STATIC_INIT \
142+
{ \
143+
.super = PMIX_OBJ_STATIC_INIT(pmix_object_t), \
144+
.num_rooms = 0, \
145+
.evbase = NULL, \
146+
.eviction_timeout = {0, 0}, \
147+
.evict_callback_fn = NULL, \
148+
.rooms = NULL, \
149+
.eviction_args = NULL, \
150+
.unoccupied_rooms = NULL, \
151+
.last_unoccupied_room = 0 \
152+
}
153+
154+
141155
/**
142156
* Initialize the hotel.
143157
*

src/common/pmix_attributes.c

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,6 @@ static void atrkdes(pmix_attribute_trk_t *p)
5959
}
6060
static PMIX_CLASS_INSTANCE(pmix_attribute_trk_t, pmix_list_item_t, atrkcon, atrkdes);
6161

62-
/* define a couple of internal attributes */
63-
static pmix_regattr_input_t internals[] = {
64-
{.index = PMIX_INDEX_BOUNDARY, .name = "PMIX_BFROPS_MODULE", .string = "pmix.bfrops.mod", .type = PMIX_STRING,
65-
.description = (char *[]){"name of bfrops plugin in-use by a given nspace", NULL}},
66-
67-
{.index = PMIX_INDEX_BOUNDARY+1, .name = "PMIX_PNET_SETUP_APP", .string = "pmix.pnet.setapp", .type = PMIX_BYTE_OBJECT,
68-
.description = (char *[]){"blob containing info to be given to pnet framework on remote nodes", NULL}},
69-
70-
{.index = UINT32_MAX, .name = "", .string = "", .type = PMIX_POINTER, .description = (char *[]){"NONE", NULL}}
71-
};
72-
7362
PMIX_EXPORT void pmix_init_registered_attrs(void)
7463
{
7564
size_t n;
@@ -92,16 +81,6 @@ PMIX_EXPORT void pmix_init_registered_attrs(void)
9281
p->description = pmix_argv_copy(dictionary[n].description);
9382
pmix_hash_register_key(p->index, p);
9483
}
95-
/* include the internals */
96-
for (n=0; UINT32_MAX != internals[n].index; n++) {
97-
p = (pmix_regattr_input_t*)pmix_malloc(sizeof(pmix_regattr_input_t));
98-
p->index = internals[n].index;
99-
p->name = strdup(internals[n].name);
100-
p->string = strdup(internals[n].string);
101-
p->type = internals[n].type;
102-
p->description = pmix_argv_copy(internals[n].description);
103-
pmix_hash_register_key(p->index, p);
104-
}
10584
initialized = true;
10685
}
10786
}
@@ -159,37 +138,12 @@ PMIX_EXPORT pmix_status_t PMIx_Register_attributes(char *function, char *attrs[]
159138

160139
PMIX_EXPORT void pmix_release_registered_attrs(void)
161140
{
162-
pmix_status_t rc;
163-
uint32_t id;
164-
pmix_regattr_input_t *ptr;
165-
char *node;
166-
167141
if (initialized) {
168142
PMIX_LIST_DESTRUCT(&client_attrs);
169143
PMIX_LIST_DESTRUCT(&server_attrs);
170144
PMIX_LIST_DESTRUCT(&host_attrs);
171145
PMIX_LIST_DESTRUCT(&tool_attrs);
172-
rc = pmix_hash_table_get_first_key_uint32(&pmix_globals.keyindex,
173-
&id, (void **) &ptr,
174-
(void **) &node);
175-
while (PMIX_SUCCESS == rc) {
176-
if (NULL != ptr->name) {
177-
free(ptr->name);
178-
ptr->name = NULL;
179-
}
180-
if (NULL != ptr->string) {
181-
free(ptr->string);
182-
ptr->string = NULL;
183-
}
184-
if (NULL != ptr->description) {
185-
pmix_argv_free(ptr->description);
186-
ptr->description = NULL;
187-
}
188-
rc = pmix_hash_table_get_next_key_uint32(&pmix_globals.keyindex, &id,
189-
(void **) &ptr, node,
190-
(void **) &node);
191-
}
192-
}
146+
}
193147
initialized = false;
194148
}
195149

src/event/pmix_event.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ typedef struct {
5656
size_t nprocs;
5757
} pmix_range_trkr_t;
5858

59+
#define PMIX_RANGE_TRKR_STATIC_INIT \
60+
{ \
61+
.range = PMIX_RANGE_UNDEF, \
62+
.procs = NULL, \
63+
.nprocs = 0 \
64+
}
65+
66+
5967
/* define a common struct for tracking event handlers */
6068
typedef struct {
6169
pmix_list_item_t super;
@@ -86,6 +94,23 @@ typedef struct {
8694
} pmix_event_hdlr_t;
8795
PMIX_CLASS_DECLARATION(pmix_event_hdlr_t);
8896

97+
#define PMIX_EVENT_HDLR_STATIC_INIT \
98+
{ \
99+
.super = PMIX_LIST_ITEM_STATIC_INIT, \
100+
.name = NULL, \
101+
.index = SIZE_MAX, \
102+
.precedence = UINT8_MAX, \
103+
.locator = NULL, \
104+
.source = PMIX_PROC_STATIC_INIT, \
105+
.rng = PMIX_RANGE_TRKR_STATIC_INIT, \
106+
.affected - NULL, \
107+
.naffected = 0, \
108+
.evhdlr = NULL, \
109+
.cbobject = NULL, \
110+
.codes = NULL, \
111+
.ncodes = 0 \
112+
}
113+
89114
/* define an object for tracking status codes we are actively
90115
* registered to receive */
91116
typedef struct {
@@ -110,6 +135,18 @@ typedef struct {
110135
} pmix_events_t;
111136
PMIX_CLASS_DECLARATION(pmix_events_t);
112137

138+
#define PMIX_EVENTS_STATIC_INIT \
139+
{ \
140+
.super = PMIX_OBJ_STATIC_INIT(pmix_object_t), \
141+
.nhdlrs = 0, \
142+
.first = NULL, \
143+
.last = NULL, \
144+
.actives = PMIX_LIST_STATIC_INIT, \
145+
.single_events = PMIX_LIST_STATIC_INIT, \
146+
.multi_events = PMIX_LIST_STATIC_INIT, \
147+
.default_events = PMIX_LIST_STATIC_INIT \
148+
}
149+
113150
/* define an object for chaining event notifications thru
114151
* the local state machine. Each registered event handler
115152
* that asked to be notified for a given code is given a

src/include/pmix_globals.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,23 @@ typedef struct {
247247
bool raw;
248248
} pmix_iof_flags_t;
249249

250+
#define PMIX_IOF_FLAGS_STATIC_INIT \
251+
{ \
252+
.set = false, \
253+
.xml = false, \
254+
.timestamp = false, \
255+
.tag = false, \
256+
.rank = false, \
257+
.file = NULL, \
258+
.directory = NULL, \
259+
.nocopy = false, \
260+
.merge = false, \
261+
.local_output = false, \
262+
.local_output_given = false, \
263+
.pattern = false, \
264+
.raw = false \
265+
}
266+
250267
/* objects used by servers for tracking active nspaces */
251268
typedef struct {
252269
pmix_list_item_t super;
@@ -665,7 +682,8 @@ typedef struct {
665682
bool external_topology;
666683
bool external_progress;
667684
pmix_iof_flags_t iof_flags;
668-
pmix_hash_table_t keyindex; // translation table of key <-> index
685+
pmix_pointer_array_t keyindex; // translation table of key <-> index
686+
uint32_t next_keyid;
669687
} pmix_globals_t;
670688

671689
/* provide access to a function to cleanup epilogs */

src/runtime/pmix_finalize.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ void pmix_rte_finalize(void)
6060
int i;
6161
pmix_notify_caddy_t *cd;
6262
pmix_iof_req_t *req;
63+
pmix_regattr_input_t *p;
6364

6465
if (--pmix_initialized != 0) {
6566
if (pmix_initialized < 0) {
@@ -143,6 +144,21 @@ void pmix_rte_finalize(void)
143144
pmix_globals.hostname = NULL;
144145
}
145146
PMIX_LIST_DESTRUCT(&pmix_globals.nspaces);
147+
for (i=0; i < pmix_globals.keyindex.size; i++) {
148+
p = (pmix_regattr_input_t*)pmix_pointer_array_get_item(&pmix_globals.keyindex, i);
149+
if (NULL != p) {
150+
if (NULL != p->name) {
151+
free(p->name);
152+
}
153+
if (NULL != p->string) {
154+
free(p->string);
155+
}
156+
if (NULL != p->description) {
157+
pmix_argv_free(p->description);
158+
}
159+
free(p);
160+
}
161+
}
146162
PMIX_DESTRUCT(&pmix_globals.keyindex);
147163

148164
/* now safe to release the event base */

src/runtime/pmix_init.c

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include "src/client/pmix_client_ops.h"
5858
#include "src/common/pmix_attributes.h"
5959
#include "src/event/pmix_event.h"
60+
#include "src/include/dictionary.h"
6061
#include "src/include/pmix_types.h"
6162
#include "src/util/pmix_error.h"
6263
#include "src/util/pmix_keyval_parse.h"
@@ -74,26 +75,45 @@ const char* pmix_tool_msg = PMIX_PROXY_BUGREPORT_STRING;
7475
PMIX_EXPORT int pmix_initialized = 0;
7576
PMIX_EXPORT bool pmix_init_called = false;
7677
/* we have to export the pmix_globals object so
77-
* all plugins can access it. However, it is included
78-
* in the pmix_rename.h file for external protection.
79-
* Initialize only those entries that are not covered
80-
* by MCA params or are complex structures initialized
81-
* below */
78+
* all plugins can access it. */
8279
PMIX_EXPORT pmix_globals_t pmix_globals = {
8380
.init_cntr = 0,
81+
.myid = PMIX_PROC_STATIC_INIT,
82+
.myidval = PMIX_VALUE_STATIC_INIT,
83+
.myrankval = PMIX_VALUE_STATIC_INIT,
8484
.mypeer = NULL,
85+
.uid = 0,
86+
.gid = 0,
8587
.hostname = NULL,
88+
.appnum = 0,
89+
.pid = 0,
8690
.nodeid = UINT32_MAX,
8791
.pindex = 0,
8892
.evbase = NULL,
8993
.debug_output = -1,
94+
.events = PMIX_EVENTS_STATIC_INIT,
9095
.connected = false,
9196
.commits_pending = false,
97+
.event_window = {0, 0},
98+
.cached_events = PMIX_LIST_STATIC_INIT,
99+
.iof_requests = PMIX_POINTER_ARRAY_STATIC_INIT,
100+
.max_events = INT_MAX,
101+
.event_eviction_time = 0,
102+
.notifications = PMIX_HOTEL_STATIC_INIT,
92103
.pushstdin = false,
104+
.stdin_targets = PMIX_LIST_STATIC_INIT,
105+
.tag_output = false,
106+
.xml_output = false,
107+
.timestamp_output = false,
108+
.output_limit = SIZE_MAX,
109+
.nspaces = PMIX_LIST_STATIC_INIT,
93110
.topology = {NULL, NULL},
94111
.cpuset = {NULL, NULL},
95112
.external_topology = false,
96-
.external_progress = false
113+
.external_progress = false,
114+
.iof_flags = PMIX_IOF_FLAGS_STATIC_INIT,
115+
.keyindex = PMIX_POINTER_ARRAY_STATIC_INIT,
116+
.next_keyid = PMIX_INDEX_BOUNDARY
97117
};
98118

99119
static void _notification_eviction_cbfunc(struct pmix_hotel_t *hotel, int room_num, void *occupant)
@@ -292,8 +312,8 @@ int pmix_rte_init(uint32_t type, pmix_info_t info[], size_t ninfo, pmix_ptl_cbfu
292312
pmix_hotel_init(&pmix_globals.notifications, pmix_globals.max_events, pmix_globals.evbase,
293313
pmix_globals.event_eviction_time, _notification_eviction_cbfunc);
294314
PMIX_CONSTRUCT(&pmix_globals.nspaces, pmix_list_t);
295-
PMIX_CONSTRUCT(&pmix_globals.keyindex, pmix_hash_table_t);
296-
pmix_hash_table_init(&pmix_globals.keyindex, 1024);
315+
PMIX_CONSTRUCT(&pmix_globals.keyindex, pmix_pointer_array_t);
316+
pmix_pointer_array_init(&pmix_globals.keyindex, 1024, INT_MAX, 128);
297317

298318
/* and setup the iof request tracking list */
299319
PMIX_CONSTRUCT(&pmix_globals.iof_requests, pmix_pointer_array_t);

src/server/pmix_server_ops.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ static pmix_status_t _collect_data(pmix_server_trkr_t *trk, pmix_buffer_t *buf)
659659
pmix_value_array_init(key_count_array, sizeof(uint32_t));
660660

661661
PMIX_LIST_FOREACH (scd, &trk->local_cbs, pmix_server_caddy_t) {
662-
pmix_strncpy(pcs.nspace, scd->peer->info->pname.nspace, PMIX_MAX_NSLEN);
662+
pmix_strncpy(pcs.nspace, scd->peer->info->pname.nspace, PMIX_MAX_NSLEN);
663663
pcs.rank = scd->peer->info->pname.rank;
664664
PMIX_CONSTRUCT(&cb, pmix_cb_t);
665665
cb.proc = &pcs;
@@ -4067,9 +4067,7 @@ pmix_status_t pmix_server_grpconstruct(pmix_server_caddy_t *cd, pmix_buffer_t *b
40674067
goto error;
40684068
}
40694069
}
4070-
/* see if we are to enforce a timeout or if they want
4071-
* a context ID created - we don't internally care
4072-
* about any other directives */
4070+
/* check directives */
40734071
for (n = 0; n < ninfo; n++) {
40744072
if (PMIX_CHECK_KEY(&info[n], PMIX_TIMEOUT)) {
40754073
tv.tv_sec = info[n].value.data.uint32;

0 commit comments

Comments
 (0)