[PATCH 0/2] improve code portability
Bruce Richardson
bruce.richardson at intel.com
Mon Apr 3 19:04:08 CEST 2023
On Mon, Apr 03, 2023 at 09:30:22AM -0700, Tyler Retzlaff wrote:
> Improve portability of telemetry code to allow it to be compiled by msvc
> unconditionally.
>
> Remove use of VLA and instead dynamically allocate. MSVC will never
> implement VLAs due to misuse / security concerns.
>
> Remove use of ranged based initializer (a gcc extension) instead just
> explicitly initialize individual array elements.
>
> Tyler Retzlaff (2):
> telemetry: use malloc instead of variable length array
> telemetry: use portable syntax to initialize array
>
Is this worth doing, given that DPDK telemetry uses a unix domain socket
for it's connectivity, which would not be available on windows anyway?
I don't particularly like these patches as:
* The removal of the VLAs means we will potentially be doing a *lot* of
malloc and free calls inside the telemetry code. It may not be a data
path or particularly performance critical, but I know for things like CPU
busyness, users may want to call telemetry functions hundreds (or
potentially thousands) of times a second. It also makes the code slightly
harder to read, and introduces the possibility of us having memory leaks.
* The second patch just makes the code uglier. True, it's non-standard, but
it really does make the code a whole lot more readable and managable. If
we need to make this standards-conforming, then I think we need to drop
the "const", and do runtime init of this array with loops for the ranges.
All that said, if we do have a path to get telemetry working on windows, I
think we can work together to get a suitable patchset in for it.
/Bruce
More information about the dev
mailing list