Repository navigation
C workload bindings - #11288
C workload bindings#11288
Conversation
d6a8fa4 to
857e629
Compare
ed2ca03 to
e71c078
Compare
e71c078 to
e4ac7a9
Compare
|
The simulation framework we integrated into foundationdb-rs has proven valuable, catching numerous bugs in our database layers. However, we’re still dependent on the ClientWorkload.h C++ bindings, which aren’t FFI-safe. Would you be open to reviewing this PR or perhaps discussing any alternative approaches? I’d be glad to adapt the implementation if there’s a better way forward. |
Signed-off-by: Eloi DEMOLIS <[email protected]>
Signed-off-by: Eloi DEMOLIS <[email protected]>
e4ac7a9 to
bb7d4a2
Compare
Result of foundationdb-pr-clang-ide on Linux CentOS 7
|
Result of foundationdb-pr on Linux CentOS 7
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-cluster-tests on Linux CentOS 7
|
Result of foundationdb-pr-clang on Linux CentOS 7
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Signed-off-by: Eloi DEMOLIS <[email protected]>
Result of foundationdb-pr-clang-ide on Linux CentOS 7
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-cluster-tests on Linux CentOS 7
|
Result of foundationdb-pr-clang on Linux CentOS 7
|
Result of foundationdb-pr on Linux CentOS 7
|
|
I don't understand why |
We run 10K simulation tests for every PR. One test was failing but it was not related to your change. Compilation was fine last time.
I just reviewed your recent changes and I agree with you. In my opinion, it's more trouble for what it's worth. |
bf4148c to
c03354a
Compare
Signed-off-by: Eloi DEMOLIS <[email protected]>
c03354a to
6058962
Compare
|
I reverted the last commit to return to the "object-oriented" design which doesn't require the fdbserver binary to expose any symbol: the function pointers are explicitly passed as arguments in structs as needed instead. Other than that, I don't see any other modifications to make. |
@Wonshtrum Great, thanks. Let me do a final review today and hopefully this PR is good to go. Once accepted, I will merge your PR to the main branch, and in that process, also squash all commits into one, so you don't have to do it now. |
Result of foundationdb-pr-clang-ide on Linux CentOS 7
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-cluster-tests on Linux CentOS 7
|
Result of foundationdb-pr-clang on Linux CentOS 7
|
Result of foundationdb-pr on Linux CentOS 7
|
| if (!workloadImpl) { | ||
| TraceEvent(SevError, "WorkloadNotFound").log(); | ||
| success = false; | ||
| return; |
There was a problem hiding this comment.
I noticed this return was not in the existing code, but looks like existing code had a bug which would cause a crash. Thanks for fixing.
There was a problem hiding this comment.
LGTM, this is a great addition to the codebase, so thanks again.
@Wonshtrum I will merge this change, but one unaddressed feedback is a README file in the rust directory mentioning the rust code is just present as an example and has no cmake integration. Can you add that file in a separate PR? Else, I can also add it.
I also changed the default value of the FDBMetric format_code to be %.3g instead of 0.3g both in C and Rust, I do not understand the latter value and why it is used in CppWorkload.h, is it a mistake? If so can I change it?
I missed this earlier. Yes, this looks like a bug. Would appreciate if you can fix this along with the README mentioned above.
I'm utilizing the
ExternalWorkloadto test custom layers within the FoundationDB simulation. The layers under test are authored in Rust and are based on the foundationdb-rs project. The workload API is defined by the C++ header fileClientWorkload.h. Interoperability between Rust and C++ presents challenges, although creating a C++ to C shim was relatively straightforward. My main concern is the unstable ABI of the C++ API, as it relies on the compiler, linker, and system libraries. This proved to be an issue when transitioning from version 7.1 to 7.3, where the workload I was using suddenly broke due to a change in the representation of thestd::stringclass as the fdbserver switched from gcc to clang, as detailed in this forum thread and issue #11298.To address this, I propose that alongside the existing C++ API (utilized by
JavaWorkload), pure C bindings should be made available to ease integration with other languages and mitigate the impact of changes in compilation environments. This aligns well with the location ofClientWorkload.hin thebindings/cfolder.Given my limited familiarity with the FoundationDB codebase, I resorted to various wrappers to minimize code changes. However, a more efficient approach might involve rewriting the
ExternalWorkloador creating a dedicated C version.In this PR, I've divided
ClientWorkload.hintoCWorkload.handCppWorkload.h. ImportingCppWorkload.hshould mirror the behavior of the originalClientWorkload.h, ensuring compatibility with existing workloads utilizing this API. The C bindings introduceBridgeToClientandBridgeToServerstructs that encapsulate collections of function pointers. If the "useCAPI" option is enabled in theExternalWorkloadconfiguration file, it will load theworkloadInstantiatesymbol (instead ofworkloadFactory) and invoke it with the server-bridge (allowing the C workload to interact with the C++FDBWorkloadContextandGenericPromise<bool>classes). The returned client-bridge is then encapsulated within a C++ "translator" workload and assigned as theworkloadImplof theExternalWorkload.