Closed ckampfe closed 2 years ago
Hot dog I'm excited to try this! I knew there was an n+1 thing going on and spent a bit of time trying to wrangle :ets.select
before throwing in the towel on the matchspec. Of course a list of matches is the way to go. I was trying to build up a bunch of orelse
s in a single guard, doh.
Thanks!
@losvedir you may want to hold off on merging this, I'm still trying to make sure these results are repeatable
@losvedir Heh, after attempting to repeat these results, I'm not able to get similar results to the original, so I must have a made a mistake in benchmarking somehow. It seems like this change isn't having the effect I thought it was. That said, I'm confused, and curious why select
doesn't appear to be working how I thought it would. I'm wondering, what is the select
BIF doing under the hood? Is it basically a lookup
loop? I have no idea! Something to look into! 😂
In any case feel free to do with this PR as you wish. I'll open a different one if I come up with something, sorry for the distraction 😂
This is fascinating to me! I took a stab at it myself while you were working on it (once I saw the light with your generation of the match via the for(...)
expression) and I was sure it would be a big win! But I'm also seeing actually worse performance with this approach, for reasons I don't understand.
I'm closing the PR for now since the experiment didn't pan out. But in any case, thanks for opening it! This was something on my to-do list to figure out, so I'm glad to have explored it a bit.
Hey thanks for the cool comparison project, I love stuff like this.
This PR uses
:ets.select
and matchspecs to avoid doing:ets.lookup
in aEnum.map
loop. Basically getting rid of an N+1 style lookup.I benchmarked this by waiting for the data to finish loading (as confirmed by curl) and then running the k6 commands as specified in the README, and results look like this for
loadTest.js
, which are pretty different from the results I was getting on the unchanged project:I'm not exactly sure how to test the json results from the API (and this was a pretty quick change) so it's entirely possible I've just broken the API and this benchmark is total garbage, but maybe you can help me see if the results I'm getting are what you expect the endpoint to return. In any case thanks again, and maybe this is useful!