Skip to content

Issues with mutable.HashMap #567

@szeiger

Description

@szeiger

Some findings from benchmarking mutable.HashSet:

  • Doesn't handle primitives correctly (using .hashCode instead of .##)
  • Considerably slower than Java's HashSet (mutable.HashMap used as a Set is even slower)
  • Uses open addressing with a high load factory: This can be useful in some cases but is probably not the best default, especially on the JVM where open addressing can't play to its full strength
  • Doesn't cache hash codes (unlike our other standard hash-based collections): This can lead to surprising performance if elements can't compute hashes cheaply
  • Doesn't support size hints for efficient bulk building
  • Like our other Set and Map types it is vulnerable to DoS vulnerability in Scala 2.12 HashMap bug#11203

We should replace it with a more "standard" implementation (chaining via linked lists, cached hash codes) for predictable performance that is consistent with mutable.HashMap and java.util.HashSet.

The current version could live on as OpenHashSet, consistent with OpenHashMap. OTOH, OpenHashMap is deprecated.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions