Closed Raynos closed 8 years ago
You can make it cheaper if create a new constructor function with parent as proto, and override this.prefix
Changing proto messes with the hidden class.
I can optimize the constructor further to make it cheaper but that seems like a micro-op. I just want to fix the shared DNSResolver lulz.
lgtm. thanks!
before:
raynos at raynos-ThinkPad-T440p ~/uber/node-statsd-client on fast-get-child-client*
$ node benchmarks/child-client.js
time: 989
raynos at raynos-ThinkPad-T440p ~/uber/node-statsd-client on fast-get-child-client*
$ node benchmarks/child-client.js
time: 991
raynos at raynos-ThinkPad-T440p ~/uber/node-statsd-client on fast-get-child-client*
$ node benchmarks/child-client.js
time: 959
after:
$ node benchmarks/child-client.js
time: 648
raynos at raynos-ThinkPad-T440p ~/uber/node-statsd-client on fast-get-child-client*
$ node benchmarks/child-client.js
time: 657
raynos at raynos-ThinkPad-T440p ~/uber/node-statsd-client on fast-get-child-client*
$ node benchmarks/child-client.js
time: 627
I made it 66% faster with the latest commit. Looking at the flames I think I made v8 inline all the constructors and stuff.
If it needs to be any faster i'm going to have to read the generated ASM:
This makes two changes: first fix any missing options not passed to child.
Secondly ensure that all children share the same dnsResolver.
r: @Matt-Esch @syyang