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

[WK2] Decoding in ArgumentCoder<Vector<T>> should reserve initial capacity, avoid shrink-to-fit #7444

Conversation

zdobersek
Copy link
Contributor

@zdobersek zdobersek commented Dec 10, 2022

0c0b202

[WK2] Decoding in ArgumentCoder<Vector<T>> should reserve initial capacity, avoid shrink-to-fit
https://bugs.webkit.org/show_bug.cgi?id=249077

Reviewed by Kimmo Kinnunen.

When decoding a Vector of non-trivial elements, use the decoded size to
reserve initial capacity and then perform unchecked appends of each
decoded element. This replaces the incremental grow-as-you-go appending
and the final shrink-to-fit operation which possibly ends up moving over
all the elements into the newly-allocated smaller buffer.

The decoding-moves-counter test is updated, with the only remaining and
unavoidable move of each element contained in the Vector happening when
that element is moved into the resulting Vector.

* Source/WebKit/Platform/IPC/ArgumentCoders.h:
* Tools/TestWebKitAPI/Tests/IPC/ArgumentCoderTests.cpp:
(TestWebKitAPI::TEST_F):

Canonical link: https://commits.webkit.org/257725@main

8fae0c3

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  πŸ§ͺ win
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ›  gtk βœ… πŸ›  wincairo
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac πŸ’₯ πŸ§ͺ gtk-wk2
  πŸ§ͺ api-ios ❌ πŸ§ͺ mac-wk1 ⏳ πŸ§ͺ api-gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-wk2
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch βœ… πŸ§ͺ mac-wk2-stress
βœ… πŸ›  watch-sim

@zdobersek zdobersek self-assigned this Dec 10, 2022
@zdobersek zdobersek added the WebKit2 Bugs relating to the WebKit2 API layer label Dec 10, 2022
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Dec 11, 2022
@questgugou
Copy link

good project

@zdobersek zdobersek added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels Dec 12, 2022
…acity, avoid shrink-to-fit

https://bugs.webkit.org/show_bug.cgi?id=249077

Reviewed by Kimmo Kinnunen.

When decoding a Vector of non-trivial elements, use the decoded size to
reserve initial capacity and then perform unchecked appends of each
decoded element. This replaces the incremental grow-as-you-go appending
and the final shrink-to-fit operation which possibly ends up moving over
all the elements into the newly-allocated smaller buffer.

The decoding-moves-counter test is updated, with the only remaining and
unavoidable move of each element contained in the Vector happening when
that element is moved into the resulting Vector.

* Source/WebKit/Platform/IPC/ArgumentCoders.h:
* Tools/TestWebKitAPI/Tests/IPC/ArgumentCoderTests.cpp:
(TestWebKitAPI::TEST_F):

Canonical link: https://commits.webkit.org/257725@main
@webkit-early-warning-system webkit-early-warning-system force-pushed the eng/WK2-Decoding-in-ArgumentCoderVectorT-should-reserve-initial-capacity-avoid-shrink-to-fit branch from 8fae0c3 to 0c0b202 Compare December 12, 2022 13:54
@webkit-commit-queue
Copy link
Collaborator

Committed 257725@main (0c0b202): https://commits.webkit.org/257725@main

Reviewed commits have been landed. Closing PR #7444 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit 0c0b202 into WebKit:main Dec 12, 2022
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Dec 12, 2022
@zdobersek zdobersek deleted the eng/WK2-Decoding-in-ArgumentCoderVectorT-should-reserve-initial-capacity-avoid-shrink-to-fit branch December 12, 2022 15:22
@questgugou
Copy link

thankyou verymuch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebKit2 Bugs relating to the WebKit2 API layer
Projects
None yet
6 participants