Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions used as keys in map are slow #14847

Closed
DartBot opened this issue Nov 5, 2013 · 8 comments
Closed

Functions used as keys in map are slow #14847

DartBot opened this issue Nov 5, 2013 · 8 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. type-enhancement A request for a change that isn't a bug type-performance Issue relates to performance or code size

Comments

@DartBot
Copy link

DartBot commented Nov 5, 2013

This issue was originally filed by nb...@gmail.com


If you create a map with the key being type Function, the map can have very slow performance. I believe this is due to Functions with the same signature will have the same hashcode.

@dgrove
Copy link
Contributor

dgrove commented Nov 6, 2013

Is this with the Dart VM or dartj2s (or both?)

@DartBot
Copy link
Author

DartBot commented Nov 6, 2013

This comment was originally written by nbily...@gmail.com


Just the Dart VM

@anders-sandholm
Copy link
Contributor

Removed Type-Defect label.
Added Type-Enhancement, Area-VM, Triaged labels.

@sethladd
Copy link
Contributor

sethladd commented Dec 2, 2013

Added Performance label.

@ghost
Copy link

ghost commented Jan 3, 2014

Could you please provide a small Dart program that exhibits the slow performance. Thanks.

@DartBot
Copy link
Author

DartBot commented Jan 3, 2014

This comment was originally written by nbilyk...@gmail.com


I've attached a benchmark harness.

I'm running
Dart VM version: 0.8.10.3_r29803 (Mon Nov 04 09:52:29 2013) on "windows_ia32"

In the Dart VM method closures all have the same hashCode, and are very slow within Maps. When using dart2js and running the same code through JavaScript, the hashCodes are different and performance is good.

With 1000 references there was a 200x performance difference.


Attachment:
dartscratchpad.dart (1.20 KB)

@DartBot
Copy link
Author

DartBot commented Feb 19, 2014

This comment was originally written by @tatumizer


same with reflection:
showHashCodeCollision() {
  var f1=(a,b)=>10;
  var f2=()=>15;
  var f3=(){print("foo");};
  print(reflect(f1).function.hashCode); // 313080768
  print(reflect(f2).function.hashCode); // 313080768
  print(reflect(f3).function.hashCode); // 313080768

}

@DartBot DartBot added Type-Enhancement area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. type-performance Issue relates to performance or code size labels Feb 19, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Feb 29, 2016
@rmacnak-google
Copy link
Contributor

@alexmarkov
203955bc48f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. type-enhancement A request for a change that isn't a bug type-performance Issue relates to performance or code size
Projects
None yet
Development

No branches or pull requests

6 participants