-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C API: improve performance by not memcpy-ing string DB values across …
…ffi boundary (#935) This introduces a couple of new FFI types, representing owned C++ strings and arrays. We use those owned strings for database values, so they do not need to be memcpy'd across ffi boundaries. This is in response to Riff's concerns that database values which hamgrd will be reading may be large and expensive to memcpy. Partner pr to sonic-net/sonic-dash-ha#11 Co-authored-by: erer1243 <[email protected]>
- Loading branch information
Showing
13 changed files
with
251 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,33 @@ | ||
#include "util.h" | ||
|
||
using namespace swss; | ||
|
||
bool swss::cApiTestingDisableAbort = false; | ||
|
||
SWSSString SWSSString_new(const char *data, uint64_t length) { | ||
SWSSTry(return makeString(std::string(data, numeric_cast<std::string::size_type>(length)))); | ||
} | ||
|
||
SWSSString SWSSString_new_c_str(const char *c_str) { | ||
SWSSTry(return makeString(std::string(c_str))); | ||
} | ||
|
||
const char *SWSSStrRef_c_str(SWSSStrRef s) { | ||
SWSSTry(return ((std::string *)s)->c_str()); | ||
} | ||
|
||
uint64_t SWSSStrRef_length(SWSSStrRef s) { | ||
SWSSTry(return ((std::string *)s)->length()); | ||
} | ||
|
||
void SWSSString_free(SWSSString s) { | ||
SWSSTry(delete (std::string *)s); | ||
} | ||
|
||
void SWSSFieldValueArray_free(SWSSFieldValueArray arr) { | ||
SWSSTry(delete[] arr.data); | ||
} | ||
|
||
void SWSSKeyOpFieldValuesArray_free(SWSSKeyOpFieldValuesArray kfvs) { | ||
SWSSTry(delete[] kfvs.data); | ||
} |
Oops, something went wrong.