Repository navigation
Example showing how to use 1DS C API shared lib in .NETcore 3.x app - #231
Max Golovanov (maxgolov) wants to merge 21 commits into
Conversation
|
Usage instructions for building shared library instead of static: To build shared library: or - new way of passing options from script to cmake: |
…metry into maxgolov/shared_library
…t/cpp_client_telemetry into maxgolov/shared_library
|
bemartin - I refreshed my old sample to work with latest SDK. Basically this is yet another I tested on my "average" laptop, and I measure about 45-50K events per second, for an average event with a few fields. This is comparable to what we had in native code a few years ago, so from overall perf perspective - very minor penalty. Even if a process logs thousands events per second, it's all relatively cheap. It'd be fun to measure this vs. Xamarin on top of iOS/Java projections, but as we discussed - for mobile apps we do not have super-high perf requirements anyways... I was just thinking that if performance ever becomes an issue, we can incrementally build a full-fledged compatible C# API around this C API approach. |
|
I'm closing this stale PR due to BFG repo cleanup. Please reopen it when ready. |
C# projection layer - #4
List of changes:
Practical reasons for this implementation:
Reason 1. New ways to express an event for Geneva IFx SDK without using Bond. Main intent is to move IFx customers away from Bond in their code to 1DS-style EventProperties.
A concept of strongly-typed variant dictionary that can be used to express an event in a very user-friendly, intuitive manner. This is C# code that is pretty much identical to API surface we have in C++11 land and other 1DS SDKs:
This managed object is implemented as "variant dictionary":
where EventProperty - allows to contain the standard supported by collector strong types, plus optional Pii Kind tag. That managed container object then gets converted to native structure passed down to 1DS C++ SDK via "ABI stable" C API. The marshaling is not ideal at the moment. I believe we can make it x2 times faster by avoiding memcpy in a few spots.
Reason 2. Prove that it's a viable approach from performance standpoint that can be used in system services written in C#.
Benchmarking how fast we can go -- measuring combined time of the following steps:
Preliminary results of early implementation:
Reason 3. We can do the rest of "incremental" work to provide a compat layer for Aria C# Server customers on top of our 1DS C++ SDK.
We can also deprecate our C++/CX and C++/CLI projection layers. Those two other technologies to generate Windows C# wrapper are "legacy" and "deprecated", we should switch to netcore P/Invoke instead.
Reason 4. I wanted to learn more about data marshaling from managed to native via P/Invoke 😄(out of curiosity ... to learn something new)
Perf numbers for a quick test to emit 100000 events in ONE thread in a loop (not multi-threaded, just 1 core, 1 background disk flush thread):