Skip to main content

2022-12-12

Project description

pcvis

A command line tool for visualizing page cache status of given files

prerequisites

  • install pcstat (Page Cache stat: get page cache stats for files, https://github.com/tobert/pcstat)
    • it has both Linux and macOS binaries since v0.0.1
    • if you are using Linux/macOS, you can skip this step and use pcvis --install-pcstat to install it automatically

installation

via pip

pip install pcvis

After installation, there will be a command called pcvis you can use

manual

  1. Download this repo, copy the pcvis/pcvis.py from this repo
  2. Move pcvis.py into your $PATH (e.g. /usr/local/bin)
mv pcvis.py /usr/local/bin/pcvis
chmod +x /usr/local/bin/pcvis

usage

Visualize a given file's page cache status like below:

# pcstat still needs to be installed, and it will be automatically launched by pcvis
pcvis -f /path/to/my_file

sample outputs

█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█░░░░░░░░░░░░░░░░░░░░█░░░░░░░░░█░░░░█░█░██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█

Via this visualization, you can easily spot that:

  1. the black blocks indicate the part of the file that is in the page cache
  2. this file's header and footer are accessed and loaded in page cache
  3. this file is accessed in a random access manner, and you may even vaguely check if the random access is a binary search, etc

arguments

  • -f or --file: the path to the file(s) you want to visualize its page cache status, e.g. pcvis -f /path/to/foo_file /path/to/bar_file. If you specify this argument, pcvis will launch pcstat automatically and visualize the result. If this argument is not specified, pcvis will read the output of pcstat from stdin, e.g. pcstat -json -pps /path/to/my_file | pcvis

  • -s or --style: there are over 20 different rendering styles to choose from, you can specify a custom style by passing an integer to this argument. The default style is 0. Some sample styles are shown below:

    • e.g. pcvis -s 3 🌕🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌕🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌕🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌕🌑🌑🌑🌑🌑🌑🌑🌑🌑🌕🌑🌑🌑🌑🌕🌑🌕🌑🌕🌕🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌕
    • e.g. pcvis -s 4 💚🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍💚🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍💚🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍💚🤍🤍🤍🤍🤍🤍🤍🤍🤍💚🤍🤍🤍🤍💚🤍💚🤍💚💚🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍💚
  • -i or --install-pcstat: install pcstat to your system. By default, pcstat is installed into /usr/local/bin. You can specify PCVIS_PCSTAT_PATH env var to alter the default install dir. e.g. PCVIS_PCSTAT_PATH=/usr/bin pcvis -i

  • -l or --list: list all styles available

  • -v or --version: show version (only available if you install via pip)

  • -h or --help: show help message

examples

  1. Visualize all csv files' page cache
find . -iname "*.csv" | xargs pcvis -f
  1. Install pcstat automatically into /usr/local/bin
pcvis --install-pcstat
  1. List all available styles
pcvis --list

notes

  1. If you are doing database kernel development and would like to verify IO access pattern for your files, before running the above command for visualization, you may need to clean page cache up front so that such result clearly show the IO access pattern each time
# for linux
sync; echo 1 > /proc/sys/vm/drop_caches 

# for macOS
sudo purge
  1. Some of the icons in the visualization requires UTF8 to render, so you may need to set locale to UTF8 under some systems
export LC_ALL="en_US.utf8"

Otherwise, errors like 'ascii' codec can't encode character u'\xa0' in position 20: ordinal not in range(128) may be reported.

Alternatively, you may try using some ASCII only style like pcvis -s 1 -f /path/to/file to avoid such issue.

development

run tests

poetry run pytest

install dev revision locally

make setup

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pcvis-0.6.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

pcvis-0.6.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file pcvis-0.6.0.tar.gz.

File metadata

  • Download URL: pcvis-0.6.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for pcvis-0.6.0.tar.gz
Algorithm Hash digest
SHA256 9299dc1be7263a1432c8b9b08d11e9664d1a5d761231f7018d5c618aa56bd7bc
MD5 fc1611892a5d1628055c4b22e1da0574
BLAKE2b-256 4f05e61af3362986ba2298a151ff84127b2a4033130272d706e0de2cfa357616

See more details on using hashes here.

File details

Details for the file pcvis-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: pcvis-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for pcvis-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 821bf03b6453fe98cfec9a81f18a4c52bac39218d611f79eb5230ed419c10299
MD5 f241c33b625d34df237b541bf17bebab
BLAKE2b-256 a156f6f91c2c26aa7c97700f7bab7d40a6178df826a149138158dade996980a2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page