Skip to contentSkip to conversation

Improvements around PERSISTENT_DIR

PATCH In review Antonin Godard 3 participants 10 messages Jul 9, 2025 – Jul 15, 2025

lore
Share & tools
lore
#0 lore raw

cover Improvements around PERSISTENT_DIR

The PERSISTENT_DIR directory should be shared along the sstate cache to ensure that the hash equivalence database is also shared. Otherwise this can result in bugs described in YOCTO #15921 [1].

[1]: https://bugzilla.yoctoproject.org/show_bug.cgi?id=15921

---
Antonin Godard (4):
test-manual/understand-autobuilder.rst: mention hashequiv server ref-manual/structure.rst: update with info on PERSISTENT_DIR dev-manual/start.rst: mention that PERSISTENT_DIR should be shared too overview-manual/concepts.rst: mention PERSISTENT_DIR for user configuration

 documentation/dev-manual/start.rst                   |  5 +++++
 documentation/overview-manual/concepts.rst           |  3 +++
 documentation/ref-manual/structure.rst               | 14 +++++++++++++-
 documentation/test-manual/understand-autobuilder.rst |  6 ++++++
 4 files changed, 27 insertions(+), 1 deletion(-)

---
base-commit: 80084a4cabdf7f61c7e93eda8ddbd5bc7d54e041
change-id: 20250708-update-sstate-dir-docs-8763b1387ff5

Best regards,

Signature · 1 line
Antonin Godard <[email protected]>
#1 lore raw

PATCH 1/4 test-manual/understand-autobuilder.rst: mention hashequiv server

The autobuilder also uses a shared Hash Equivalence server, so mention it here too.

---
 documentation/test-manual/understand-autobuilder.rst | 6 ++++++
 1 file changed, 6 insertions(+)
documentation/test-manual/understand-autobuilder.rst +6 -0
index 7f4d1be3c..23b3ef7d7 100644
@@ -184,6 +184,12 @@ directory to be shared between them. This means once a Worker has built
 an artifact, all the others can benefit from it. The usage of the directory
 within the build system is designed for sharing over NFS.
 
+Shared Hash Equivalence Server
+------------------------------
+
+The Workers all use the same Hash Equivalence server, through a common
+definition for :term:`BB_HASHSERVE`.
+
 Resulttool
 ----------
 
Signature · 1 line
2.50.0
#2 lore raw

PATCH 2/4 ref-manual/structure.rst: update with info on PERSISTENT_DIR

In reply to Antonin Godard

Since we mention that SSTATE_DIR can be shared for multiple builds, also mention that PERSISTENT_DIR should be shared alongside SSTATE_DIR.

