<div dir="ltr">Hi.<div><br></div><div>We have moved from plain text lager logging to our own event system that has main difference: we have limited amount of possible events that are compiled in code.</div><div><br></div><div>In known_events.erl I have:</div><div><br></div><div><br></div><div>-event({stream_started, info, ["stream started"]}).</div><div><br></div><div>and then I write in code:</div><div><br></div><div><br></div><div>events:stream_started([{media,Name}]).</div><div><br></div><div>Later all this is printed (using lager formatting, it is cool).</div><div><br></div><div><br></div><div><br></div><div>So we are close to the problem.  My code that was handling such:  events:stream_started was searching for predefined event via:  known_events:module_info(attributes).</div><div><br></div><div>Suddenly eprof told that I need to look carefully at this place and I wrote parse_transform that takes all attributes from module AST and compiles them into code. Also I've generated function  known_events:find(Name) with all possible clauses.</div><div><br></div><div>On single core of my macbook I got 4000 times speedup.  100 000 of fetches known_events:all()  took about 8 seconds with module_info(attributes) and about 2 milliseconds with generated and compiled code.</div><div><br></div><div><br></div><div>So lesson from here is: try to avoid calling module_info(attributes) in innner loops. It may be suprisingly expensive.</div><div><br></div><div><br></div><div><br></div><div><br></div></div>