<github.com/cloudposse/atmos/pull/2829>Follow up p...
# atmos-dev
Tried this back and forth in all the weird edge cases I am doing and it works
🚀 1
Will dig into why the tests failed 🫠
Just a schema ordering thing that was breaking some tests. Fix pushed.
@Erik Osterman (Cloud Posse) you mind kicking this off for me please bowtie
✔️ 1
So, we added most of our other stacks and apps to using labels, it took 3 minutes to assess what it should run with a dry-run
Copy code
time atmos terraform apply \
    --labels deployment:$app-dev \
    --max-concurrency 3 \
    -auto-approve \
    --dry-run
Let me see if I can do anything to make it faster 😬
e
Note, atmos has a built-in profiler
z
I was looking at the tracelogs as it ran and atmos was trying to hydrate everything, not just things that I was pointing at with tags/labels
e
@Andriy Knysh (Cloud Posse) do we have a claude skill for using the
--profiler-*
flags?
(not to be confused with the
--profile
flags)
z
Copy code
Error: unknown flag  --profiler  for command  atmos terraform apply
looking at extended help
e
Copy code
❯ atmos --help=all|grep profiler
      --profiler-enabled                        Enable pprof profiling server
      --profiler-host string                    Host for pprof profiling server (default localhost)
      --profiler-port int                       Port for pprof profiling server (default 6060)
a
do we have a claude skill for using the
--profiler-*
flags
no, we don't. It was implemented before the AI and not touched since then
you can also use
--heatmap
atmos.tools/cli/global-flags#…
z
Having codex dig through it, yeah in my testing last night I had maybe like 6 or 7 stacks
now I have like... idk, probably over 130+
with different labels heh
Copy code
Found it. #2807 intentionally skips unmatched labels before state reads, but our deployment label is a two-pass template: it
  references base_environment_stage, which is itself a template. The scope check sees it still unresolved and conservatively
  renders every component—hence 3,451 S3 reads.

  I'm flattening that label expression everywhere it uses this pattern; same final label, resolvable in one pass.

• Ran set -e
  │ selector_files=$(rg -l -U 'labels:\n(?:[^\n]*\n)*?\s+deployment:.*base_environment_stage' stacks)
  │ perl -0pi -e 's/deployment: "\{\{ \.vars\.app \}\}-\{\{ \.vars\.base_environment_stage \}\}"/deployment:
  │ … +5 lines
  └ (no output)
a
Copy code
3,451 S3 reads
is it using
!terraform.state
?
z
Copy code
Fixed the scope miss in 46 stack labels.

  base_environment_stage was itself templated, so #2807’s label prefilter couldn't resolve deployment in one pass and evaluated
  the whole repo.

  Changed labels to resolve directly:

  deployment: '{{ .<http://vars.app|vars.app> }}-{{ regexReplaceAll "(x|[0-9]+)$" .vars.deployment_requirements.stage "" }}'

  Heatmap result for your exact command:

  - Before: 225s, 3,451 S3 state reads
  - After: 36s, 543 S3 state reads

  No Atmos source change needed—the parent PR's scope-before-evaluate behavior now actually applies to these stacks.
I think I introduced some kind of fallback to evaluate everything instead of throwing an error
a
i believe we cache each
!terraform.state
read (unless something broke) so we don't read the data from the same key more than once
let me know if you need help
z
Thanks - going to dig through this a bit more. 36 seconds is still too slow
Copy code
• Confirmed. Atmos deliberately does not cache a missing state, so every fallback reference re-reads S3. But successful
  Terraform nodes already invalidate that exact cache entry afterward, which makes negative caching safe for this process.

  I'm changing the cache to retain "not provisioned" until that invalidation.
ok, got it down to 3 seconds lol
e
Did codex end up using the profiler?
z
it used the heatmap and profiler
Pushed up a fix to my branch ^
also hopefully fixed whatever is going wrong with the acceptance testing
having rabbit review
heatmap caught all of the s3 calls
🚀 1
Windows acceptance test Failing after 53m 😭
e
lol
Reabase? this should be fixed in github.com/cloudposse/atmos/pull/2834
(which is merged)
z
lol ok
e
(it was driving me insane)
z
Ok - I merged main into my branch
All checks have passed 🎉
@Andriy Knysh (Cloud Posse)
i believe we cache each
!terraform.state
read (unless something broke) so we don't read the data from the same key more than once
Is there a way to clear this cache? Does it live somewhere?
Trying to see if it's worth the effort to go all in on atmos profiles to scope the included stack paths way down
ah, nvm. it doesn't get written to disk
e
that cache is in memory, only while the process is running
👍 1
z
it's odd because it feels like subsequent runs are faster
Yeah I guess at this point breaking it down to specific stack files isn't saving me anything really meaningful then
we use
!terraform.state
literally everywhere
a
> Is there a way to clear this cache? Does it live somewhere? the cache is per CLi command execution, not forever. Do you mean to clear the cache between some steps in the code?
z
Nah, wouldn't want to do that. I was thinking it was maybe getting cached outside of memory between atmos commands
just seeing runtimes between commands going from 10 seconds on the initial run, then after taking 3-4 ¯\_(ツ)_/¯
probably just my network/aws thing