Skip to content

Commit d8b024e

Browse files
committed
NSFS | Improve list objects performance on top of NS FS
Signed-off-by: naveenpaul1 <[email protected]>
1 parent 1d52ffb commit d8b024e

File tree

11 files changed

+857
-312
lines changed

11 files changed

+857
-312
lines changed

config.js

+3
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,9 @@ config.NSFS_GLACIER_MIGRATE_INTERVAL = 15 * 60 * 1000;
843843
// of `manage_nsfs glacier restore`
844844
config.NSFS_GLACIER_RESTORE_INTERVAL = 15 * 60 * 1000;
845845

846+
// enable/disable unsorted listing application level
847+
config.NSFS_LIST_OBJECTS_V2_UNSORTED_ENABLED = false;
848+
846849
// NSFS_GLACIER_EXPIRY_RUN_TIME must be of the format hh:mm which specifies
847850
// when NooBaa should allow running glacier expiry process
848851
// NOTE: This will also be in the same timezone as specified in

src/api/object_api.js

+6
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,9 @@ module.exports = {
723723
limit: {
724724
type: 'integer'
725725
},
726+
list_type: {
727+
type: 'string',
728+
},
726729
}
727730
},
728731
reply: {
@@ -777,6 +780,9 @@ module.exports = {
777780
limit: {
778781
type: 'integer'
779782
},
783+
list_type: {
784+
type: 'string',
785+
},
780786
}
781787
},
782788
reply: {

src/endpoint/s3/ops/s3_get_bucket.js

+1
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
(s3_utils.cont_tok_to_key_marker(cont_tok) || start_after) : req.query.marker,

src/native/fs/fs_napi.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,7 @@ struct TellDir : public FSWrapWorker<DirWrap>
21052105
}
21062106
virtual void OnOK()
21072107
{
2108-
DBG0("FS::Telldir::OnOK: " << DVAL(_wrap->_path) << DVAL(_tell_res));
2108+
DBG1("FS::Telldir::OnOK: " << DVAL(_wrap->_path) << DVAL(_tell_res));
21092109
Napi::Env env = Env();
21102110
auto res = Napi::BigInt::New(env, _tell_res);
21112111
_deferred.Resolve(res);

src/sdk/keymarker_fs.js

+50
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

+229-90
Large diffs are not rendered by default.

src/test/system_tests/test_utils.js

+22
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,26 @@ function get_new_buckets_path_by_test_env(new_buckets_full_path, new_buckets_dir
491491
return is_nc_coretest ? path.join(new_buckets_full_path, new_buckets_dir) : new_buckets_dir;
492492
}
493493

494+
495+
/**
496+
* common dummy SDK for testing
497+
*/
498+
function make_dummy_object_sdk() {
499+
return {
500+
requesting_account: {
501+
force_md5_etag: false,
502+
nsfs_account_config: {
503+
uid: process.getuid(),
504+
gid: process.getgid(),
505+
}
506+
},
507+
abort_controller: new AbortController(),
508+
throw_if_aborted() {
509+
if (this.abort_controller.signal.aborted) throw new Error('request aborted signal');
510+
}
511+
};
512+
}
513+
494514
/**
495515
* write_manual_config_file writes config file directly to the file system without using config FS
496516
* used for creating backward compatibility tests, invalid config files etc
@@ -758,10 +778,12 @@ exports.create_identity_dir_if_missing = create_identity_dir_if_missing;
758778
exports.symlink_account_name = symlink_account_name;
759779
exports.symlink_account_access_keys = symlink_account_access_keys;
760780
exports.create_file = create_file;
781+
exports.make_dummy_object_sdk = make_dummy_object_sdk;
761782
exports.create_redirect_file = create_redirect_file;
762783
exports.delete_redirect_file = delete_redirect_file;
763784
exports.create_system_json = create_system_json;
764785
exports.update_system_json = update_system_json;
765786
exports.fail_test_if_default_config_dir_exists = fail_test_if_default_config_dir_exists;
766787
exports.create_config_dir = create_config_dir;
767788
exports.clean_config_dir = clean_config_dir;
789+

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

-175
This file was deleted.

0 commit comments

Comments
 (0)