Skip to content

Workspaced element's cache keys are calculated 4 times during a build

When you run bst build on a workspaced element, the cache key of this element is effectively calculated 4 time.

To reproduce this issue:

  1. Create an empty buildstream project
  2. Add an element that just import a dummy folder or file
  3. Apply, the following diff to get cache key specific outputs
  4. Open a workspace on the created element
  5. bst build --debug the element

You should see something similar to

root@e9568cd70324:/src/integration_candidate# bst --debug build project_0.bst 
DEBUG: Early enablement of messages
Loading:   001
[pid:11    id:001][--:--:--][        ][ main:project_0.bst                 ] DEBUG   Created: import element at project_0.bst [line 1 column 0]
[pid:11    id:002][--:--:--][        ][ main:project_0.bst-0               ] DEBUG   Created: local source at project_0.bst [line 8 column 4]

[project_0.bst] Recalculating cache keys
[pid:11    id:002][--:--:--][        ][ main:project_0.bst-0               ] DEBUG   get_workspace_key called : 248b7c61-5d77-42a3-806b-9b286ad4e85f
[pid:11    id:002][--:--:--][        ][ main:project_0.bst-0               ] DEBUG   get_workspace_key called : 9b11dcf4-cb13-4a06-ab2a-99cf0720eab9
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74

[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74

BuildStream Version 1.0
  Session Start: Thursday, 30-11-2017 at 18:04:58
  Project:       dummy_ic (/src/integration_candidate)
  Targets:       project_0.bst

User Configuration
  Configuration File:      Default Configuration
  Log Files:               /root/.cache/buildstream/logs
  Source Mirrors:          /root/.cache/buildstream/sources
  Build Area:              /root/.cache/buildstream/build
  Artifact Cache:          /root/.cache/buildstream/artifacts
  Maximum Fetch Tasks:     10
  Maximum Build Tasks:     4
  Maximum Push Tasks:      4
  Maximum Network Retries: 2

Pipeline
   buildable 5a56ee9e project_0.bst Workspaces: /src/integration_candidate/prj

[pid:11    id:000][--:--:--] START   Starting build
======================================================================================================================================================================== 00:00:00 dummy_ic (1/1) ========================================================================================================================================================================
                                                                                                                                                                      (Fetched:0 1 0)→ (Built:0 0 0)                                                                                                                                                                      
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[pid:18    id:001][--:--:--][5a56ee9e][build:project_0.bst  ] START   dummy_ic/project_0/5a56ee9e-build.18.log
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[pid:18    id:001][--:--:--][5a56ee9e][build:project_0.bst  ] START   Staging sources
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[pid:18    id:001][00:00:00][5a56ee9e][build:project_0.bst  ] SUCCESS Staging sources
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[pid:18    id:001][--:--:--][5a56ee9e][build:project_0.bst  ] DEBUG   [project_0.bst] Force cache key calculation
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[pid:18    id:002][--:--:--][5a56ee9e][build:project_0.bst  ] DEBUG   get_workspace_key called : 8743f64d-3eaa-4dae-b41e-b76a1f281fec
======================================================================================================================================================================== 00:00:00 dummy_ic (1/1) ========================================================================================================================================================================
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[pid:18    id:001][--:--:--][5a56ee9e][build:project_0.bst  ] START   Caching Artifact
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[pid:18    id:001][--:--:--][5a56ee9e][build:project_0.bst  ] DEBUG   [project_0.bst] Force cache key calculation
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[pid:18    id:002][--:--:--][5a56ee9e][build:project_0.bst  ] DEBUG   get_workspace_key called : 4f830a03-ce1e-4125-90c8-384298501d7d
======================================================================================================================================================================== 00:00:00 dummy_ic (1/1) ========================================================================================================================================================================
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[pid:18    id:001][00:00:00][5a56ee9e][build:project_0.bst  ] SUCCESS Caching Artifact
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[project_0.bst] Returning STRONG cache key : 5a56ee9e0a4fb7e930039e3f4227c0a9a37b2a0967d068d5cc892ad0cf74fd74
[pid:18    id:001][00:00:00][5a56ee9e][build:project_0.bst  ] SUCCESS dummy_ic/project_0/5a56ee9e-build.18.log
======================================================================================================================================================================== 00:00:00 dummy_ic (1/1) ========================================================================================================================================================================
                                                                                                                                                                      (Fetched:0 1 0)→ (Built:0 0 0)                                                                                                                                                                      
                                                                                                                                                                         ~~~~~ Active Tasks ~~~~~                                                                                                                                                                         
[pid:11    id:000][00:00:00] SUCCESS Build Complete

Pipeline Summary
  Total:       1
  Session:     1
  Fetch Queue: processed 0, skipped 1, failed 0 
  Build Queue: processed 1, skipped 0, failed 0 
DEBUG: Destroyed: import element at project_0.bst [line 1 column 0]
DEBUG: Destroyed: local source at project_0.bst [line 8 column 4]

Everytime DEBUG get_workspace_key called is printed, that's mean that the cache key is recalculated. The UUID at the end has been added to make sure that this is not any kind of duplicated display.

Fist of all, _get_cache_key is called and calculate 2 cache keys : the strong and the weak one. __calculate_cache_key indirectly call get_workspace_key regardless the type of cache key being calculated.

Then, the cache key is re-calculated via _get_cache_key_for_build, once during the build and once more when caching the element

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information