npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yuuza/btrdbfs

v1.0.4

Published

Run a filesystem on btrdb!

Downloads

1

Readme

btrdbfs - btrdb FileSystem

Run a filesystem on btrdb!

btrdbfs implements FUSE filesystem using Node.js with the binding fuse-native.

Implemented operations

  • [x] create, open, mkdir, release
  • [x] readdir, getattr
  • [x] read, write
  • [x] chmod, chown, utimens, truncate
  • [x] unlink, rmdir, rename
  • [x] statfs
  • [x] link, symlink

Tested workloads

  • [x] copy/make some large files
  • [x] clone btrdb: git clone btrdb
  • [x] build btrdb: pnpm i && pnpm run build
  • [x] git clone and build MusicCloud, build and run its server
  • [x] run btrdbfs on btrdbfs and do things above

Performance

About 50 MB/s sequential read/write on i5-3320M with big_writes option.

$ dd if=/dev/zero of=mnt/zeros bs=1M status=progress
893386752 bytes (893 MB, 852 MiB) copied, 15 s, 59.6 MB/s^C
853+0 records in
853+0 records out
894435328 bytes (894 MB, 853 MiB) copied, 15.0697 s, 59.4 MB/s
$ dd if=mnt/bigfile of=/dev/null bs=1M status=progress
1083179008 bytes (1.1 GB, 1.0 GiB) copied, 22 s, 49.2 MB/s
1078+0 records in
1078+0 records out
1130364928 bytes (1.1 GB, 1.1 GiB) copied, 22.9497 s, 49.3 MB/s

The bottleneck is the CPU. Since both btrdb and btrdbfs are running on JS engine, the performance is better than my expectation.

The btrdb never do random write on the database file. For this reason, btrdbfs will have great random write performance on HDD.

Try it now

Install btrdbfs on your Linux OS:

npm install -g @yuuza/btrdbfs

Mount the btrdbfs:

mkdir mnt
btrdbfs myfs.db mnt

Design

Using three document sets for inodes, links and extents.

Inodes

/**
 * @typedef {Object} Inode
 * @property {number} id
 * @property {number} kind - KIND_*
 * @property {number} size
 * @property {number} ct - ctime
 * @property {number} at - atime
 * @property {number} mt - mtime
 * @property {number} mode
 * @property {number} uid
 * @property {number} gid
 * @property {string} ln - symlink
 */

const inodes = await db.createSet("inodes", "doc");

Links

For links, use "paid" index to get all links under the directory on readdir(), and use "paid_name" index to find a link with specific name under the specific directory when finding an link from path string.

/**
 * @typedef {Object} Link
 * @property {number} id
 * @property {number} ino
 * @property {number} paid - parent dir inode
 * @property {string} name
 */
const links = await db.createSet("links", "doc");
await links.useIndexes({
  "paid": (x) => x.paid,
  "paid_name": (x) => x.paid + "_" + x.name,
});

Extents

Each "Extent" document saving a Uint8array as the extent data. The "ino_pos" index is used to find an extent of an inode.

/**
 * @typedef {Object} Extent
 * @property {number} id
 * @property {number} ino - inode id
 * @property {number} pos
 * @property {Uint8Array} data
 */

const EXTENT_SIZE = 4 * 4096;

const extents = await db.createSet("extents", "doc");
extents.useIndexes({
  "ino_pos": (x) => x.ino + "_" + x.pos,
});