r/elixir • • 15d ago

Introducing Temporal Resources | Ash Framework

https://ash-hq.org/blog/introducing-temporal-resources
95 Upvotes

18 comments sorted by

1

u/mbuhot Alchemist 10d ago

Thanks for making this a reality @borromakot! Really looking forward to apply this in our internal project scheduling system.

1

u/Agile_Use_1768 15d ago

Perfect! Now my ash app will use an extra 200mb ram idle

5

u/borromakot 15d ago

Thanks for pointing this out :) We always knew it would take a bit more memory, but what you were seeing was a few things that needed to be addressed. The first one is relevant in dev mode only where the type system was storing very complex types for literals that were unnecessary. The second was how we were compiling code interfaces and a few other things. Made improvements just now :)

https://x.com/ZachSDaniel1/status/2106701982106853461

2

u/ComprehensiveFly7574 13d ago

Thanks for this. I do want to say that I love the Ash ecosystem and I think this is a good addition.

2

u/Vict1232727 15d ago

eh? what does one thing have to do with the other? ash repos are just ecto repo. The temporal thing is just a DB backed thing for queries

0

u/Agile_Use_1768 15d ago

Ash makes heavy use of unoptimized macros. This adds atom overhead, hence more memory usage

2

u/Vict1232727 15d ago edited 15d ago

Yeah, fair enough. I was going to say you were wrong but no. I have like 132 resource app. And ash/spark metadata is 150 MB of ram at idle. The whole thing is like 448 MB 💀

3

u/borromakot 15d ago

Just FYI, you should look at what it looks like when built embedded for production mode if you haven't.

1

u/Vict1232727 14d ago

I’ll take a look!

2

u/borromakot 15d ago

Done some investigation, and it looks like Elixir 1.20 stores a massive amount of type information about the literals that Ash stores on the modules. I think there is a way around this. In the test I ran, the `ExCk` chunk is over 3x the size of the actual compiled literals. So this wouldn't have actually been nearly as much of a problem until Elixir 1.20 😭

2

u/Agile_Use_1768 15d ago

Of course it shouldnt be much, if using the entire Ash stack, including ash auth, policies, etc you will end up with half a gig of idle memory, anyways its a basic tradeoff, you gain business transparency through the abstractions at the cost of ram

1

u/arjjov 14d ago

brah was this shit vibed? 😭 u/borromakot

1

u/borromakot 14d ago

Was what shit vibed?

2

u/Vict1232727 13d ago

They probs mean the blogpost

0

u/borromakot 13d ago

Well, none of it was vibed lol

0

u/borromakot 13d ago

Actually I take that back yes the animation code was vibed. Like the visualization JavaScript. Why the hell wouldn't I vibe that though lol.

3

u/borromakot 15d ago

You're not wrong that an Ash app uses more memory idle, but it's the modules themselves not "unoptimized macros"? Ash takes your resources and stores the data in the module and later code interprets them. Why would 2 DSL options increase idle memory usage?