cli icon indicating copy to clipboard operation
cli copied to clipboard

[local cache] Initial implementation of the local cache layer

Open anton-107 opened this issue 2 months ago β€’ 1 comments

Changes

  • added libs/cache library with a proposed caching interface and a single implementation: libs/cache/file_cache.go
  • implemented basic caching method GetOrCompute
  • implemented background cleanup of old cache files
  • added databricks cache clear command
  • added DATABRICKS_CACHE_DISABLED environment variable to disable the cache layer
  • modified populate_current_user.go to use the new caching library
  • added telemetry for local.cache hits and misses

Why

This is the first attempt to speed up subsequent databricks bundle commands that a bundle developer runs while developing a bundle

Tests

  • changed existing acceptance tests to use a dedicated cache folder
  • added new acceptance test for overall caching functionality and telemetry
  • added new acceptance test for clearing the cache
  • added unit tests for libs/cache

anton-107 avatar Sep 29 '25 10:09 anton-107

Commit: https://github.com/databricks/cli/pull/3678/commits/ecc4e9c88f6050a737042bbc9844504a856c84f4

Run: 19741772068

Env πŸŸ¨β€‹KNOWN πŸ”„β€‹flaky πŸ’šβ€‹RECOVERED πŸ™ˆβ€‹SKIP βœ…β€‹pass πŸ™ˆβ€‹skip Time
πŸŸ¨β€‹ aws linux 7 2 371 628 20:08
πŸŸ¨β€‹ aws windows 7 2 373 626 23:16
πŸ’šβ€‹ aws-ucws linux 7 2 514 513 35:56
πŸ”„β€‹ aws-ucws windows 2 6 2 515 511 36:08
πŸ”„β€‹ azure linux 6 1 4 365 627 32:17
πŸ”„β€‹ azure windows 5 1 4 368 625 27:43
πŸ’šβ€‹ azure-ucws linux 1 4 510 512 37:25
πŸ’šβ€‹ azure-ucws windows 1 4 512 510 41:07
πŸ’šβ€‹ gcp linux 1 4 364 631 25:15
πŸ’šβ€‹ gcp windows 1 4 366 629 25:44
21 failing tests:
Test Name aws linux aws windows aws-ucws linux aws-ucws windows azure linux azure windows azure-ucws linux azure-ucws windows gcp linux gcp windows
πŸŸ¨β€‹ TestAccept πŸŸ¨β€‹K πŸŸ¨β€‹K πŸ’šβ€‹R πŸ”„β€‹f πŸ’šβ€‹R πŸ’šβ€‹R πŸ’šβ€‹R πŸ’šβ€‹R πŸ’šβ€‹R πŸ’šβ€‹R
πŸ”„β€‹ TestAccept/bundle/resources/dashboards/nested-folders/DATABRICKS_BUNDLE_ENGINE=direct βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p πŸ”„β€‹f βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p
πŸ”„β€‹ TestAccept/bundle/resources/dashboards/nested-folders/DATABRICKS_BUNDLE_ENGINE=terraform βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p πŸ”„β€‹f βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p
πŸ™ˆβ€‹ TestAccept/bundle/resources/permissions πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S
πŸŸ¨β€‹ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions πŸŸ¨β€‹K πŸŸ¨β€‹K πŸ’šβ€‹R πŸ’šβ€‹R πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S
πŸŸ¨β€‹ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=direct πŸŸ¨β€‹K πŸŸ¨β€‹K πŸ’šβ€‹R πŸ’šβ€‹R
πŸŸ¨β€‹ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/with_permissions/DATABRICKS_BUNDLE_ENGINE=terraform πŸŸ¨β€‹K πŸŸ¨β€‹K πŸ’šβ€‹R πŸ’šβ€‹R
πŸŸ¨β€‹ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions πŸŸ¨β€‹K πŸŸ¨β€‹K πŸ’šβ€‹R πŸ’šβ€‹R πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S
πŸŸ¨β€‹ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=direct πŸŸ¨β€‹K πŸŸ¨β€‹K πŸ’šβ€‹R πŸ’šβ€‹R
πŸŸ¨β€‹ TestAccept/bundle/resources/permissions/jobs/destroy_without_mgmtperms/without_permissions/DATABRICKS_BUNDLE_ENGINE=terraform πŸŸ¨β€‹K πŸŸ¨β€‹K πŸ’šβ€‹R πŸ’šβ€‹R
πŸ”„β€‹ TestAccept/bundle/resources/pipelines/allow-duplicate-names βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p πŸ”„β€‹f βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p
πŸ”„β€‹ TestAccept/bundle/resources/pipelines/allow-duplicate-names/DATABRICKS_BUNDLE_ENGINE=terraform βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p πŸ”„β€‹f βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p
πŸ™ˆβ€‹ TestAccept/bundle/run/app-with-job πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S πŸ™ˆβ€‹S
πŸ”„β€‹ TestAccept/bundle/templates/default-python/integration_classic/DATABRICKS_BUNDLE_ENGINE=terraform/UV_PYTHON=3.11 βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p πŸ”„β€‹f βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p
πŸ”„β€‹ TestAccept/bundle/templates/default-python/integration_classic/DATABRICKS_BUNDLE_ENGINE=terraform/UV_PYTHON=3.12 βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p πŸ”„β€‹f βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p
πŸ”„β€‹ TestAccept/bundle/templates/default-python/integration_classic/DATABRICKS_BUNDLE_ENGINE=terraform/UV_PYTHON=3.13 βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p πŸ”„β€‹f βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p
πŸ”„β€‹ TestAccept/ssh/connection βœ…β€‹p βœ…β€‹p βœ…β€‹p πŸ”„β€‹f βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p
πŸ”„β€‹ TestExportDir βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p πŸ”„β€‹f βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p
πŸ”„β€‹ TestImportDirWithOverwriteFlag βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p πŸ”„β€‹f βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p
πŸ”„β€‹ TestWorkpaceExportPrintsContents βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p πŸ”„β€‹f βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p
πŸ”„β€‹ TestWorkspaceList βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p πŸ”„β€‹f βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p βœ…β€‹p
Top 50 slowest tests (at least 2 minutes):
duration env testname
14:22 azure-ucws windows TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
10:23 azure-ucws windows TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
6:27 gcp linux TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:58 aws windows TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:46 gcp windows TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:43 aws-ucws windows TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
5:42 gcp linux TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
5:39 aws-ucws linux TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:39 aws windows TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
5:27 aws-ucws windows TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
5:16 azure windows TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
4:33 azure windows TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
4:12 azure-ucws linux TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
4:10 azure-ucws linux TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
3:53 azure linux TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
3:42 aws-ucws windows TestAccept/bundle/templates/default-python/combinations/serverless/DATABRICKS_BUNDLE_ENGINE=terraform/DLT=yes/NBOOK=no/PY=yes
3:31 azure linux TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
3:08 azure-ucws windows TestAccept/bundle/resources/synced_database_tables/basic
3:03 azure linux TestAccept/bundle/resources/experiments/basic/DATABRICKS_BUNDLE_ENGINE=direct
2:59 gcp windows TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
2:58 gcp windows TestAccept/bundle/resources/experiments/basic/DATABRICKS_BUNDLE_ENGINE=terraform
2:54 azure-ucws linux TestAccept/bundle/resources/registered_models/basic/DATABRICKS_BUNDLE_ENGINE=terraform
2:43 aws linux TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
2:33 azure windows TestAccept/bundle/templates/default-python/integration_classic/DATABRICKS_BUNDLE_ENGINE=terraform/UV_PYTHON=3.12
2:32 azure-ucws linux TestAccept/bundle/resources/synced_database_tables/basic
2:32 aws linux TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=terraform
2:30 azure-ucws linux TestAccept/bundle/resources/registered_models/basic/DATABRICKS_BUNDLE_ENGINE=direct
2:24 aws-ucws linux TestAccept/bundle/resources/registered_models/basic/DATABRICKS_BUNDLE_ENGINE=terraform
2:23 gcp windows TestAccept/bundle/templates/default-python/integration_classic/DATABRICKS_BUNDLE_ENGINE=direct/UV_PYTHON=3.9
2:22 azure-ucws windows TestAccept/bundle/templates/default-python/combinations/classic/DATABRICKS_BUNDLE_ENGINE=terraform/DLT=yes/NBOOK=yes/PY=yes
2:22 azure-ucws linux TestAccept/bundle/resources/experiments/basic/DATABRICKS_BUNDLE_ENGINE=terraform
2:20 aws-ucws linux TestAccept/bundle/resources/clusters/deploy/update-after-create/DATABRICKS_BUNDLE_ENGINE=direct
2:20 aws-ucws windows TestAccept/bundle/templates/default-python/combinations/classic/DATABRICKS_BUNDLE_ENGINE=terraform/DLT=yes/NBOOK=yes/PY=yes
2:17 azure linux TestAccept/bundle/templates/default-python/integration_classic/DATABRICKS_BUNDLE_ENGINE=terraform/UV_PYTHON=3.10
2:17 azure-ucws windows TestAccept/bundle/resources/registered_models/basic/DATABRICKS_BUNDLE_ENGINE=terraform
2:16 aws linux TestAccept/bundle/templates/default-python/integration_classic/DATABRICKS_BUNDLE_ENGINE=terraform/UV_PYTHON=3.9
2:15 azure linux TestAccept/bundle/templates/default-python/integration_classic/DATABRICKS_BUNDLE_ENGINE=direct/UV_PYTHON=3.11
2:15 aws-ucws linux TestAccept/bundle/resources/models/basic/DATABRICKS_BUNDLE_ENGINE=direct
2:14 azure linux TestAccept/bundle/templates/default-python/integration_classic/DATABRICKS_BUNDLE_ENGINE=direct/UV_PYTHON=3.10
2:13 aws linux TestAccept/bundle/templates/default-python/integration_classic/DATABRICKS_BUNDLE_ENGINE=terraform/UV_PYTHON=3.12
2:11 aws-ucws windows TestAccept/bundle/resources/experiments/basic/DATABRICKS_BUNDLE_ENGINE=terraform
2:11 aws-ucws windows TestAccept/bundle/templates/default-python/combinations/serverless/DATABRICKS_BUNDLE_ENGINE=terraform/DLT=no/NBOOK=no/PY=yes
2:10 azure-ucws linux TestAccept/bundle/templates/default-python/integration_classic/DATABRICKS_BUNDLE_ENGINE=terraform/UV_PYTHON=3.10
2:09 azure-ucws windows TestAccept/bundle/templates/default-python/combinations/classic/DATABRICKS_BUNDLE_ENGINE=terraform/DLT=yes/NBOOK=no/PY=yes
2:08 gcp linux TestAccept/bundle/templates/default-python/combinations/classic/DATABRICKS_BUNDLE_ENGINE=direct/DLT=yes/NBOOK=yes/PY=yes
2:08 azure-ucws linux TestAccept/bundle/templates/default-python/combinations/classic/DATABRICKS_BUNDLE_ENGINE=terraform/DLT=yes/NBOOK=yes/PY=yes
2:07 azure-ucws linux TestAccept/bundle/resources/models/basic/DATABRICKS_BUNDLE_ENGINE=terraform
2:07 azure-ucws linux TestAccept/bundle/templates/default-python/combinations/classic/DATABRICKS_BUNDLE_ENGINE=terraform/DLT=yes/NBOOK=no/PY=no
2:07 gcp linux TestAccept/bundle/resources/models/basic/DATABRICKS_BUNDLE_ENGINE=direct
2:06 azure linux TestAccept/bundle/templates/default-python/integration_classic/DATABRICKS_BUNDLE_ENGINE=direct/UV_PYTHON=3.9

eng-dev-ecosystem-bot avatar Sep 29 '25 11:09 eng-dev-ecosystem-bot

Do we have a benchmark that shows the cases where this helps and what's the impact? It's quite some code to maintain, should have a clear benefit.

denik avatar Nov 25 '25 09:11 denik

@denik no benchmark yet, but the plan was to release this and add metrics on cache hit and ho much it would have saved

andrewnester avatar Nov 25 '25 11:11 andrewnester