go - runtime.duffcopy is called a lot -
when profiling app, , run top, see
showing top 10 nodes out of 31 (cum >= 0.12s) flat flat% sum% cum cum% 13.93s 63.00% 63.00% 13.93s 63.00% runtime.duffcopy
i struggling know when , why called , if there can improve this? need see function these calls made or there general rule-of-thumb should think about?
i have read named return values can improve this, quite big function testing lot of conditions (returning true or false), don't know if idea implement that.
thanks
think solved it. had @ assembly output , saw had
for _, v := range c.items
an item relatively big object, replaced above loop with
for index := 0; index < len(c.items); index++
and used direct access of objects c.items[index]. top shows:
350ms 4.85% 60.47% 350ms 4.85% runtime.duffcopy
the overall execution time cut 12s 4s. quite nice :)
Comments
Post a Comment