Skip to content

Eliminate copies in deferred cleanup #3035

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

Merged
merged 11 commits into from
Feb 7, 2025

Conversation

TimSylvester
Copy link
Collaborator

@TimSylvester TimSylvester commented Nov 21, 2024

Pulls in an implementation of move_only_function.

This simplifies deferred deletions, since there's no temporary copy to potentially outlast the schedule call, and eliminates the need to transfer ownership from each unique_ptr to a shared_ptr so that it can be copied.

Unfortunately, the change of function types for the scheduler spreads to the map callbacks due to usage like:

pathChangeCallback = Scheduler::GetCurrent()->bindOnce(...

This is further complicated by the fact that of the callbacks are explicitly copied:

void FileSourceRequest::setResponse(const Response& response) {
    // Copy, because calling the callback will sometimes self
    // destroy this object. We cannot move because this method
    // can be called more than once.

So some but not all callbacks are changed to the new function type, and typedefs are added to clarify.

This will make it possible to eliminate the extra copy steps in deferred tile destruction.

[18341ea] use public dep (+12 squashed commits)
[8ce96e4] fix glfw/xcode build
[0511a86] cherry-pick 366ebcc
[5b8a962] Disable static downcast warnings
[c7f4dea] improve type reference
[90c6a0b] xcode build
[8642002] use `std23::move_only_function` (+6 squashed commits)
[e57500aa58] improve coverage, rebase on main
[e98eab5cb7] normalize syntax
[d8dc4777ca] back out capture changes
[29610f6115] clear vector to resume a well-defined state
[4ff6f3a4e0] release pending items before waiting
[27d1cfacae] Set deferred deletions aside and schedule them once per frame (per source)
Copy link

github-actions bot commented Jan 10, 2025

Bloaty Results (iOS) 🐋

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  -0.6% -74.8Ki  -0.5% -64.0Ki    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results-ios/pr-3035-compared-to-main.txt

Copy link

github-actions bot commented Jan 14, 2025

Bloaty Results 🐋

Compared to main

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1%  +114Ki  -0.0%    -224    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-3035-compared-to-main.txt

Compared to d387090 (legacy)

    FILE SIZE        VM SIZE    
 --------------  -------------- 
   +31% +36.2Mi  +438% +26.2Mi    TOTAL

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/bloaty-results/pr-3035-compared-to-legacy.txt

Copy link

github-actions bot commented Jan 14, 2025

Benchmark Results ⚡

Benchmark                                                     Time             CPU      Time Old      Time New       CPU Old       CPU New
------------------------------------------------------------------------------------------------------------------------------------------
OVERALL_GEOMEAN                                            -0.0053         -0.0052             0             0             0             0

Full report: https://maplibre-native.s3.eu-central-1.amazonaws.com/benchmark-results/pr-3035-compared-to-main.txt

@TimSylvester TimSylvester marked this pull request as ready for review January 21, 2025 23:51
Copy link
Member

@louwers louwers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see comments.

@TimSylvester TimSylvester enabled auto-merge (squash) February 7, 2025 16:30
@TimSylvester TimSylvester merged commit 1455924 into maplibre:main Feb 7, 2025
51 checks passed
@TimSylvester TimSylvester deleted the no-copy-defer branch February 7, 2025 18:48
louwers added a commit to louwers/maplibre-native that referenced this pull request Mar 17, 2025
nnhubbard pushed a commit to nnhubbard/maplibre-native that referenced this pull request Apr 4, 2025
…to cachly-production

* 'main' of https://github.com/maplibre/maplibre-native: (365 commits)
  Fix warnings, ignore new CMake build directories (maplibre#3356)
  Fix rare crash LatLngAnimator (maplibre#3352)
  Release MapLibre iOS 6.12.2 (maplibre#3354)
  Add logo to sponsor section (maplibre#3353)
  chore(deps): update bazel (maplibre#3347)
  Enabled renovate dependency dashboard (maplibre#3350)
  Change Java Transfrom class from final to normal (maplibre#3332)
  Made iOS Benchmark app run on Xcode 16 (maplibre#3344)
  Android 11.8.5 release change log update (maplibre#3342)
  Fix `ErrorSurfaceLostKHR` exception (maplibre#3337)
  Add regression test for maplibre#3323, bug in layer dependency tracking (maplibre#3326)
  Create `core-release.yml` for MapLibre Native Core releases (maplibre#3331)
  Apply clang-tidy fixes (mostly use designated initializers) (maplibre#3328)
  Prepare Android v11.8.4 release (maplibre#3324)
  Add workaround for android emulator as crash on Android emulation is still presented (maplibre#3310)
  chore(deps): update bazel deps (maplibre#3311)
  Revert maplibre#3035 which was causing memory growth issue (maplibre#3315)
  fix glfw platform feature state demo (maplibre#3313)
  Bump mozilla-actions/sccache-action from 0.0.7 to 0.0.8 in the github-actions group (maplibre#3290)
  Allow Rust to build core as a static lib (maplibre#3283)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants