{ "@context":[ "https://www.w3.org/ns/activitystreams", {"Hashtag":"as:Hashtag"} ], "published":"2021-09-27T14:00:16.520Z", "attributedTo":"https://epiktistes.com/actors/toddsundsted", "to":["https://www.w3.org/ns/activitystreams#Public"], "cc":["https://epiktistes.com/actors/toddsundsted/followers"], "content":"
what a difference one line of code makes!
commit fe18dc5 moved the line @saved_record : self | Nil = nil
from the module Ktistec::Model::InstanceMethods
into the macro Ktistec::Model.included
.
that single change cut the build time in half and reduced the memory required to build by about a third. you can be sure the improvement came as a surprise!
but really, it wasn't just this change itself—although it introduced the biggest improvement—because after all of the subsequent refactoring, simply moving the line back didn't increase the build time again.
the build time also improved slightly after other subsequent commits. and several of those commits introduced changes that reduced the amount of macro generated code. and that's the key insight: macros reduce visible boilderplate but don't reduce actual code that needs to be compiled.
i'm still investigating, but clearly the original placement of the line resulted in the generation of a lot of redundant/unnecessary code!
TL;DR if you're planning on using macros in crystal, check your build times before and after your changes—i'm sure there's a corresponding commit somewhere in the past that introduced this problem and i didn't catch it!
", "mediaType":"text/html", "attachment":[], "tag":[ {"type":"Hashtag","name":"#ktistec","href":"https://epiktistes.com/tags/ktistec"}, {"type":"Hashtag","name":"#crystal","href":"https://epiktistes.com/tags/crystal"} ], "type":"Note", "id":"https://epiktistes.com/objects/NxFsgH_E118" }