Skip to content

Commit

Permalink
[NKV-SDK-Host] Refactor nkv host code
Browse files Browse the repository at this point in the history
    Brief Changes:
    ==============
    * Fixed issue using resize and pushback at the same time
    * Fix listing_keys and data_cache proto-types
    * Gitlab upgrade, trigger:include now takes a string or list
    * Fix Sonar-Scanner download.
        - Get sonar-scanner from URL determined by CI/CD var
        - Determine sonar-scanner dir name by listing contents of zip

    Testing Done:
    =============
    * Run with gitlab pipeline

    * {Ticket/Issue Reference}
            * SVK-2328

Signed-off-by: r.kavuluru <[email protected]>
  • Loading branch information
ramachaitanyak committed Aug 20, 2024
1 parent 13f841e commit 19f0e9c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
6 changes: 3 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ deploy DSS:
UPSTREAM_REF: $CI_MERGE_REQUEST_REF_PATH
trigger:
include:
project: dfs/dss/dss-ansible
ref: master
file: .gitlab-ci.yml
- project: dfs/dss/dss-ansible
ref: master
file: .gitlab-ci.yml
strategy: depend
resource_group: inv_$CI_PROJECT_NAME.ini
rules:
Expand Down
12 changes: 7 additions & 5 deletions .gitlab/sonar.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
sonar-scanner:
stage: scan
before_script:
# Download latest sonar-scanner from sonar-source
- rm -rf /sonar-scanner*
- wget --no-verbose --content-disposition -E -c "https://search.maven.org/remote_content?g=org.sonarsource.scanner.cli&a=sonar-scanner-cli&v=LATEST&c=linux&e=zip"
- unzip -q sonar-scanner-cli-*.zip -d /
# Download sonar-scanner from URL defined in CICD variable SONAR_SCANNER_URL
- export SONAR_SCANNER_FILENAME="${SONAR_SCANNER_URL##*/}"
- curl --silent --remote-name $SONAR_SCANNER_URL
# Get sonar-scanner root dir from printed contents of zip file
- export SONAR_SCANNER_DIR=$(unzip -l "$SONAR_SCANNER_FILENAME" | awk '{print $4}' | grep '/' | cut -d '/' -f 1 | sort | uniq -c | sort -nr | head -n 1 | awk '{print $2}')
- unzip -q $SONAR_SCANNER_FILENAME -d /
script:
# Scan with sonar-scanner
- /sonar-scanner-*-linux/bin/sonar-scanner -Dsonar.qualitygate.wait=true -Dsonar.cfamily.build-wrapper-output=bw-output -Dsonar.coverageReportPaths=$SONAR_UNIT_TEST_REPORT
- /$SONAR_SCANNER_DIR/bin/sonar-scanner -Dsonar.qualitygate.wait=true -Dsonar.cfamily.build-wrapper-output=bw-output -Dsonar.coverageReportPaths=$SONAR_UNIT_TEST_REPORT
allow_failure: true
needs:
- build dss-sdk
Expand Down
26 changes: 21 additions & 5 deletions host/src/include_private/nkv_framework.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,12 @@
int32_t core_to_pin;
int32_t path_numa_node;
std::atomic<uint32_t> nkv_async_path_cur_qd;
std::unordered_map<std::size_t, std::set<std::string> > *listing_keys;
std::unordered_map<std::string, nkv_value_wrapper*> *data_cache;
// This is a vector of maps with keys and set values
std::vector<std::unordered_map<std::size_t, std::set<std::string>>> listing_keys;
//std::unordered_map<std::size_t, std::set<std::string> > *listing_keys;
// This is a vector of maps with keys and wrapper object values
std::vector<std::unordered_map<std::string, nkv_value_wrapper*>> data_cache;
//std::unordered_map<std::string, nkv_value_wrapper*> *data_cache;
std::atomic<uint32_t> nkv_outstanding_iter_on_path;
std::atomic<uint32_t> nkv_path_stopping;
std::atomic<uint64_t> nkv_num_key_prefixes;
Expand Down Expand Up @@ -282,16 +286,28 @@
pthread_rwlock_init(&data_rw_lock_list[iter], NULL);
}

listing_keys = new std::unordered_map<std::size_t, std::set<std::string> > (nkv_listing_cache_num_shards);
// Resize and initialize std::unordered_map at each index
listing_keys.resize(nkv_listing_cache_num_shards);
//listing_keys = new std::unordered_map<std::size_t, std::set<std::string> > (nkv_listing_cache_num_shards);
for (auto i =0; i<nkv_listing_cache_num_shards; i++) {
// Initialize map at index
listing_keys[i] = std::unordered_map<std::size_t, std::set<std::string>>();
}
if (nkv_in_memory_exec) {
data_cache = new std::unordered_map<std::string, nkv_value_wrapper*> (nkv_listing_cache_num_shards);
//data_cache = new std::unordered_map<std::string, nkv_value_wrapper*> (nkv_listing_cache_num_shards);
// Resize and initialize data_cache
data_cache.resize(nkv_listing_cache_num_shards);
for (auto i=0; i<nkv_listing_cache_num_shards; i++) {
// Initialize map at index
data_cache[i] = std::unordered_map<std::string, nkv_value_wrapper*>();
}
}
cnt_cache.resize(nkv_read_cache_shard_size);
for (auto i=0; i<nkv_read_cache_shard_size; i++) {
// Initialize class object
nkv_lruCache<std::string, nkv_value_wrapper> *cache_obj
= new nkv_lruCache<std::string, nkv_value_wrapper>(nkv_read_cache_size);
cnt_cache.push_back(cache_obj);
cnt_cache[i] = cache_obj;
}
nkv_num_dc_keys = 0;

Expand Down
8 changes: 4 additions & 4 deletions host/src/nkv_framework.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2224,10 +2224,10 @@ NKVTargetPath::~NKVTargetPath() {
}

delete[] cache_rw_lock_list;
delete[] listing_keys;
if (nkv_in_memory_exec) {
delete[] data_cache;
}
// This delete is not required with the STL container, clean up happens
// when container goes out of scope
//delete[] listing_keys;
//delete[] data_cache;
//delete[] cnt_cache;
for (int i=0; i<cnt_cache.size(); i++) {
delete cnt_cache[i];
Expand Down

0 comments on commit 19f0e9c

Please sign in to comment.