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

Use values iterator and update in map equality/hash #718

Merged
merged 4 commits into from
Nov 6, 2024
Merged

Conversation

jakemac53
Copy link
Contributor

@jakemac53 jakemac53 commented Nov 5, 2024

Initially I tried using entries instead of a values iterator, but that was surprisingly slow. This appears to be a good middle ground (see history of this comment for old results).

Hashing is about the same, but much faster for maps which don't have O(1) lookup. Equality is much faster.

Benchmarks before:

DeepCollectionQualityUnordered.equals(RunTime): 7427.29020979021 us.
DeepCollectionQualityUnordered.hash(RunTime): 217.8173707406213 us.
DeepCollectionQuality.equals(RunTime): 2653.23875 us.
DeepCollectionQuality.hash(RunTime): 178.1674653887114 us.

Benchmarks after:

DeepCollectionQualityUnordered.equals(RunTime): 4435.374 us.
DeepCollectionQualityUnordered.hash(RunTime): 212.8631545473818 us.
DeepCollectionQuality.equals(RunTime): 1989.1746626686656 us.
DeepCollectionQuality.hash(RunTime): 178.3396697902722 us.

Copy link

github-actions bot commented Nov 5, 2024

Package publishing

Package Version Status Publish tag (post-merge)
package:characters 1.4.0 ready to publish characters-v1.4.0
package:args 2.6.1-wip WIP (no publish necessary)
package:async 2.12.0 already published at pub.dev
package:collection 1.19.1-wip WIP (no publish necessary)
package:convert 3.1.2 already published at pub.dev
package:crypto 3.0.6 already published at pub.dev
package:fixnum 1.1.1 already published at pub.dev
package:logging 1.3.0 already published at pub.dev
package:os_detect 2.0.3-wip WIP (no publish necessary)
package:path 1.9.1 already published at pub.dev
package:platform 3.1.6 already published at pub.dev
package:typed_data 1.4.0 already published at pub.dev

Documentation at https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

Copy link

github-actions bot commented Nov 5, 2024

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
collection None 1.19.1-wip 1.19.1-wip 1.19.1-wip ✔️
Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

Coverage ✔️
File Coverage
pkgs/collection/lib/src/equality.dart 💚 89 %

This check for test coverage is informational (issues shown here will not fail the PR).

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbols
License Headers ✔️
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

@jakemac53 jakemac53 changed the title Use entries and update for equality in map equality/hash impls. Use values iterator and update for equality in map equality/hash Nov 5, 2024
@jakemac53 jakemac53 changed the title Use values iterator and update for equality in map equality/hash Use values iterator and update in map equality/hash Nov 5, 2024
@jakemac53
Copy link
Contributor Author

cc @davidmorgan

pkgs/collection/lib/src/equality.dart Outdated Show resolved Hide resolved
pkgs/collection/lib/src/equality.dart Outdated Show resolved Hide resolved
@jakemac53 jakemac53 merged commit 1156cfe into main Nov 6, 2024
14 checks passed
@jakemac53 jakemac53 deleted the use-entries branch November 6, 2024 16:30
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Nov 7, 2024
Revisions updated by `dart tools/rev_sdk_deps.dart`.

core (https://github.com/dart-lang/core/compare/4b62792..1156cfe):
  1156cfe4  2024-11-06  Jacob MacDonald  Use `values` iterator  and `update` in map equality/hash (dart-lang/core#718)
  9ab5a189  2024-11-05  Jacob MacDonald  add a basic benchmark for DeepCollectionEquality (dart-lang/core#717)
  9e379158  2024-11-05  Jonas Finnemann Jensen  Introduce `IterableMapEntryExtension` for use with `Map.entries`. (dart-lang/core#715)

dartdoc (https://github.com/dart-lang/dartdoc/compare/5168f81..24c2a96):
  24c2a966  2024-11-04  dependabot[bot]  Bump the github-actions group across 1 directory with 4 updates (dart-lang/dartdoc#3922)

http (https://github.com/dart-lang/http/compare/8db0d0a..03ced4d):
  03ced4d  2024-11-06  Brian Quinlan  Upgrade flutter_http_example to cupertino_http (dart-lang/http#1393)
  df59bac  2024-11-05  Brian Quinlan  Release package:cupertino_http 2.0.1 (dart-lang/http#1400)
  0544e1f  2024-11-05  Brian Quinlan  Fix a bug where cupertino_http did not work on iOS<17. (dart-lang/http#1399)

sse (https://github.com/dart-lang/sse/compare/1b02011..befbd6d):
  befbd6d  2024-11-04  dependabot[bot]  Bump actions/checkout from 4.2.0 to 4.2.2 in the github-actions group (dart-lang/sse#118)

Change-Id: I2b4ebfe2f56f9478c7e89cd2d3e50485ae44caa0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393943
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Auto-Submit: Devon Carew <devoncarew@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants