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

hive-fs

v1.0.0

Published

H.I.V.E - fs ------------

Downloads

5

Readme

H.I.V.E - fs

hive-fs 是一个用 CoffeeScript 写的 基于索引和偏移量 的文件系统.

原本是针对我的毕业设计 Archangel 而设计实现的, Leviathan 内部组件之一, 用于在多个 Nero-Kodiak 集群节点之间/内部同步 Gateway 的核心数据块(配置信息), 也同样适用于一些其他基础层面的同步服务.

架构

Slot 索引

Tuple 结构

Cell 结构

块缓冲 & 回写

资源管理

空闲表

Slot 回收与重用

分配不定长 Cell

资源限制(参数待调优)

lib/constants.coffee:

# cell
# KEYSIZE: 32B # Cell 中每个 key 的最大字节长度, ('idx' 不存储)
BYTESIZE: 4B # 存储 Cell 中每个 value 的最大字节长度, 即标准 4 字节整型长度
# freelst
UNITSIZE: 5B # 空闲表中每条记录的最大字节长度, 包括: 4 字节的整数表示空闲 slot 的起始 seek 位置, 1 字节的整数表示连续块数量
# seek index
TUPLESIZE: 270B # seek-index 表中每条记录的最大字节长度, 包括: 1 字节的整数表示该 tuple 是否空闲, 4 字节的整数表示某个 Cell 的起始 seek 位置, 1 字节的整数表示连续块数量, 8 字节存储时间戳, 剩余 256 字节是索引占用的最大字节长度.
BLKSIZE: 1KB # 每个 Slot 块的标准大小

示例 && API

{Hive} = require './'

# Hive 配置(可选)
cfg =
  rw: yes
  dirname: '/dev/shm'
  basename: 'hive-fs'

data =
  idx: 'github:abbshr' # 必须字段
  ts: Date.now() # 必须字段
  name: 'Ran Aizen'
  id: 1237104
  activeDay: [1,3,5,7,9]
  following: ['@_the_flash', '@_batman', '@_the_arrow', '@_superman']

hive = new Hive cfg
# 申请 slots, 并构造一个 cell 来写数据
hive.write data, (err) ->
# 跳至索引记录的 slot 偏移量, 从 buffer 构建 cell
hive.seek 'github:abbshr', (err, cell) ->
# 释放一个 cell
hive.free 'github:abbshr', (err) ->
# 关闭 hive
hive.close (err) ->

建议: 配合共享内存以进一步提升性能.