Skip to content

Commit

Permalink
NSFS | Improve list objects performance on top of NS FS
Browse files Browse the repository at this point in the history
Signed-off-by: naveenpaul1 <[email protected]>
  • Loading branch information
naveenpaul1 committed Oct 17, 2024
1 parent 8f1d6f8 commit 6b417cd
Show file tree
Hide file tree
Showing 11 changed files with 848 additions and 308 deletions.
3 changes: 3 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,9 @@ config.NSFS_GLACIER_MIGRATE_INTERVAL = 15 * 60 * 1000;
// of `manage_nsfs glacier restore`
config.NSFS_GLACIER_RESTORE_INTERVAL = 15 * 60 * 1000;

// enable/disable unsorted listing application level
config.NSFS_LIST_OBJECTS_V2_UNSORTED_ENABLED = false;

// NSFS_GLACIER_EXPIRY_RUN_TIME must be of the format hh:mm which specifies
// when NooBaa should allow running glacier expiry process
// NOTE: This will also be in the same timezone as specified in
Expand Down
6 changes: 6 additions & 0 deletions src/api/object_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,9 @@ module.exports = {
limit: {
type: 'integer'
},
list_type: {
type: 'string',
},
}
},
reply: {
Expand Down Expand Up @@ -774,6 +777,9 @@ module.exports = {
limit: {
type: 'integer'
},
list_type: {
type: 'string',
},
}
},
reply: {
Expand Down
1 change: 1 addition & 0 deletions src/endpoint/s3/ops/s3_get_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ async function get_bucket(req) {
bucket: req.params.bucket,
prefix: req.query.prefix,
delimiter: req.query.delimiter,
list_type: list_type,
limit: Math.min(max_keys_received, 1000),
key_marker: list_type === '2' ?
(cont_tok_to_key_marker(cont_tok) || start_after) : req.query.marker,
Expand Down
2 changes: 1 addition & 1 deletion src/native/fs/fs_napi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2061,7 +2061,7 @@ struct TellDir : public FSWrapWorker<DirWrap>
}
virtual void OnOK()
{
DBG0("FS::Telldir::OnOK: " << DVAL(_wrap->_path) << DVAL(_tell_res));
DBG1("FS::Telldir::OnOK: " << DVAL(_wrap->_path) << DVAL(_tell_res));
Napi::Env env = Env();
auto res = Napi::BigInt::New(env, _tell_res);
_deferred.Resolve(res);
Expand Down
50 changes: 50 additions & 0 deletions src/sdk/keymarker_fs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* Copyright (C) 2020 NooBaa */
'use strict';

class KeyMarkerFS {
constructor({ marker, marker_pos, pre_dir, pre_dir_pos }, is_unsorted = false) {
this.marker = marker;
this.marker_pos = marker_pos.toString();
this.pre_dir = pre_dir;
this.pre_dir_pos = pre_dir_pos;
this.key_marker_value = marker;
this.current_dir = '';
this.is_unsorted = is_unsorted;
this.last_pre_dir = '';
this.last_pre_dir_position = '';
if (is_unsorted) {
this.current_dir = pre_dir.length > 0 && marker.includes('/') ?
marker.substring(0, marker.lastIndexOf('/') + 1) : '';
}
}

async update_key_marker(marker, marker_pos) {
this.marker = marker;
this.marker_pos = marker_pos;
this.key_marker_value = marker;
}

async get_previour_dir_length() {
return this.pre_dir.length;
}

async get_previour_dir_info() {
return {
pre_dir_path: this.pre_dir.pop(),
pre_dir_position: this.pre_dir_pos.pop(),
};
}

async add_previour_dir(pre_dir, pre_dir_pos) {
this.pre_dir.push(pre_dir);
this.pre_dir_pos.push(pre_dir_pos.toString());
}

async update_last_previour_dir(last_pre_dir, last_pre_dir_position) {
this.last_pre_dir = last_pre_dir;
this.last_pre_dir_position = last_pre_dir_position;
}
}

// EXPORTS
module.exports = KeyMarkerFS;
306 changes: 220 additions & 86 deletions src/sdk/namespace_fs.js

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions src/test/system_tests/test_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,26 @@ function get_new_buckets_path_by_test_env(new_buckets_full_path, new_buckets_dir
return is_nc_coretest ? path.join(new_buckets_full_path, new_buckets_dir) : new_buckets_dir;
}


/**
* common dummy SDK for testing
*/
function make_dummy_object_sdk() {
return {
requesting_account: {
force_md5_etag: false,
nsfs_account_config: {
uid: process.getuid(),
gid: process.getgid(),
}
},
abort_controller: new AbortController(),
throw_if_aborted() {
if (this.abort_controller.signal.aborted) throw new Error('request aborted signal');
}
};
}

/**
* write_manual_config_file writes config file directly to the file system without using config FS
* used for creating backward compatibility tests, invalid config files etc
Expand Down Expand Up @@ -627,8 +647,10 @@ exports.get_new_buckets_path_by_test_env = get_new_buckets_path_by_test_env;
exports.write_manual_config_file = write_manual_config_file;
exports.write_manual_old_account_config_file = write_manual_old_account_config_file;
exports.delete_manual_config_file = delete_manual_config_file;
exports.make_dummy_object_sdk = make_dummy_object_sdk;
exports.create_redirect_file = create_redirect_file;
exports.delete_redirect_file = delete_redirect_file;
exports.fail_test_if_default_config_dir_exists = fail_test_if_default_config_dir_exists;
exports.create_config_dir = create_config_dir;
exports.clean_config_dir = clean_config_dir;

175 changes: 0 additions & 175 deletions src/test/unit_tests/jest_tests/test_list_object.test.js

This file was deleted.

Loading

0 comments on commit 6b417cd

Please sign in to comment.