fakelib

command module
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2024 License: MIT Imports: 8 Imported by: 0

README

fakelib

API reference Test LICENSE

fakelib is a tool for generating massive music libraries for testing purposes. It was originally created as part of the ashuffle project to test the performance of ashuffle.

Install:

go install github.com/joshkunz/fakelib@latest

Why?

ashuffle's users often had libraries in the 10s to 100s of thousands of songs. Since ashuffle had to track a user's library, there were performance issues scaling to these massive numbers of tracks. Since ashuffle did not interact with the libraries directly (instead it queried MPD), the libraries used during testing had to be real, valid, MP3s with correct metadata.

The first approach at generating large libraries was to generate a "golden" MP3, copy it several thousand times, and update the metadata accordingly. This worked, but was painful to scale past the low 10s of thousands of songs. Additionally this approach had substantial drawbacks. First, it took almost an hour to generate, since it was limited to disk throughput. It also consumed a large amount of space (nearly 500MB for 20k tracks). This made it expensive and slow to ship around to test infrastructure. Worst of all, even with those drawbacks, the libraries it generated were still much smaller than some users libraries.

fakelib is an attempt to generate much larger libraries. fakelib can easily generate a fake library with a million tracks in seconds. fakelib is similar in concept to copying an MP3 several thousand times and updating the metadata, however, it's much more efficient. Instead of actually doing the copies fakelib implements a FUSE filesystem. When mounted this filesystem appears as a large music library. When a program tries to read one of the MP3s in the library, fakelib generates tag information and responds with the bytes of the generated tag. Once the tag has been read, later reads in the file go directly to a "golden" MP3's audio data. This means that the library is functionally a large library of tracks with unique metadata, and exactly the same audio data. The "golden" MP3 is never copied.

Running

Once you have a golden MP3, you can run fakelib to mount the fake library file system, and then use it as normal:

$ mkdir test
$ fakelib ./test/
With a Custom Golden MP3

fakelib works based on a "golden" MP3. This MP3 will be used as the actual audio content for the virtual songs. If for whatever the built-in golden MP3 is not sufficient (e.g. you want a longer MP3) you can use provide a custom golden MP3 as the first argument:

$ fakelib gold.mp3 ./test/

Any MP3 should work, but one good way to generate a short empty MP3 is using ffmpeg. This is ideal for testing since it takes up very little space:

$ SECONDS=5
$ ffmpeg -f lavfi -i anullsrc=r=44100:cl=mono -t $SECONDS -q:a 9 -acodec libmp3lame gold.mp3

As a Library

fakelib can also be used as a library. See the documentation for details.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package filesystem provides a FUSE filesystem that can be used to mount a fake library to a particular filesystem path.
Package filesystem provides a FUSE filesystem that can be used to mount a fake library to a particular filesystem path.
Package library provides the core implementation of `fakelib`.
Package library provides the core implementation of `fakelib`.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL