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

@staltz/binary-tests

v1.0.0

Published

Hey everyone. Now is time to tell you all, I've been somewhat secretly working on a better database. Not _secret_ secret, but I havn't been talking about my plans. mainly so I could enjoy working on it without the weight of expectations as to why it's tak

Downloads

3

Readme

a much faster database!

Hey everyone. Now is time to tell you all, I've been somewhat secretly working on a better database. Not secret secret, but I havn't been talking about my plans. mainly so I could enjoy working on it without the weight of expectations as to why it's taking so long ;)

The first commit to a key part of this, Normalized Index, was August 17, 2016. I recall I was staying on @mikey's couch at the time. Flumedb itself was also part of this effort, but that's been deployed for a while. This is now the rest of the ideas I had, about ready to be rolled out.

tl;dr - it's faster, and uses significantly less memory. indexes are way smaller, and just as fast. It's still written in javascript, in fact, it's written entirely in javascript.

components

The core idea in flumedb, is that the main storage is a log file, referenced by the byte offset. views, such as indexes, point back into this. I've been rethinking various aspects of the system, and just this weekend, I've been finally fitting them together.

flumelog-aligned-offset

This is basically the same ideas as flumelog-offset, but a better implementation that doesn't have the performance problems flumelog-offset had. It's also built on top of dat's random-access-file, for hopefully easy browser support, and better collaboration with dat!

bipf (binary in place format)

As it turned out, JSON parsing is really quite slow. It's not just the parsing it self, but also it's allocating the js objects, which also use a lot more memory than their serializations. However, you can have a format designed for use without parsing. Meaning, a format optimized for finding a particular value and pulling it out, without looking at every field in the whole object. databases queries mostly will only look at one or two fields, compare that to something then throw it away or write to IO. There are many binary json replacements, but very few of them are intended for in-place use. I implemented one, and was really quite suprised how fast it was. Combined with a better flumelog, this actually makes it possible to do queries by reading every value in the database!

normalized-index

normalized-index takes the idea of indexes that are just pointers to it's logical extreme - it's a log-structured-merge tree, like leveldb. A "log-structured merge tree" is essentially a reordering of the database, from some particular perspective, with a clever way to merge sections you've already ordered together. We are already using a LSMT in level, but because leveldb isn't aware of flume, it needs to store keys in level, and that makes the level indexes quite large. normalized-index doesn't store keys at all, only pointers. Currently, the indexes for ssb-query (using level) are 99 mb (on my machine) the same indexes created with normalized-index are only 20 mb. Using bipf and flumelog-aligned-offset, a normalized-index builds a little faster than the same index did with level using json. Query time is about the same, fast enough, but index size is much better.

That means potentially, we can have way more indexes, the main constraint here being to avoid increasing indexing time.

demonstration

I havn't rolled this into scuttlebutt yet, but I have scripts that demonstate it all in action.

clone this repo, npm install then,

node init.js # copy your .ssb/flume/log.offset file into bipf format.
node indexes.js # generate indexes using normalized-index
node query.js # run a default query on top of those indexes.

node query.js --query '{QUERY}' # run a custom query, in map-filter-reduce json format.

todo

  • gather feedback
  • rewrite flumeview-reduces to benefit from bipf.
  • lazy indexes.
  • map-filter-reduce directly on bipf format, so no parsing ever.
  • bikeshed best design for bipf.

future work

This would suit being reimplemented in C. Likely this would make it even faster. The simple way to evaluate that would implement bipf in C, then flumelog-aligned, then compare scan perf.

Investigate how much performance we can hope for on mobile, or in browsers.

License

MIT