-
Notifications
You must be signed in to change notification settings - Fork 9
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
Explore using JSON for LB stats files for a more consistent, readable format #1469
Comments
Proposal for format: {
"phases": [
{
"phase": [
{
"id": 1,
"tasks": [
{
"resource": "cpu",
"node": 10,
"object": 1993438,
"time": 5.34
},
{
"resource": "cpu",
"node": 10,
"object": 283883,
"time": 3.4,
"suphases": [
{
"id": 1,
"time": 1.4
},
{
"id": 2,
"time": 2.0
}
]
}
]
}
]
}
]
} |
If there won't be anything except phases, then it could be a simple array, which still is valid JSON. [
{
"phase": [
{
"id": 1,
"tasks": [
{
"resource": "cpu",
"node": 10,
"object": 1993438,
"time": 5.34
},
{
"resource": "cpu",
"node": 10,
"object": 283883,
"time": 3.4,
"suphases": [
{
"id": 1,
"time": 1.4
},
{
"id": 2,
"time": 2.0
}
]
}
]
}
]
}
] |
One question, why is |
Because there will be multiple phases. I just have phase |
Oh, I see what you mean. I misunderstood. I think you are right on this. |
OK, so than that would be sufficient I guess: [
{
"phase": {
"id": 1,
"tasks": [
{
"resource": "cpu",
"node": 10,
"object": 1993438,
"time": 5.34
},
{
"resource": "cpu",
"node": 10,
"object": 283883,
"time": 3.4,
"suphases": [
{
"id": 1,
"time": 1.4
},
{
"id": 2,
"time": 2.0
}
]
}
]
}
},
...
] |
On second thought, maybe like this: {
"phases": [
{
"id": 1,
"tasks": [
{
"resource": "cpu",
"node": 10,
"object": 1993438,
"time": 5.34
},
{
"resource": "cpu",
"node": 10,
"object": 283883,
"time": 3.4,
"subphases": [
{
"id": 1,
"time": 1.4
},
{
"id": 2,
"time": 2.0
}
]
}
]
},
{
"id": 2,
"tasks": [
{
"resource": "cpu",
"node": 10,
"object": 1993438,
"time": 5.34
},
{
"resource": "cpu",
"node": 10,
"object": 283883,
"time": 3.4,
"subphases": [
{
"id": 1,
"time": 1.4
},
{
"id": 2,
"time": 2.0
}
]
}
]
}
]
}
that way |
Are we including |
If we do include |
That's exactly why I included it. So we could combine the files and it would be correct. I'm still intending to have one file per rank because that will be most efficient to output I think. But this would allow us to easily combine them and know which rank they came from without relying on the filename to know. |
So the optional meta-data file would look like this: {
"subphases": [
{
"id": 1,
"name": "mySubphaseName1"
},
{
"id": 2,
"name": "mySubphaseName2"
},
]
} |
So the issue with the specification is that if we incrementally output, we can't create an array for {
"phases": [
null,
null,
null,
null,
null,
null,
null,
{
"tasks": [
{
"time": 1.6927719116210938e-05,
"subphases": [
{
"time": 1.6927719116210938e-05,
"id": 0
}
],
"resource": "cpu",
"object": 107374182400,
"node": 0
},
{
"time": 0.012003183364868164,
"subphases": [
{
"time": 0.012003183364868164,
"id": 0
}
],
"resource": "cpu",
"object": 25769803776,
"node": 0
},
{
"time": 0.011924028396606445,
"subphases": [
{
"time": 0.011924028396606445,
"id": 0
}
],
"resource": "cpu",
"object": 0,
"node": 0
}
],
"id": 7
}
]
} But the code to output this is easy to write: using json = nlohmann::json;
json j;
j["phases"] = {};
j["phases"][phase]["id"] = phase;
std::size_t i = 0;
for (auto&& elm : node_data_.at(phase)) {
ElementIDStruct id = elm.first;
TimeType time = elm.second;
j["phases"][phase]["tasks"][i]["resource"] = "cpu";
j["phases"][phase]["tasks"][i]["node"] = theContext()->getNode();
j["phases"][phase]["tasks"][i]["object"] = id.id;
j["phases"][phase]["tasks"][i]["time"] = time;
auto const& subphase_times = node_subphase_data_.at(phase)[id];
std::size_t const subphases = subphase_times.size();
if (subphases != 0) {
for (std::size_t s = 0; s < subphases; s++) {
j["phases"][phase]["tasks"][i]["subphases"][s]["id"] = s;
j["phases"][phase]["tasks"][i]["subphases"][s]["time"] = subphase_times[s];
}
}
i++;
}
fmt::print("j={}\n", to_string(j)); |
So I think we need to not output an array for |
Actually, now I read more, I think to do this "correctly" we have to read all the json in, add what we want, and then write it out again. So we will need some work-around for the incremental output. |
Given that limitation, is JSON really the right format to use? |
What Needs to be Done?
Choose a new format for the LB stats file.
The text was updated successfully, but these errors were encountered: