Optimize CSV monitor output for 2x runtime#412
Conversation
PhilipFackler
left a comment
There was a problem hiding this comment.
This approach is great! Nice results. Thanks for spending time on this. Looks like I trusted the std::ostream buffer too much. 😸
I would like you to revert the structure a bit, though.
I think you should use this approach for all of the formats. No need to have extra custom CSV functions and separate bits in the ValuePrinter. Use the string buffer in the controller (call it something generic like buffer_ instead of csv_line_) and change the print* functions internally to use the interface you've made here for appendCsv. You could change them to append also, to make it clearer (don't need two different implementations for the same thing). You shouldn't have to bother much with the implementations for the other formats (just switch to using stringstream).
In other words, just replace my implementation with yours everywhere. 😆
How does that sit with you?
|
Also, shouldn't this be aimed at |
I can change the target branch, I only kept it like this because I measured it against my other branch, not this one! I will shift target so it's async with the other PR. Good on unifying across the three formats, I just don't know much about yaml. Otherwise as long as you and @pelesh are okay with this, I can certainly extend this to the other formats and make api clearer. Thank you for the feedback! |
They all use |
|
@PhilipFackler I reworked this along the lines you suggested, so they all now use the same buffer. And added a consistency test. Thank you! |
|
@lukelowry it looks like this PR now includes changes from #411. This will need to be fixed. I think this PR should touch only the |
I think I messed up a rebase. I'll fix shortly, because I agree. |
b9c4069 to
b71d5fa
Compare
|
@PhilipFackler fixed, thank you. This speeds up tests a lot too |
|
cc @nkoukpaizan incase slaven is busy |
b71d5fa to
02c0e9b
Compare
02c0e9b to
f1c348d
Compare
|
I am getting following linker error: @lukelowry, can you reproduce it at your end? |
|
@pelesh thanks for catching this. It links on my Linux build, so I missed it. Bus inherits getMonitor() from BusBase, but we only explicitly instantiated Bus, not BusBase. The new test exposed that missing BusBase<double, size_t>::getMonitor() symbol on macOS/arm64. I fixed it by explicitly instantiating BusBase next to the existing Bus instantiations. I also removed the consistency test since it was only checking two wrappers over the same append path. Could you pull the update and confirm the arm64 build now links? |
|
This still adds more complexity to the code than necessary. @lukelowry I'll send you a patch on slack that you can work with to integrate. I also sent via email. Let me know if you received it. |
Patches applied! |
PhilipFackler
left a comment
There was a problem hiding this comment.
Looks good. Great job!
Description
This stacked PR optimizes CSV monitor output in PhasorDynamics by formatting CSV values directly into a reusable line buffer in the hot monitor path. It is stacked on #411 (
lukel/perf-sys-dev).Proposed changes
VariableMonitorBasewith existing stream-print fallbacks.std::to_charsfor floating-point output.VariableMonitorControllerand write each CSV row once.Performance was measured with
application/PhasorDynamics/PDSimusing the app-reportedComplete intime. Each row reports the median of 3 trials after rebuildingPDSimon the corresponding branch.lukel/perf-sys-dev(s)Checklist
-Wall -Wpedantic -Wconversion -Wextra.Further comments
stoked