delian / node-netflowv9

NetFlow Version 9 library for Node.JS
GNU General Public License v2.0
42 stars 13 forks source link

Use Object.create(null) in place of o = {} to reduce IC_Miss #19

Closed gavinaiken closed 6 years ago

gavinaiken commented 6 years ago

This is an optimization from my colleague Tom, would be great to also get this merged, thanks!

Using the object literal syntax var o = {} and then immediately setting various properties on it such as o['src_addr'] = ..., can cause prototype transitions to occur frequently. As a result, it may be easier on memory to simply use a map instead by using Object.create(null)

delian commented 6 years ago

Ok, I was wondering if this is going to make it faster

Delian

On Wed, Jun 27, 2018 at 11:47 AM Gavin Aiken notifications@github.com wrote:

This is an optimization from my colleague Tom, would be great to also get this merged, thanks!

Using the object literal syntax var o = {} and then immediately setting various properties on it such as o['src_addr'] = ..., can cause prototype transitions to occur frequently. As a result, it may be easier on memory to simply use a map instead by using Object.create(null)

You can view, comment on, or merge this pull request online at:

https://github.com/delian/node-netflowv9/pull/19 Commit Summary

  • Use Object.create(null) in place of o = {} to reduce IC_Miss

File Changes

Patch Links:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/delian/node-netflowv9/pull/19, or mute the thread https://github.com/notifications/unsubscribe-auth/AAG7ZrbDpmEipXxuTNM3uHZRLS6Hf5fkks5uA1SlgaJpZM4U5ZI6 .

delian commented 6 years ago

Should be merged, and version 0.2.14 is published in npm

gavinaiken commented 6 years ago

I think it made a small difference in our testing, not dramatic, but worth doing