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
- Download this repo, copy the
pcvis/pcvis.py
from this repo - 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:
- the black blocks indicate the part of the file that is in the page cache
- this file's header and footer are accessed and loaded in page cache
- 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 launchpcstat
automatically and visualize the result. If this argument is not specified,pcvis
will read the output ofpcstat
fromstdin
, 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 is0
. Some sample styles are shown below:- e.g.
pcvis -s 24
🌕🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌕🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌕🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌕🌑🌑🌑🌑🌑🌑🌑🌑🌑🌕🌑🌑🌑🌑🌕🌑🌕🌑🌕🌕🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌕 - e.g.
pcvis -s 17
💚🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍💚🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍💚🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍💚🤍🤍🤍🤍🤍🤍🤍🤍🤍💚🤍🤍🤍🤍💚🤍💚🤍💚💚🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍💚
- e.g.
-
-i
or--install-pcstat
: install pcstat to your system. By default, pcstat is installed into /usr/local/bin. You can specifyPCVIS_PCSTAT_PATH
env var to alter the default install dir. e.g.PCVIS_PCSTAT_PATH=/usr/bin pcvis -i
-
-v
or--version
: show version (only available if you install viapip
) -
-h
or--help
: show help message
examples
- Visualize all csv files' page cache
find . -iname "*.csv" | xargs pcvis -f
- Install
pcstat
automatically into/usr/local/bin
pcvis --install-pcstat
notes
- 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
- 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"
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
Built Distribution
File details
Details for the file pcvis-0.5.1.tar.gz
.
File metadata
- Download URL: pcvis-0.5.1.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de787a8d5625e56e73c9a98d53ff57e85f9f9f6aef869b2160912c6c1e77d580 |
|
MD5 | 51a33e21a0859a205d761061ab57befc |
|
BLAKE2b-256 | f286dfbb8bf407c62cdb07beed6602449fd45cf8656b689b29e6abeeac8a9bc8 |
File details
Details for the file pcvis-0.5.1-py3-none-any.whl
.
File metadata
- Download URL: pcvis-0.5.1-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c361a1da756e14666db4f3441ac934ea1b4b847e468a580d9078db5d4b4db92c |
|
MD5 | d555663d0a6aeeb7a0649bc130a5915f |
|
BLAKE2b-256 | 7231c9ac4164b9616ec7735c245ca9bf8cc5ea35eee2010a2ca266418fa861fc |