https://infracost.io logo
#contributors
Title
# contributors
l

little-author-61621

08/17/2021, 8:14 AM
Hi @few-glass-63325! If it helps, here's some links to relevant code for how we currently batch the queries to the API: Here's the code that runs the price queries: https://github.com/infracost/infracost/blob/edee8dc15c710ad9cdb1d15f0263e534a1f9d2bd/internal/prices/prices.go#L69 And the logic for batching the queries and unbatching the results is here: https://github.com/infracost/infracost/blob/master/internal/apiclient/pricing.go#L44
f

few-glass-63325

08/18/2021, 7:48 AM
I'm checking up the code of https://github.com/infracost/infracost/blob/edee8dc15c710ad9cdb1d15f0263e534a1f9d2bd/internal/prices/prices.go#L30 I'm trying to understand how this part can be improved... Honestly code looks well written. From the first glance batching code is okay too. Thought I feel that there might be a way to reduce contentions on the channel in GetPricesConcurrent and decrease blocking count in the RunQueries. Right now I do not have clear idea how to do this. But in couple of days I find a time to take a look again on this code :)
l

little-author-61621

08/18/2021, 7:54 AM
Interesting, yeah my initial thought was to reduce the number of round trips to the API. Currently the batching is only done within a resource. So if you have a lot of resources that only have one cost component it will make an individual round-trip call for each resource. My thought was we can batch the calls across resources. So it would request 10 resources in a single round trip if they only have one cost component each.
What tool are you using for the flame graphs?
f

few-glass-63325

08/18/2021, 8:03 AM
This is actually Intellij Idea/ GoLand but I think there can be more tools that provide similar functionality. I just found this IDE is quite comfortable for this
🙌 2
p

polite-vr-31842

08/18/2021, 6:30 PM
@few-glass-63325 Interesting investigation! We probably can enhance the performance to a degree but to make a boost we have probably no other choice but to have batching multiple resources. I'm no expert in GraphQL so I don't know how hard/easy could it be.
5 Views