Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client side unary communication performance improvements #335

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
0040c4a
partially complete changes to templatize data structures
CPattar-NI Oct 9, 2023
8ab9c50
not using the messagevalueclasses
CPattar-NI Oct 10, 2023
55c7771
resizing LVArray dynamically
CPattar-NI Oct 13, 2023
4c2b942
resize array as and when required, template-specialization for uint64
CPattar-NI Oct 17, 2023
7ab9a65
Chakith changes
yash-ni Oct 25, 2023
e9fb841
updated gitignore to add build_bak
yash-ni Oct 25, 2023
5ef4159
Added variable check
yash-ni Oct 25, 2023
bc57257
Merge branch 'remove-temp-structures' of https://github.com/yash-ni/g…
yash-ni Oct 25, 2023
4a91451
Added templates for basic datatypes
yash-ni Oct 25, 2023
4deb905
Removed redundant code
yash-ni Oct 27, 2023
bfb4ddb
Fixed int64 bug
yash-ni Oct 30, 2023
d574c45
Fixed labview server crash
yash-ni Oct 30, 2023
5500fe6
Included all repeated datatypes in the template as well
yash-ni Nov 1, 2023
7647266
Using same old parsing method for strings
yash-ni Nov 1, 2023
aaee3cb
fixed string parsing to return ptr
yash-ni Nov 1, 2023
cc61d1a
parse using google::protobuf::RepeatedField<char> _repeatedMessageValues
CPattar-NI Nov 2, 2023
566274f
Added enum class for data types
yash-ni Nov 6, 2023
c14f921
using grpc repeatedField as vectors
CPattar-NI Nov 6, 2023
6304aab
Removed case structure and extra comparision overhead
yash-ni Nov 8, 2023
ab0ea6a
Made changes for all streaming cases
yash-ni Nov 10, 2023
88903f4
Made changes to all rpc vim files
yash-ni Nov 10, 2023
bcb13ef
Removed extra enum parameter
yash-ni Nov 10, 2023
1bed38e
String parse
CPattar-NI Nov 10, 2023
e8e66c4
Merge branch 'users/cpattar/remove-temp-structures' into remove-temp-…
yash-ni Nov 10, 2023
425b991
Changed lvClusterHandle to raw pointer instead of shared pointer
yash-ni Nov 10, 2023
84b5b7b
Reverted build spec
yash-ni Nov 20, 2023
c53d19c
Commented datatype enum
yash-ni Nov 21, 2023
ee2e4dd
Merge pull request #1 from yash-ni/remove-temp-structures
CPattar-NI Nov 21, 2023
1016ec0
split ParseAndCopyMessage into single and repeated
CPattar-NI Jan 3, 2024
42805cd
clearing local gitignore changes
CPattar-NI Jan 3, 2024
ef329dd
removing windows header which was used for debugging
CPattar-NI Jan 3, 2024
7b2f5dd
Adding debug symbols for release build, adding feature toggle class
CPattar-NI Jan 10, 2024
ea42913
Adding files to cmake, and using the feature toggle class
CPattar-NI Jan 11, 2024
488bf95
Merge branch 'users/cpattar/create-feature-toggle-infra' into users/c…
CPattar-NI Jan 11, 2024
3acb1a0
Merge branch 'master' into users/cpattar/create-feature-toggle-infra
CPattar-NI Jan 12, 2024
cc24a01
Code cleanup
CPattar-NI Jan 12, 2024
9c20e5d
Continue index required for nested message type only.
CPattar-NI Jan 17, 2024
bd77565
Config file read in InitCallback is enough
CPattar-NI Jan 17, 2024
bdab389
Merge branch 'users/cpattar/create-feature-toggle-infra' of https://g…
CPattar-NI Jan 17, 2024
b20ca1f
Merge branch 'users/cpattar/create-feature-toggle-infra' into users/c…
CPattar-NI Jan 17, 2024
fe5e0f2
remove empty LVCluster declaration
CPattar-NI Jan 17, 2024
2132292
Removing feature toggle header
CPattar-NI Jan 17, 2024
d93084a
Adding a PostParseAction to enable custom post action. In this case, …
CPattar-NI Jan 18, 2024
aab0398
merge feature toggle branch commit
CPattar-NI Jan 18, 2024
2ab27d5
Removing efficient copy for streaming clients
CPattar-NI Jan 19, 2024
c417c3d
Cleaning up code from streaming calls
CPattar-NI Jan 19, 2024
dc3dc7e
Merge branch 'master' into users/cpattar/remove-temp-structures
CPattar-NI Jan 19, 2024
9228be3
reverting the VI changes for streaming
CPattar-NI Jan 19, 2024
3742cd3
Merge branch 'users/cpattar/remove-temp-structures' of https://github…
CPattar-NI Jan 19, 2024
e74dfac
Merge branch 'master' into users/cpattar/remove-temp-structures
CPattar-NI Jan 22, 2024
e47104a
cannot overload a function with 'extern "C"' linkage, ClientUnaryCall…
CPattar-NI Jan 22, 2024
30e08c9
minor bug fix
CPattar-NI Jan 22, 2024
f380fcd
fixing for each loop, as "for each" isn't available on linux
CPattar-NI Jan 22, 2024
2b66ff1
changing back NumericArrayResize from noinit
CPattar-NI Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ add_library(labview_grpc_server SHARED
src/grpc_server.cc
src/lv_interop.cc
src/lv_message.cc
src/lv_message_efficient.cc
src/lv_message_value.cc
src/lv_proto_server_reflection_plugin.cc
src/lv_proto_server_reflection_service.cc
Expand Down
Binary file modified labview source/gRPC lv Support/Client API/Client Unary Call.vim
Binary file not shown.
60 changes: 30 additions & 30 deletions src/cluster_copier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ namespace grpc_labview {
{
if (metadata->isRepeated)
{
auto repeatedString = static_cast<const LVRepeatedStringMessageValue&>(*value);
auto repeatedString = static_cast<const LVRepeatedMessageValue<std::string>&>(*value);
if (repeatedString._value.size() != 0)
{
NumericArrayResize(0x08, 1, start, repeatedString._value.size());
Expand Down Expand Up @@ -356,7 +356,7 @@ namespace grpc_labview {
{
if (metadata->isRepeated)
{
auto repeatedInt32 = std::static_pointer_cast<LVRepeatedInt32MessageValue>(value);
auto repeatedInt32 = std::static_pointer_cast<LVRepeatedMessageValue<int>>(value);
if (repeatedInt32->_value.size() != 0)
{
NumericArrayResize(0x03, 1, start, repeatedInt32->_value.size());
Expand All @@ -368,7 +368,7 @@ namespace grpc_labview {
}
else
{
*(int*)start = ((LVInt32MessageValue*)value.get())->_value;
*(int*)start = ((LVVariableMessageValue<int>*)value.get())->_value;
}
}

Expand All @@ -378,7 +378,7 @@ namespace grpc_labview {
{
if (metadata->isRepeated)
{
auto repeatedUInt32 = std::static_pointer_cast<LVRepeatedUInt32MessageValue>(value);
auto repeatedUInt32 = std::static_pointer_cast<LVRepeatedMessageValue<uint32_t>>(value);
if (repeatedUInt32->_value.size() != 0)
{
NumericArrayResize(0x03, 1, start, repeatedUInt32->_value.size());
Expand All @@ -390,7 +390,7 @@ namespace grpc_labview {
}
else
{
*(int*)start = ((LVUInt32MessageValue*)value.get())->_value;
*(int*)start = ((LVVariableMessageValue<uint32_t>*)value.get())->_value;
}
}

Expand Down Expand Up @@ -435,7 +435,7 @@ namespace grpc_labview {
{
if (metadata->isRepeated)
{
auto repeatedInt64 = std::static_pointer_cast<LVRepeatedInt64MessageValue>(value);
auto repeatedInt64 = std::static_pointer_cast<LVRepeatedMessageValue<int64_t>>(value);
if (repeatedInt64->_value.size() != 0)
{
NumericArrayResize(0x04, 1, start, repeatedInt64->_value.size());
Expand All @@ -447,7 +447,7 @@ namespace grpc_labview {
}
else
{
*(int64_t*)start = ((LVInt64MessageValue*)value.get())->_value;
*(int64_t*)start = ((LVVariableMessageValue<int64_t>*)value.get())->_value;
}
}

Expand All @@ -457,7 +457,7 @@ namespace grpc_labview {
{
if (metadata->isRepeated)
{
auto repeatedUInt64 = std::static_pointer_cast<LVRepeatedUInt64MessageValue>(value);
auto repeatedUInt64 = std::static_pointer_cast<LVRepeatedMessageValue<uint64_t>>(value);
if (repeatedUInt64->_value.size() != 0)
{
NumericArrayResize(0x08, 1, start, repeatedUInt64->_value.size());
Expand All @@ -469,7 +469,7 @@ namespace grpc_labview {
}
else
{
*(uint64_t*)start = ((LVUInt64MessageValue*)value.get())->_value;
*(uint64_t*)start = ((LVVariableMessageValue<uint64_t>*)value.get())->_value;
}
}

Expand All @@ -479,7 +479,7 @@ namespace grpc_labview {
{
if (metadata->isRepeated)
{
auto repeatedBoolean = std::static_pointer_cast<LVRepeatedBooleanMessageValue>(value);
auto repeatedBoolean = std::static_pointer_cast<LVRepeatedMessageValue<bool>>(value);
if (repeatedBoolean->_value.size() != 0)
{
NumericArrayResize(0x01, 1, start, repeatedBoolean->_value.size());
Expand All @@ -491,7 +491,7 @@ namespace grpc_labview {
}
else
{
*(bool*)start = ((LVBooleanMessageValue*)value.get())->_value;
*(bool*)start = ((LVVariableMessageValue<bool>*)value.get())->_value;
}
}

Expand All @@ -501,7 +501,7 @@ namespace grpc_labview {
{
if (metadata->isRepeated)
{
auto repeatedDouble = std::static_pointer_cast<LVRepeatedDoubleMessageValue>(value);
auto repeatedDouble = std::static_pointer_cast<LVRepeatedMessageValue<double>>(value);
if (repeatedDouble->_value.size() != 0)
{
auto array = *(LV1DArrayHandle*)start;
Expand All @@ -514,7 +514,7 @@ namespace grpc_labview {
}
else
{
*(double*)start = ((LVDoubleMessageValue*)value.get())->_value;
*(double*)start = ((LVVariableMessageValue<double>*)value.get())->_value;
}
}

Expand All @@ -524,7 +524,7 @@ namespace grpc_labview {
{
if (metadata->isRepeated)
{
auto repeatedFloat = std::static_pointer_cast<LVRepeatedFloatMessageValue>(value);
auto repeatedFloat = std::static_pointer_cast<LVRepeatedMessageValue<float>>(value);
if (repeatedFloat->_value.size() != 0)
{
NumericArrayResize(0x03, 1, start, repeatedFloat->_value.size());
Expand All @@ -536,7 +536,7 @@ namespace grpc_labview {
}
else
{
*(float*)start = ((LVFloatMessageValue*)value.get())->_value;
*(float*)start = ((LVVariableMessageValue<float>*)value.get())->_value;
}
}

Expand Down Expand Up @@ -681,7 +681,7 @@ namespace grpc_labview {
auto array = *(LV1DArrayHandle*)start;
if (array && *array && ((*array)->cnt != 0))
{
auto repeatedStringValue = std::make_shared<LVRepeatedStringMessageValue>(metadata->protobufIndex);
auto repeatedStringValue = std::make_shared<LVRepeatedMessageValue<std::string>>(metadata->protobufIndex);
message._values.emplace(metadata->protobufIndex, repeatedStringValue);
auto lvStr = (*array)->bytes<LStrHandle>();
for (int x = 0; x < (*array)->cnt; ++x)
Expand Down Expand Up @@ -717,7 +717,7 @@ namespace grpc_labview {
if (array && *array && ((*array)->cnt != 0))
{
auto count = (*array)->cnt;
auto repeatedValue = std::make_shared<LVRepeatedBooleanMessageValue>(metadata->protobufIndex);
auto repeatedValue = std::make_shared<LVRepeatedMessageValue<bool>>(metadata->protobufIndex);
message._values.emplace(metadata->protobufIndex, repeatedValue);
auto data = (*array)->bytes<bool>();
repeatedValue->_value.Reserve(count);
Expand All @@ -727,7 +727,7 @@ namespace grpc_labview {
}
else
{
auto value = std::make_shared<LVBooleanMessageValue>(metadata->protobufIndex, *(bool*)start);
auto value = std::make_shared<LVVariableMessageValue<bool>>(metadata->protobufIndex, *(bool*)start);
message._values.emplace(metadata->protobufIndex, value);
}
}
Expand All @@ -742,7 +742,7 @@ namespace grpc_labview {
if (array && *array && ((*array)->cnt != 0))
{
auto count = (*array)->cnt;
auto repeatedValue = std::make_shared<LVRepeatedInt32MessageValue>(metadata->protobufIndex);
auto repeatedValue = std::make_shared<LVRepeatedMessageValue<int>>(metadata->protobufIndex);
message._values.emplace(metadata->protobufIndex, repeatedValue);
auto data = (*array)->bytes<int32_t>();
repeatedValue->_value.Reserve(count);
Expand All @@ -752,7 +752,7 @@ namespace grpc_labview {
}
else
{
auto value = std::make_shared<LVInt32MessageValue>(metadata->protobufIndex, *(int*)start);
auto value = std::make_shared<LVVariableMessageValue<int>>(metadata->protobufIndex, *(int*)start);
message._values.emplace(metadata->protobufIndex, value);
}
}
Expand All @@ -767,7 +767,7 @@ namespace grpc_labview {
if (array && *array && ((*array)->cnt != 0))
{
auto count = (*array)->cnt;
auto repeatedValue = std::make_shared<LVRepeatedUInt32MessageValue>(metadata->protobufIndex);
auto repeatedValue = std::make_shared<LVRepeatedMessageValue<uint32_t>>(metadata->protobufIndex);
message._values.emplace(metadata->protobufIndex, repeatedValue);
auto data = (*array)->bytes<uint32_t>();
repeatedValue->_value.Reserve(count);
Expand All @@ -777,7 +777,7 @@ namespace grpc_labview {
}
else
{
auto value = std::make_shared<LVUInt32MessageValue>(metadata->protobufIndex, *(uint32_t*)start);
auto value = std::make_shared<LVVariableMessageValue<uint32_t>>(metadata->protobufIndex, *(uint32_t*)start);
message._values.emplace(metadata->protobufIndex, value);
}
}
Expand Down Expand Up @@ -833,7 +833,7 @@ namespace grpc_labview {
if (array && *array && ((*array)->cnt != 0))
{
auto count = (*array)->cnt;
auto repeatedValue = std::make_shared<LVRepeatedInt64MessageValue>(metadata->protobufIndex);
auto repeatedValue = std::make_shared<LVRepeatedMessageValue<int64_t>>(metadata->protobufIndex);
message._values.emplace(metadata->protobufIndex, repeatedValue);
auto data = (*array)->bytes<int64_t>();
repeatedValue->_value.Reserve(count);
Expand All @@ -843,7 +843,7 @@ namespace grpc_labview {
}
else
{
auto value = std::make_shared<LVInt64MessageValue>(metadata->protobufIndex, *(int64_t*)start);
auto value = std::make_shared<LVVariableMessageValue<int64_t>>(metadata->protobufIndex, *(int64_t*)start);
message._values.emplace(metadata->protobufIndex, value);
}
}
Expand All @@ -858,7 +858,7 @@ namespace grpc_labview {
if (array && *array && ((*array)->cnt != 0))
{
auto count = (*array)->cnt;
auto repeatedValue = std::make_shared<LVRepeatedUInt64MessageValue>(metadata->protobufIndex);
auto repeatedValue = std::make_shared<LVRepeatedMessageValue<uint64_t>>(metadata->protobufIndex);
message._values.emplace(metadata->protobufIndex, repeatedValue);
auto data = (*array)->bytes<uint64_t>();
repeatedValue->_value.Reserve(count);
Expand All @@ -868,7 +868,7 @@ namespace grpc_labview {
}
else
{
auto value = std::make_shared<LVUInt64MessageValue>(metadata->protobufIndex, *(uint64_t*)start);
auto value = std::make_shared<LVVariableMessageValue<uint64_t>>(metadata->protobufIndex, *(uint64_t*)start);
message._values.emplace(metadata->protobufIndex, value);
}
}
Expand All @@ -883,7 +883,7 @@ namespace grpc_labview {
if (array && *array && ((*array)->cnt != 0))
{
auto count = (*array)->cnt;
auto repeatedValue = std::make_shared<LVRepeatedDoubleMessageValue>(metadata->protobufIndex);
auto repeatedValue = std::make_shared<LVRepeatedMessageValue<double>>(metadata->protobufIndex);
message._values.emplace(metadata->protobufIndex, repeatedValue);
auto data = (*array)->bytes<double>();
repeatedValue->_value.Reserve(count);
Expand All @@ -893,7 +893,7 @@ namespace grpc_labview {
}
else
{
auto value = std::make_shared<LVDoubleMessageValue>(metadata->protobufIndex, *(double*)start);
auto value = std::make_shared<LVVariableMessageValue<double>>(metadata->protobufIndex, *(double*)start);
message._values.emplace(metadata->protobufIndex, value);
}
}
Expand All @@ -908,7 +908,7 @@ namespace grpc_labview {
if (array && *array && ((*array)->cnt != 0))
{
auto count = (*array)->cnt;
auto repeatedValue = std::make_shared<LVRepeatedFloatMessageValue>(metadata->protobufIndex);
auto repeatedValue = std::make_shared<LVRepeatedMessageValue<float>>(metadata->protobufIndex);
message._values.emplace(metadata->protobufIndex, repeatedValue);
auto data = (*array)->bytes<float>();
repeatedValue->_value.Reserve(count);
Expand All @@ -918,7 +918,7 @@ namespace grpc_labview {
}
else
{
auto value = std::make_shared<LVFloatMessageValue>(metadata->protobufIndex, *(float*)start);
auto value = std::make_shared<LVVariableMessageValue<float>>(metadata->protobufIndex, *(float*)start);
message._values.emplace(metadata->protobufIndex, value);
}
}
Expand Down
73 changes: 38 additions & 35 deletions src/feature_toggles.cc
Original file line number Diff line number Diff line change
@@ -1,49 +1,52 @@
#include "feature_toggles.h"
#include <feature_toggles.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <map>

// Function to read feature configurations from an INI file
void FeatureConfig::readConfigFromFile(const std::string& filePath) {
std::ifstream configFile(filePath);
if (!configFile.is_open()) {
return;
}
namespace grpc_labview {
// Function to read feature configurations from an INI file
void FeatureConfig::readConfigFromFile(const std::string& filePath) {
std::ifstream configFile(filePath);
if (!configFile.is_open()) {
return;
}

std::string line;
std::string currentSection; // For handling INI sections
std::string line;
std::string currentSection; // For handling INI sections

while (std::getline(configFile, line)) {
// Trim leading and trailing whitespaces
line.erase(line.find_last_not_of(" \t") + 1);
line.erase(0, line.find_first_not_of(" \t"));
while (std::getline(configFile, line)) {
// Trim leading and trailing whitespaces
line.erase(line.find_last_not_of(" \t") + 1);
line.erase(0, line.find_first_not_of(" \t"));

// Skip comments and empty lines
if (line.empty() || line[0] == ';') {
continue;
}
// Skip comments and empty lines
if (line.empty() || line[0] == ';') {
continue;
}

// Check for section header
if (line[0] == '[' && line[line.length() - 1] == ']') {
currentSection = line.substr(1, line.length() - 2);
} else {
// Parse key-value pairs
std::istringstream iss(line);
std::string key, value;
if (std::getline(iss, key, '=') && std::getline(iss, value)) {
// Append section name to key for uniqueness
std::string fullKey = currentSection.empty() ? key : currentSection + "_" + key;
featureFlags[fullKey] = (value == "true");
// Check for section header
if (line[0] == '[' && line[line.length() - 1] == ']') {
currentSection = line.substr(1, line.length() - 2);
}
else {
// Parse key-value pairs
std::istringstream iss(line);
std::string key, value;
if (std::getline(iss, key, '=') && std::getline(iss, value)) {
// Append section name to key for uniqueness
std::string fullKey = currentSection.empty() ? key : currentSection + "_" + key;
featureFlags[fullKey] = (value == "true");
}
}
}
}

configFile.close();
}
configFile.close();
}

// Function to check if a feature is enabled
bool FeatureConfig::isFeatureEnabled(const std::string& featureName) const {
auto it = featureFlags.find(featureName);
return (it != featureFlags.end()) ? it->second : false;
// Function to check if a feature is enabled
bool FeatureConfig::isFeatureEnabled(const std::string& featureName) const {
auto it = featureFlags.find(featureName);
return (it != featureFlags.end()) ? it->second : false;
}
}
Loading
Loading