Skip to content

Commit

Permalink
Remove mmap-io which constantly causing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sileix committed Mar 30, 2022
1 parent 77295b4 commit 8e83a6a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 61 deletions.
20 changes: 1 addition & 19 deletions lib/prediction/exact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,7 @@ export default class ExactMatcher {
}

async load(filename : string) {
let buffer;
try {
const mmap = (await import('mmap-io')).default;
const fd = await pfs.open(filename, 'r');
const stats = await fd.stat();
buffer = mmap.map(Math.ceil(stats.size / mmap.PAGESIZE) * mmap.PAGESIZE,
mmap.PROT_READ, mmap.MAP_SHARED | mmap.MAP_POPULATE, fd.fd, 0, mmap.MADV_RANDOM);

// we created the mapping, so we can close the file and remove it - the kernel
// keeps a reference to it
// at the next load, we'll overwrite _btrie, which will cause the buffer to go unreferenced
// later, the GC will release buffer, unmap it, and _only then_ will the file actually be
// closed and deleted
await fd.close();
} catch(e) {
if (e.code !== 'MODULE_NOT_FOUND')
throw e;
buffer = await pfs.readFile(filename);
}
const buffer = await pfs.readFile(filename);
this._btrie = new BTrie(buffer);

// assume that the binary file contains all modifications made afterwards, and clear the trie
Expand Down
41 changes: 0 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"js-yaml": "^4.1.0",
"lice-js": "^0.2.0",
"mime": "^3.0.0",
"mmap-io": "^1.1.7",
"morgan": "^1.9.1",
"node-gettext": "^3.0.0",
"nodemailer": "^6.7.2",
Expand Down

0 comments on commit 8e83a6a

Please sign in to comment.