Skip to content

Commit 6b417cd

Browse files
committed
NSFS | Improve list objects performance on top of NS FS
Signed-off-by: naveenpaul1 <napaul@redhat.com>
1 parent 8f1d6f8 commit 6b417cd

File tree

11 files changed

+848
-308
lines changed

11 files changed

+848
-308
lines changed

config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,9 @@ config.NSFS_GLACIER_MIGRATE_INTERVAL = 15 * 60 * 1000;
799799
// of `manage_nsfs glacier restore`
800800
config.NSFS_GLACIER_RESTORE_INTERVAL = 15 * 60 * 1000;
801801

802+
// enable/disable unsorted listing application level
803+
config.NSFS_LIST_OBJECTS_V2_UNSORTED_ENABLED = false;
804+
802805
// NSFS_GLACIER_EXPIRY_RUN_TIME must be of the format hh:mm which specifies
803806
// when NooBaa should allow running glacier expiry process
804807
// NOTE: This will also be in the same timezone as specified in

src/api/object_api.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,9 @@ module.exports = {
720720
limit: {
721721
type: 'integer'
722722
},
723+
list_type: {
724+
type: 'string',
725+
},
723726
}
724727
},
725728
reply: {
@@ -774,6 +777,9 @@ module.exports = {
774777
limit: {
775778
type: 'integer'
776779
},
780+
list_type: {
781+
type: 'string',
782+
},
777783
}
778784
},
779785
reply: {

src/endpoint/s3/ops/s3_get_bucket.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ async function get_bucket(req) {
4141
bucket: req.params.bucket,
4242
prefix: req.query.prefix,
4343
delimiter: req.query.delimiter,
44+
list_type: list_type,
4445
limit: Math.min(max_keys_received, 1000),
4546
key_marker: list_type === '2' ?
4647
(cont_tok_to_key_marker(cont_tok) || start_after) : req.query.marker,

src/native/fs/fs_napi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2061,7 +2061,7 @@ struct TellDir : public FSWrapWorker<DirWrap>
20612061
}
20622062
virtual void OnOK()
20632063
{
2064-
DBG0("FS::Telldir::OnOK: " << DVAL(_wrap->_path) << DVAL(_tell_res));
2064+
DBG1("FS::Telldir::OnOK: " << DVAL(_wrap->_path) << DVAL(_tell_res));
20652065
Napi::Env env = Env();
20662066
auto res = Napi::BigInt::New(env, _tell_res);
20672067
_deferred.Resolve(res);

src/sdk/keymarker_fs.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* Copyright (C) 2020 NooBaa */
2+
'use strict';
3+
4+
class KeyMarkerFS {
5+
constructor({ marker, marker_pos, pre_dir, pre_dir_pos }, is_unsorted = false) {
6+
this.marker = marker;
7+
this.marker_pos = marker_pos.toString();
8+
this.pre_dir = pre_dir;
9+
this.pre_dir_pos = pre_dir_pos;
10+
this.key_marker_value = marker;
11+
this.current_dir = '';
12+
this.is_unsorted = is_unsorted;
13+
this.last_pre_dir = '';
14+
this.last_pre_dir_position = '';
15+
if (is_unsorted) {
16+
this.current_dir = pre_dir.length > 0 && marker.includes('/') ?
17+
marker.substring(0, marker.lastIndexOf('/') + 1) : '';
18+
}
19+
}
20+
21+
async update_key_marker(marker, marker_pos) {
22+
this.marker = marker;
23+
this.marker_pos = marker_pos;
24+
this.key_marker_value = marker;
25+
}
26+
27+
async get_previour_dir_length() {
28+
return this.pre_dir.length;
29+
}
30+
31+
async get_previour_dir_info() {
32+
return {
33+
pre_dir_path: this.pre_dir.pop(),
34+
pre_dir_position: this.pre_dir_pos.pop(),
35+
};
36+
}
37+
38+
async add_previour_dir(pre_dir, pre_dir_pos) {
39+
this.pre_dir.push(pre_dir);
40+
this.pre_dir_pos.push(pre_dir_pos.toString());
41+
}
42+
43+
async update_last_previour_dir(last_pre_dir, last_pre_dir_position) {
44+
this.last_pre_dir = last_pre_dir;
45+
this.last_pre_dir_position = last_pre_dir_position;
46+
}
47+
}
48+
49+
// EXPORTS
50+
module.exports = KeyMarkerFS;

src/sdk/namespace_fs.js

Lines changed: 220 additions & 86 deletions
Large diffs are not rendered by default.

src/test/system_tests/test_utils.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,26 @@ function get_new_buckets_path_by_test_env(new_buckets_full_path, new_buckets_dir
474474
return is_nc_coretest ? path.join(new_buckets_full_path, new_buckets_dir) : new_buckets_dir;
475475
}
476476

477+
478+
/**
479+
* common dummy SDK for testing
480+
*/
481+
function make_dummy_object_sdk() {
482+
return {
483+
requesting_account: {
484+
force_md5_etag: false,
485+
nsfs_account_config: {
486+
uid: process.getuid(),
487+
gid: process.getgid(),
488+
}
489+
},
490+
abort_controller: new AbortController(),
491+
throw_if_aborted() {
492+
if (this.abort_controller.signal.aborted) throw new Error('request aborted signal');
493+
}
494+
};
495+
}
496+
477497
/**
478498
* write_manual_config_file writes config file directly to the file system without using config FS
479499
* used for creating backward compatibility tests, invalid config files etc
@@ -627,8 +647,10 @@ exports.get_new_buckets_path_by_test_env = get_new_buckets_path_by_test_env;
627647
exports.write_manual_config_file = write_manual_config_file;
628648
exports.write_manual_old_account_config_file = write_manual_old_account_config_file;
629649
exports.delete_manual_config_file = delete_manual_config_file;
650+
exports.make_dummy_object_sdk = make_dummy_object_sdk;
630651
exports.create_redirect_file = create_redirect_file;
631652
exports.delete_redirect_file = delete_redirect_file;
632653
exports.fail_test_if_default_config_dir_exists = fail_test_if_default_config_dir_exists;
633654
exports.create_config_dir = create_config_dir;
634655
exports.clean_config_dir = clean_config_dir;
656+

src/test/unit_tests/jest_tests/test_list_object.test.js

Lines changed: 0 additions & 175 deletions
This file was deleted.

0 commit comments

Comments
 (0)