nv-buf-storage-on-mmap 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -0
- package/index.js +36 -0
- package/package.json +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
|
|
2
|
+
nv-buf-storage-on-mmap
|
|
3
|
+
=======================
|
|
4
|
+
- very big buffer
|
|
5
|
+
- only work on server-side
|
|
6
|
+
- only work on linux
|
|
7
|
+
- it is used for saving massive intermediate datas in debug/test-bed/tracing enviroment
|
|
8
|
+
- it work well if fragments(in-continuous segment on underlying) <= 67108864
|
|
9
|
+
|
|
10
|
+
install
|
|
11
|
+
=======
|
|
12
|
+
- npm install nv-buf-storage-on-mmap
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
usage
|
|
16
|
+
=====
|
|
17
|
+
|
|
18
|
+
const x = require("nv-buf-storage-on-mmap");
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
example
|
|
22
|
+
-------
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/*
|
|
26
|
+
(
|
|
27
|
+
file_path = "./nvbuf.store.mmap",
|
|
28
|
+
init_max_alocable_sz=1024*1024*1024*128,
|
|
29
|
+
init_max_nd_cnt =2**26,
|
|
30
|
+
underlying_offset = 0,
|
|
31
|
+
underlying_sz = undefined,
|
|
32
|
+
huge_page_mode = undefined,
|
|
33
|
+
mmap_offset = undefined,
|
|
34
|
+
mmap_arg_addr = undefined
|
|
35
|
+
)=> <NonScalableStorage>
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
var store = x("/home/dev/test-nv-buf-storage/nvbuf.store.mmap")
|
|
39
|
+
store
|
|
40
|
+
/*
|
|
41
|
+
|
|
42
|
+
NonScalableStorage {
|
|
43
|
+
_data: Uint8Array(137438953472) [
|
|
44
|
+
0, 49, 50, 51, 52, 53, 54, 55, 55, 0, 0, 0,
|
|
45
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
46
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
47
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
48
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
49
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
50
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
51
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
52
|
+
0, 0, 0, 0,
|
|
53
|
+
... 137438953372 more items
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
x.show_underlying(store)
|
|
60
|
+
/*
|
|
61
|
+
{
|
|
62
|
+
"is_success": true,
|
|
63
|
+
"mmap_arg_addr": "0",
|
|
64
|
+
"mmap_ptr": "0x7e4293e00000",
|
|
65
|
+
"mmap_offset": 0,
|
|
66
|
+
"mmap_bytsz": 139049566304,
|
|
67
|
+
"fd": -1,
|
|
68
|
+
"flags": 1,
|
|
69
|
+
"is_creator": false,
|
|
70
|
+
"using_fixed_addr": false,
|
|
71
|
+
"huge_page_mode": "None",
|
|
72
|
+
"file_path": "/home/dev/test-nv-buf-storage/nvbuf.store.mmap"
|
|
73
|
+
}
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
METHODS
|
|
79
|
+
========
|
|
80
|
+
|
|
81
|
+
store._calc_datasz_for_dump store.algn_aloc store.aloc store.cond_is_scalable store.constructor store.debug_read
|
|
82
|
+
store.debug_wbi store.debug_wnum store.debug_write store.debug_wsym store.dloc store.dump
|
|
83
|
+
store.rdv store.rf32 store.rf32a store.rf64 store.rf64a store.ri16
|
|
84
|
+
store.ri16a store.ri32 store.ri32a store.ri64 store.ri64a store.ri8
|
|
85
|
+
store.ri8a store.rjson store.ro store.rstr store.rta store.ru16
|
|
86
|
+
store.ru16a store.ru32 store.ru32a store.ru64 store.ru64a store.ru8
|
|
87
|
+
store.ru8a store.ru8ca store.seperated_dump store.underlying_bytsz store.wdv store.wf32
|
|
88
|
+
store.wf32a store.wf64 store.wf64a store.wi16 store.wi16a store.wi32
|
|
89
|
+
store.wi32a store.wi64 store.wi64a store.wi8 store.wi8a store.wjson
|
|
90
|
+
store.wo store.wstr store.wta store.wu16 store.wu16a store.wu32
|
|
91
|
+
store.wu32a store.wu64 store.wu64a store.wu8 store.wu8a store.wu8ca
|
|
92
|
+
|
|
93
|
+
store._data store._dv store._fl
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
APIS
|
|
97
|
+
=======
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
LICENSE
|
|
101
|
+
=======
|
|
102
|
+
- ISC
|
|
103
|
+
|
package/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const _path = require("path");
|
|
2
|
+
const _fs = require("fs");
|
|
3
|
+
const _mmap = require("nd-mmap2");
|
|
4
|
+
const _store = require("nv-buf-storage");
|
|
5
|
+
const _fl = require("nv-buf-free-list2");
|
|
6
|
+
|
|
7
|
+
module.exports = (
|
|
8
|
+
file_path = "./nvbuf.store.mmap",
|
|
9
|
+
init_max_alocable_sz=1024*1024*1024*128,
|
|
10
|
+
init_max_nd_cnt =2**26,
|
|
11
|
+
underlying_offset = 0,
|
|
12
|
+
underlying_sz = undefined,
|
|
13
|
+
huge_page_mode = undefined,
|
|
14
|
+
mmap_offset = undefined,
|
|
15
|
+
mmap_arg_addr = undefined
|
|
16
|
+
)=>{
|
|
17
|
+
file_path = _path.resolve(file_path);
|
|
18
|
+
if(_fs.existsSync(file_path)) {
|
|
19
|
+
var [cond,ab] = _mmap(file_path);
|
|
20
|
+
if(cond) {
|
|
21
|
+
return _store.load_non_scalable_from_external_ab(ab,underlying_offset,underlying_sz);
|
|
22
|
+
} else {
|
|
23
|
+
throw(ab);
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
var flsz = _fl._type.calc_fl_underlying_bytsz(init_max_alocable_sz,init_max_nd_cnt);
|
|
27
|
+
var datasz = init_max_alocable_sz;
|
|
28
|
+
var [cond,ab] = _mmap(file_path,flsz+datasz);
|
|
29
|
+
if(cond) {
|
|
30
|
+
return _store(init_max_alocable_sz,init_max_nd_cnt,false,{src:ab,offset:0},{src:ab,offset:flsz});
|
|
31
|
+
} else {
|
|
32
|
+
throw(ab);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
module.exports.show_underlying = (store)=>store._data.buffer.mm_info.show();
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nv-buf-storage-on-mmap",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
},
|
|
8
|
+
"author": "",
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"description": "",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"nd-mmap2": "^1.2.9",
|
|
13
|
+
"nv-buf-storage": "^2.1.0"
|
|
14
|
+
}
|
|
15
|
+
}
|