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-pcstatto 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.pyfrom this repo - Move
pcvis.pyinto 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
-
-for--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,pcviswill launchpcstatautomatically and visualize the result. If this argument is not specified,pcviswill read the output ofpcstatfromstdin, e.g.pcstat -json -pps /path/to/my_file | pcvis -
-sor--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 3🌕🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌕🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌕🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌕🌑🌑🌑🌑🌑🌑🌑🌑🌑🌕🌑🌑🌑🌑🌕🌑🌕🌑🌕🌕🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌑🌕 - e.g.
pcvis -s 4💚🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍💚🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍💚🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍💚🤍🤍🤍🤍🤍🤍🤍🤍🤍💚🤍🤍🤍🤍💚🤍💚🤍💚💚🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍🤍💚
- e.g.
-
-ior--install-pcstat: install pcstat to your system. By default, pcstat is installed into /usr/local/bin. You can specifyPCVIS_PCSTAT_PATHenv var to alter the default install dir. e.g.PCVIS_PCSTAT_PATH=/usr/bin pcvis -i -
-lor--list: list all styles available -
-vor--version: show version (only available if you install viapip) -
-hor--help: show help message
examples
- Visualize all csv files' page cache
find . -iname "*.csv" | xargs pcvis -f
- Install
pcstatautomatically into/usr/local/bin
pcvis --install-pcstat
- List all available styles
pcvis --list
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"
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pcvis-0.6.1.tar.gz.
File metadata
- Download URL: pcvis-0.6.1.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.9 Darwin/23.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
859bd5ee37e1b78d3605557b670c9001e659750c610ded8a188c2ced5a29d21a
|
|
| MD5 |
f7f4c4f0d487deb604d6dc6f059b59f5
|
|
| BLAKE2b-256 |
e3b65a13ae73697b8c74f1b9a2a6730e51adcfc12a1c77d95a43dc4a0592e6f2
|
File details
Details for the file pcvis-0.6.1-py3-none-any.whl.
File metadata
- Download URL: pcvis-0.6.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.9 Darwin/23.0.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4d69bfd1be76363978484aa420a96ed8f48ace8558b1d46fdf41cd3e20fe476
|
|
| MD5 |
42ff7e670e9d35dfe5ea98d7ba46e137
|
|
| BLAKE2b-256 |
fc7cea47604538c2c8f3b3cc430945167aedc70cf9971b69fdd6a5056219d73c
|