[YOCTO #15921]

---
 documentation/ref-manual/structure.rst | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
documentation/ref-manual/structure.rst +13 -1
index d6dbb2940..e4e800def 100644
@@ -246,7 +246,8 @@ section in the Yocto Project Development Tasks Manual.
 ----------------
 
 This directory contains several internal files used by the OpenEmbedded
-build system.
+build system. The path to this directory is defined by the
+:term:`PERSISTENT_DIR` variable.
 
 It also contains ``sanity_info``, a text file keeping track of important
 build information such as the values of :term:`TMPDIR`, :term:`SSTATE_DIR`,
@@ -364,6 +365,13 @@ directory for multiple builds or move the directory to another location.
 You can control the location of this directory through the
 :term:`SSTATE_DIR` variable.
 
+.. note::
+
+   If you are sharing the :term:`SSTATE_DIR` directory for multiple builds and
+   you are using a :doc:`/overview-manual/concepts:Hash Equivalence` server with
+   :term:`BB_HASHSERVE` you should also share the :term:`PERSISTENT_DIR`
+   directory. See :ref:`structure-build-cache` below.
+
 .. _structure-build-tmp:
 
 ``build/tmp/``
@@ -403,6 +411,10 @@ modification time (mtime) changes and hashing of file contents. If no
 changes to the file are detected, then the parsed result stored in the
 cache is reused. If the file has changed, it is reparsed.
 
+This directory and the :term:`SSTATE_DIR` directory can be shared for multiple
+builds when using a :doc:`/overview-manual/concepts:Hash Equivalence` server
+with :term:`BB_HASHSERVE`.
+
 .. _structure-build-tmp-deploy:
 
 ``build/tmp/deploy/``
Signature · 1 line
2.50.0
#3 lore raw

Re: [docs] [PATCH 2/4] ref-manual/structure.rst: update with info on PERSISTENT_DIR

Quoted 3 lines · Antonin Godard via lists.yoctoproject.org

Since we mention that SSTATE_DIR can be shared for multiple builds, also mention that PERSISTENT_DIR should be shared alongside SSTATE_DIR.

NO. These changes are incorrect, please do not merge or revert if already merged.

PERSISTENT_DIR can be copied from one build directory to another when bitbake is not running, but it cannot be shared between two active builds.

If one wants to share sstate, they either have to setup a hash equivalence server (and then sharing PERSISTENT_DIR is not needed), or disable hash equivalency (in which case it is also not needed).

Alex

#4 lore raw

Re: [docs] [PATCH 2/4] ref-manual/structure.rst: update with info on PERSISTENT_DIR

Quoted 9 lines · Alexander Kanavin via lists.yoctoproject.org
Quoted 3 lines · Antonin Godard via lists.yoctoproject.org

Since we mention that SSTATE_DIR can be shared for multiple builds, also mention that PERSISTENT_DIR should be shared alongside SSTATE_DIR.

NO. These changes are incorrect, please do not merge or revert if already merged.

Quoted 7 lines

PERSISTENT_DIR can be copied from one build directory to another when bitbake is not running, but it cannot be shared between two active builds.

If one wants to share sstate, they either have to setup a hash equivalence server (and then sharing PERSISTENT_DIR is not needed), or disable hash equivalency (in which case it is also not needed).

The changes did merge and definitely are unclear.

The point is that if you share sstate, you also need to have common hash equivalence data.

That may be via having common hashequiv server, or, of you have a local sstate directory and delete the build directory, you need to preserve the hashequiv database file to make the sstate useful.

You cannot have a common PERSISTENT_DIR shared by two builds, that is not supported.

Hopefully Antonin can tweak things to make this all clearer. I should have caught this, sorry :/

Cheers,

Richard

#5 lore raw

Re: [docs] [PATCH 2/4] ref-manual/structure.rst: update with info on PERSISTENT_DIR

Quoted 27 lines · Richard Purdie
Quoted 9 lines · Alexander Kanavin via lists.yoctoproject.org
Quoted 3 lines · Antonin Godard via lists.yoctoproject.org

Since we mention that SSTATE_DIR can be shared for multiple builds, also mention that PERSISTENT_DIR should be shared alongside SSTATE_DIR.

NO. These changes are incorrect, please do not merge or revert if already merged.

Quoted 7 lines

PERSISTENT_DIR can be copied from one build directory to another when bitbake is not running, but it cannot be shared between two active builds.

If one wants to share sstate, they either have to setup a hash equivalence server (and then sharing PERSISTENT_DIR is not needed), or disable hash equivalency (in which case it is also not needed).

The changes did merge and definitely are unclear.

The point is that if you share sstate, you also need to have common hash equivalence data.

That may be via having common hashequiv server, or, of you have a local sstate directory and delete the build directory, you need to preserve the hashequiv database file to make the sstate useful.

Quoted 5 lines

You cannot have a common PERSISTENT_DIR shared by two builds, that is not supported.

Hopefully Antonin can tweak things to make this all clearer. I should have caught this, sorry :/

Hi all,

Sorry! I drew a wrong conclusion from bug #15921, I will correct this soon this week.

Alex, thanks for catching this.

Antonin

Signature · 3 lines
Antonin Godard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#6 lore raw

PATCH 3/4 dev-manual/start.rst: mention that PERSISTENT_DIR should be shared too

In reply to Antonin Godard

In the "Development environment summary", we mention that the shared state dir can be shared for developers, but PERSISTENT_DIR should be shared as well, otherwise bugs described in [1] can happen.

[1]: https://bugzilla.yoctoproject.org/show_bug.cgi?id=15921

[YOCTO #15921]

---
 documentation/dev-manual/start.rst | 5 +++++
 1 file changed, 5 insertions(+)
documentation/dev-manual/start.rst +5 -0
index 44bd2de13..1c3f87ea9 100644
@@ -228,6 +228,11 @@ particular working environment and set of practices.
        used by developers in the same organization and share the same
        source directories on their machines.
 
+       If the :term:`SSTATE_DIR` directory is shared for multiple developers,
+       and you are using a :doc:`/overview-manual/concepts:Hash Equivalence`
+       server with :term:`BB_HASHSERVE`, the :term:`PERSISTENT_DIR` directory
+       (``${TOPDIR}/cache`` by default) should be shared too.
+
     -  Set up an Autobuilder and have it populate the sstate cache and
        source directories.
 
Signature · 1 line
2.50.0
#7 lore raw

Re: [docs] [PATCH 3/4] dev-manual/start.rst: mention that PERSISTENT_DIR should be shared too

documentation/dev-manual/start.rst particular working environment and set of practices. · line 234

Quoted 4 lines · Antonin Godard via lists.yoctoproject.org
documentation/dev-manual/start.rst +4 -0
+       If the :term:`SSTATE_DIR` directory is shared for multiple developers,
+       and you are using a :doc:`/overview-manual/concepts:Hash Equivalence`
+       server with :term:`BB_HASHSERVE`, the :term:`PERSISTENT_DIR` directory
+       (``${TOPDIR}/cache`` by default) should be shared too.

Same as patch 2: incorrect, do not merge.

Alex

#8 lore raw

PATCH 4/4 overview-manual/concepts.rst: mention PERSISTENT_DIR for user configuration

In reply to Antonin Godard

The PERSISTENT_DIR directory can also be customized to be shared, so mention it in the list of configuration variables in local.conf.

---
 documentation/overview-manual/concepts.rst | 3 +++
 1 file changed, 3 insertions(+)
documentation/overview-manual/concepts.rst +3 -0
index b34de4d36..99a8f02a0 100644
@@ -277,6 +277,9 @@ in the ``meta-poky`` layer:
 -  *Shared State Directory:* Controlled by the
    :term:`SSTATE_DIR` variable.
 
+-  *Persistent Data Directory:* Controlled by the
+   :term:`PERSISTENT_DIR` variable.
+
 -  *Build Output:* Controlled by the
    :term:`TMPDIR` variable.
 
Signature · 1 line
2.50.0
#9 lore raw

Re: [docs] [PATCH 4/4] overview-manual/concepts.rst: mention PERSISTENT_DIR for user configuration

Quoted 2 lines · Antonin Godard via lists.yoctoproject.org

The PERSISTENT_DIR directory can also be customized to be shared, so mention it in the list of configuration variables in local.conf.

No. PESISTENT_DIR should never ever be shared.

Alex