kakao / s2graph

This code base is retained for historical interest only, please visit Apache Incubator Repo for latest one
https://github.com/apache/incubator-s2graph
Other
250 stars 32 forks source link

optimize toEdge by using mutable. #279

Open SteamShon opened 8 years ago

SteamShon commented 8 years ago

since toEdge is called lots of times, we think it is worth to optimize.

This is what @daewon reported

2016-03-22 7 35 00

based on profile, we can notice that toMap on list and ++ on two list takes many cpu time on toEdge. we can avoid toMap and ++ by using mutable map and give up functional style here. I think code looks ugly(not too bad), but we can remove unnecessary cpu usage. I would be minor tuning but toEdge is called many many times(called once on every fetched edges).