all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Lukas Wagner <l.wagner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 storage/proxmox{, -perl-rs} 0/7] cache storage plugin status for pvestatd/API status update calls
Date: Thu, 28 Sep 2023 13:50:05 +0200	[thread overview]
Message-ID: <20230928115012.326777-1-l.wagner@proxmox.com> (raw)

This patch series introduces a caching mechanism for expensive status
update calls made from pvestatd.

As a first step, I introduced the cache to the arguably
most expensive call, namely `storage_info` from pve-storage. Instead
of caching the results of the `storage_info` function as a whole, we
only cache the results from status updates from individual storage
plugins.

Regarding the cache implementation: I really tried it keep it as simple
as possible. Cached values are not queried terribly often and are
rather small, so I ended up with with simply creating a json-file per
cache key in a directory in tmpfs.

Changes from v1 -> v2:
  - Incorporated changes from the first review (thx @Wolfgang, thx @Max)
  - Made sure to invalidate the cache for storage plugin if necessary:
     - When changing storage config in some way
     - When allocating volumes
     - When uploading ISOs/Images (might change the amount of free space)
  - This allows to increase the expiration time - I've set it now to 60s
  - Added a flag to storage status API/CLI that allows one to ignore cached values,
    in case somebody needs up-to-date values at all cost (--ignore-cache)
  - Added functions that allow the user of proxmox-cache to lock cache entries
    (locking is accomplished using lock files and `flock`)
  - Added get_or_update helper - this one tries to get the cached value, and if 
    it does not exist/is expired computes the new value from a closure/function
    passed in as a parameter, all while holding the lock on the cache entry.
    Locking while updating the value eliminates possible race conditions if 
    multiple processes want to update the value at the same time.

Versions of this patch series:
  - v1: https://lists.proxmox.com/pipermail/pve-devel/2023-August/058806.html



proxmox:

Lukas Wagner (5):
  sys: fs: remove unnecessary clippy allow directive
  sys: fs: let CreateOptions::apply_to take RawFd instead of File
  sys: fs: use inline formatting for bail! macro
  sys: add make_tmp_dir
  cache: add new crate 'proxmox-shared-cache'

 Cargo.toml                                   |   1 +
 proxmox-shared-cache/Cargo.toml              |  18 +
 proxmox-shared-cache/debian/changelog        |   5 +
 proxmox-shared-cache/debian/control          |  53 ++
 proxmox-shared-cache/debian/copyright        |  18 +
 proxmox-shared-cache/debian/debcargo.toml    |   7 +
 proxmox-shared-cache/examples/performance.rs | 113 +++++
 proxmox-shared-cache/src/lib.rs              | 485 +++++++++++++++++++
 proxmox-shared-memory/src/lib.rs             |   4 +-
 proxmox-sys/src/fs/dir.rs                    |  76 ++-
 proxmox-sys/src/fs/file.rs                   |   4 +-
 proxmox-sys/src/fs/mod.rs                    |  15 +-
 12 files changed, 780 insertions(+), 19 deletions(-)
 create mode 100644 proxmox-shared-cache/Cargo.toml
 create mode 100644 proxmox-shared-cache/debian/changelog
 create mode 100644 proxmox-shared-cache/debian/control
 create mode 100644 proxmox-shared-cache/debian/copyright
 create mode 100644 proxmox-shared-cache/debian/debcargo.toml
 create mode 100644 proxmox-shared-cache/examples/performance.rs
 create mode 100644 proxmox-shared-cache/src/lib.rs


proxmox-perl-rs:

Lukas Wagner (1):
  cache: add bindings for `SharedCache`

 common/pkg/Makefile                  |  1 +
 common/pkg/Proxmox/RS/SharedCache.pm | 46 ++++++++++++++
 common/src/mod.rs                    |  1 +
 common/src/shared_cache.rs           | 89 ++++++++++++++++++++++++++++
 pve-rs/Cargo.toml                    |  1 +
 5 files changed, 138 insertions(+)
 create mode 100644 common/pkg/Proxmox/RS/SharedCache.pm
 create mode 100644 common/src/shared_cache.rs


pve-storage:

Lukas Wagner (1):
  stats: api: cache storage plugin status

 src/PVE/API2/Storage/Config.pm  | 18 +++++++
 src/PVE/API2/Storage/Content.pm | 15 ++++++
 src/PVE/API2/Storage/Status.pm  | 38 ++++++++++++++-
 src/PVE/Storage.pm              | 84 ++++++++++++++++++++++++---------
 4 files changed, 131 insertions(+), 24 deletions(-)


Summary over all repositories:
  21 files changed, 1049 insertions(+), 43 deletions(-)

-- 
murpp v0.4.0





             reply	other threads:[~2023-09-28 11:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28 11:50 Lukas Wagner [this message]
2023-09-28 11:50 ` [pve-devel] [PATCH v2 proxmox 1/7] sys: fs: remove unnecessary clippy allow directive Lukas Wagner
2023-09-28 11:50 ` [pve-devel] [PATCH v2 proxmox 2/7] sys: fs: let CreateOptions::apply_to take RawFd instead of File Lukas Wagner
2023-09-28 11:50 ` [pve-devel] [PATCH v2 proxmox 3/7] sys: fs: use inline formatting for bail! macro Lukas Wagner
2023-09-28 11:50 ` [pve-devel] [PATCH v2 proxmox 4/7] sys: add make_tmp_dir Lukas Wagner
2023-09-28 11:50 ` [pve-devel] [PATCH v2 proxmox 5/7] cache: add new crate 'proxmox-shared-cache' Lukas Wagner
2023-09-28 11:50 ` [pve-devel] [PATCH v2 proxmox-perl-rs 6/7] cache: add bindings for `SharedCache` Lukas Wagner
2023-09-28 11:50 ` [pve-devel] [PATCH v2 pve-storage 7/7] stats: api: cache storage plugin status Lukas Wagner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230928115012.326777-1-l.wagner@proxmox.com \
    --to=l.wagner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal