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

[core] Add lock::observing module, for analyzing lock acquisition. #5586

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

jimblandy
Copy link
Member

Add a new module lock::observing, enabled by the observe-locks feature, that records all nested lock acquisitions in trace files.

Add a new utility to the workspace, lock-analyzer, that reads the files written by the observe-locks feature and writes out a new define_lock_ranks! macro invocation that covers all observed lock usage, along with comments giving the held and acquired source locations.

@jimblandy
Copy link
Member Author

Current output:

rank COMMAND_BUFFER_DATA "CommandBuffer::data" followed by {
    // holding device/global.rs:1395 while locking device/resource.rs:323
    DEVICE_LIFE_TRACKER,

    // holding device/global.rs:1395 while locking device/resource.rs:501
    DEVICE_TEMP_SUSPECTED,

    // holding command/compute.rs:379 while locking:
    //     track/mod.rs:543
    //     track/mod.rs:555
    // holding command/render.rs:1352 while locking:
    //     track/mod.rs:543
    //     track/mod.rs:555
    DEVICE_USAGE_SCOPES,

    // holding device/queue.rs:1233 while locking device/queue.rs:1261
    BUFFER_MAP_STATE,

    // holding command/compute.rs:379 while locking:
    //     track/buffer.rs:73
    //     track/buffer.rs:172
    // holding command/render.rs:1352 while locking track/buffer.rs:172
    BUFFER_BIND_GROUP_STATE_BUFFERS,

    // holding device/queue.rs:1233 while locking track/stateless.rs:47
    STATELESS_BIND_GROUP_STATE_RESOURCES,

    // holding command/compute.rs:379 while locking:
    //     track/texture.rs:343
    //     track/texture.rs:697
    // holding command/render.rs:1352 while locking track/texture.rs:343
    TEXTURE_BIND_GROUP_STATE_TEXTURES,

    // holding command/compute.rs:379 while locking track/mod.rs:215
    // holding command/render.rs:1352 while locking track/mod.rs:215
    SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
}
rank STAGING_BUFFER_RAW "StagingBuffer::raw" followed by {
    // holding device/queue.rs:920 while locking device/queue.rs:926
    DEVICE_TRACKERS,
}
rank DEVICE_TRACKERS "Device::trackers" followed by {
    // holding device/resource.rs:3611 while locking:
    //     resource.rs:575
    //     resource.rs:912
    DEVICE_PENDING_WRITES,

    // holding device/resource.rs:3611 while locking resource.rs:560
    BUFFER_BIND_GROUPS,

    // holding device/resource.rs:3611 while locking resource.rs:891
    TEXTURE_VIEWS,

    // holding device/resource.rs:3611 while locking resource.rs:896
    TEXTURE_BIND_GROUPS,

    // holding device/life.rs:540 while locking track/buffer.rs:83
    BUFFER_BIND_GROUP_STATE_BUFFERS,

    // holding device/life.rs:540 while locking track/stateless.rs:57
    STATELESS_BIND_GROUP_STATE_RESOURCES,

    // holding device/life.rs:540 while locking track/texture.rs:182
    TEXTURE_BIND_GROUP_STATE_TEXTURES,

    // holding device/life.rs:501 while locking track/mod.rs:211
    // holding device/life.rs:540 while locking track/mod.rs:211
    // holding device/life.rs:579 while locking track/mod.rs:211
    // holding device/life.rs:591 while locking track/mod.rs:211
    // holding device/life.rs:603 while locking track/mod.rs:211
    // holding device/life.rs:615 while locking track/mod.rs:211
    // holding device/life.rs:652 while locking track/mod.rs:211
    // holding device/life.rs:670 while locking track/mod.rs:211
    // holding device/life.rs:715 while locking track/mod.rs:211
    SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
}
rank DEVICE_LIFE_TRACKER "Device::life_tracker" followed by {
    // holding device/resource.rs:323 while locking resource.rs:699
    STAGING_BUFFER_RAW,

    // holding device/resource.rs:323 while locking command/allocator.rs:51
    COMMAND_ALLOCATOR_FREE_ENCODERS,

    // holding device/resource.rs:323 while locking:
    //     device/life.rs:501
    //     device/life.rs:540
    //     device/life.rs:579
    //     device/life.rs:591
    //     device/life.rs:603
    //     device/life.rs:615
    //     device/life.rs:652
    //     device/life.rs:670
    //     device/life.rs:715
    //     device/life.rs:830
    DEVICE_TRACKERS,

    // holding device/resource.rs:323 while locking device/resource.rs:444
    DEVICE_TEMP_SUSPECTED,

    // holding device/resource.rs:323 while locking:
    //     resource.rs:647
    //     resource.rs:1088
    DEVICE_DEFERRED_DESTROY,

    // holding device/resource.rs:323 while locking:
    //     device/mod.rs:330
    //     device/mod.rs:357
    BUFFER_SYNC_MAPPED_WRITES,

    // holding device/resource.rs:323 while locking:
    //     device/life.rs:841
    //     device/life.rs:869
    BUFFER_MAP_STATE,

    // holding device/resource.rs:323 while locking pool.rs:106
    RESOURCE_POOL_INNER,

    // holding device/resource.rs:323 while locking track/mod.rs:211
    SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
}
rank DEVICE_TEMP_SUSPECTED "Device::temp_suspected" followed by {
    // holding device/queue.rs:1186 while locking:
    //     command/mod.rs:308
    //     command/mod.rs:438
    //     command/mod.rs:449
    //     device/queue.rs:1233
    COMMAND_BUFFER_DATA,

    // holding device/queue.rs:1186 while locking device/queue.rs:1402
    DEVICE_TRACKERS,

    // holding device/queue.rs:1186 while locking track/mod.rs:215
    SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
}
rank DEVICE_PENDING_WRITES "Device::pending_writes" followed by {
    // holding device/queue.rs:456 while locking:
    //     device/queue.rs:338
    //     device/queue.rs:343
    //     device/queue.rs:650
    // holding device/queue.rs:792 while locking:
    //     device/queue.rs:338
    //     device/queue.rs:343
    //     device/queue.rs:920
    STAGING_BUFFER_RAW,

    // holding device/queue.rs:1462 while locking command/allocator.rs:39
    COMMAND_ALLOCATOR_FREE_ENCODERS,

    // holding device/queue.rs:456 while locking device/queue.rs:623
    // holding device/queue.rs:792 while locking device/queue.rs:817
    DEVICE_TRACKERS,

    // holding device/queue.rs:1462 while locking device/resource.rs:323
    // holding resource.rs:575 while locking device/resource.rs:323
    // holding resource.rs:912 while locking device/resource.rs:323
    DEVICE_LIFE_TRACKER,

    // holding device/queue.rs:456 while locking identity.rs:107
    // holding device/queue.rs:792 while locking identity.rs:107
    IDENTITY_MANAGER_VALUES,

    // holding device/queue.rs:792 while locking track/mod.rs:207
    SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
}
rank BUFFER_MAP_STATE "Buffer::map_state" followed by {
    // holding resource.rs:446 while locking resource.rs:489
    DEVICE_PENDING_WRITES,
}

@jimblandy jimblandy force-pushed the core-lock-observation branch 3 times, most recently from c4a5f52 to 3636eb6 Compare April 23, 2024 18:28
@jimblandy jimblandy marked this pull request as ready for review April 23, 2024 18:28
@jimblandy jimblandy requested a review from a team as a code owner April 23, 2024 18:28
@ErichDonGubler ErichDonGubler self-requested a review April 25, 2024 14:34
@ErichDonGubler
Copy link
Member

I'll take on reviewing this.

@jimblandy
Copy link
Member Author

Actually, this is going to need some significant changes to be rebased on top of #5603. The general idea isn't going to change but the specifics of lock/observing.rs are going to get shifted around a lot.

@jimblandy
Copy link
Member Author

Okay, this version has been rebased on trunk, supports RwLock and SnatchLock, and has been cleaned up quite a bit.

Copy link
Member

@ErichDonGubler ErichDonGubler left a comment

Choose a reason for hiding this comment

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

Posting WIP feedback, at least some of which is likely invalidated by the rebase. Looking forward to the next round!


I used Conventional Comments in this review! I hope they help with clarity and tone. 🙂

lock-analyzer/src/main.rs Outdated Show resolved Hide resolved
lock-analyzer/src/main.rs Outdated Show resolved Hide resolved
lock-analyzer/src/main.rs Outdated Show resolved Hide resolved
lock-analyzer/src/main.rs Show resolved Hide resolved
wgpu-core/Cargo.toml Outdated Show resolved Hide resolved
wgpu-core/src/lock/observing.rs Outdated Show resolved Hide resolved
lock-analyzer/src/main.rs Outdated Show resolved Hide resolved
wgpu-core/src/lock/observing.rs Outdated Show resolved Hide resolved
wgpu-core/src/lock/observing.rs Outdated Show resolved Hide resolved
wgpu-core/src/lock/observing.rs Outdated Show resolved Hide resolved
@jimblandy
Copy link
Member Author

jimblandy commented Apr 25, 2024

[Edit: note that this output is borked because of #5610.]

Current output
    rank DEVICE_TEMP_SUSPECTED "Device::temp_suspected" followed by {
        // holding device/queue.rs:1186 while locking:
        //     command/mod.rs:310
        //     command/mod.rs:440
        //     command/mod.rs:451
        //     device/queue.rs:1233
        COMMAND_BUFFER_DATA,

        // holding device/queue.rs:1186 while locking device/queue.rs:1402
        DEVICE_TRACKERS,

        // holding device/queue.rs:1186 while locking track/mod.rs:214
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank COMMAND_BUFFER_DATA "CommandBuffer::data" followed by {
        // holding device/global.rs:1397 while locking device/resource.rs:501
        DEVICE_TEMP_SUSPECTED,

        // holding command/clear.rs:94 while locking command/clear.rs:118
        // holding command/clear.rs:188 while locking command/clear.rs:252
        // holding command/transfer.rs:584 while locking command/transfer.rs:603
        // holding command/transfer.rs:763 while locking command/transfer.rs:803
        // holding command/transfer.rs:934 while locking command/transfer.rs:969
        DEVICE_SNATCHABLE_LOCK,

        // holding device/queue.rs:1233 while locking device/queue.rs:1261
        BUFFER_MAP_STATE,

        // holding device/global.rs:1397 while locking device/resource.rs:323
        DEVICE_LIFE_TRACKER,

        // holding command/clear.rs:94 while locking registry.rs:142
        // holding command/clear.rs:188 while locking registry.rs:142
        // holding command/compute.rs:349 while locking registry.rs:142
        // holding command/query.rs:365 while locking registry.rs:142
        // holding command/query.rs:404 while locking registry.rs:142
        // holding command/render.rs:1352 while locking registry.rs:142
        // holding command/render.rs:2417 while locking registry.rs:142
        // holding command/transfer.rs:763 while locking registry.rs:142
        // holding command/transfer.rs:934 while locking registry.rs:142
        // holding command/transfer.rs:1119 while locking registry.rs:142
        REGISTRY_STORAGE,

        // holding device/queue.rs:1233 while locking device/queue.rs:1372
        RENDER_BUNDLE_SCOPE_RENDER_PIPELINES,

        // holding device/queue.rs:1233 while locking device/queue.rs:1376
        RENDER_BUNDLE_SCOPE_QUERY_SETS,

        // holding device/queue.rs:1233 while locking track/stateless.rs:47
        STATELESS_BIND_GROUP_STATE_RESOURCES,
    };

    rank DEVICE_SNATCHABLE_LOCK "Device::snatchable_lock" followed by {
        // holding command/render.rs:1349 while locking:
        //     command/render.rs:1352
        //     command/render.rs:2417
        // holding command/transfer.rs:1117 while locking command/transfer.rs:1119
        // holding device/global.rs:2147 while locking:
        //     command/clear.rs:94
        //     command/clear.rs:188
        //     command/compute.rs:349
        //     command/mod.rs:594
        //     command/query.rs:404
        //     command/transfer.rs:584
        //     command/transfer.rs:934
        // holding device/queue.rs:1162 while locking:
        //     command/compute.rs:349
        //     command/mod.rs:594
        //     command/transfer.rs:584
        //     command/transfer.rs:934
        COMMAND_BUFFER_DATA,

        // holding device/global.rs:2147 while locking:
        //     command/render.rs:1349
        //     device/global.rs:235
        //     device/global.rs:804
        //     device/global.rs:2147
        //     device/global.rs:2429
        //     device/global.rs:2505
        //     device/global.rs:2541
        //     device/global.rs:2609
        //     device/queue.rs:1162
        //     device/resource.rs:1014
        //     resource.rs:439
        //     resource.rs:550
        //     resource.rs:878
        // holding device/queue.rs:1162 while locking:
        //     command/render.rs:1349
        //     device/global.rs:235
        //     device/global.rs:804
        //     device/global.rs:2147
        //     device/global.rs:2429
        //     device/global.rs:2505
        //     device/global.rs:2541
        //     device/global.rs:2609
        //     device/queue.rs:1162
        //     device/resource.rs:1014
        //     resource.rs:439
        DEVICE_SNATCHABLE_LOCK,

        // holding device/global.rs:235 while locking device/global.rs:252
        // holding device/global.rs:2147 while locking:
        //     device/global.rs:2486
        //     device/global.rs:2561
        // holding device/queue.rs:1162 while locking:
        //     device/global.rs:2486
        //     device/global.rs:2561
        // holding resource.rs:439 while locking resource.rs:445
        BUFFER_MAP_STATE,

        // holding device/global.rs:2147 while locking:
        //     device/global.rs:522
        //     device/global.rs:756
        //     device/global.rs:2294
        //     device/queue.rs:456
        //     device/queue.rs:792
        //     device/resource.rs:167
        //     resource.rs:574
        // holding device/queue.rs:1162 while locking:
        //     device/global.rs:522
        //     device/global.rs:756
        DEVICE_PENDING_WRITES,

        // holding device/global.rs:2147 while locking device/resource.rs:323
        // holding device/queue.rs:1162 while locking device/resource.rs:323
        DEVICE_LIFE_TRACKER,

        // holding device/global.rs:2147 while locking:
        //     command/allocator.rs:39
        //     command/allocator.rs:59
        // holding device/queue.rs:1162 while locking command/allocator.rs:39
        COMMAND_ALLOCATOR_FREE_ENCODERS,

        // holding device/global.rs:2147 while locking:
        //     device/global.rs:1142
        //     resource.rs:559
        // holding device/queue.rs:1162 while locking device/global.rs:1142
        BUFFER_BIND_GROUPS,

        // holding command/compute.rs:429 while locking:
        //     track/buffer.rs:73
        //     track/buffer.rs:172
        // holding device/resource.rs:2210 while locking:
        //     track/buffer.rs:66
        //     track/buffer.rs:100
        BUFFER_BIND_GROUP_STATE_BUFFERS,

        // holding command/clear.rs:118 while locking command/clear.rs:158
        // holding command/compute.rs:429 while locking command/compute.rs:496
        // holding command/query.rs:452 while locking command/query.rs:494
        // holding command/transfer.rs:603 while locking:
        //     command/transfer.rs:714
        //     command/transfer.rs:721
        // holding command/transfer.rs:803 while locking command/transfer.rs:885
        // holding command/transfer.rs:969 while locking command/transfer.rs:1064
        // holding device/global.rs:195 while locking device/mod.rs:362
        // holding device/global.rs:235 while locking:
        //     device/global.rs:249
        //     device/global.rs:250
        // holding device/resource.rs:2210 while locking device/resource.rs:2074
        BUFFER_INITIALIZATION_STATUS,

        // holding device/global.rs:195 while locking:
        //     device/mod.rs:330
        //     device/mod.rs:357
        BUFFER_SYNC_MAPPED_WRITES,

        // holding device/global.rs:2147 while locking device/resource.rs:334
        // holding device/queue.rs:1162 while locking device/resource.rs:334
        DEVICE_DEFERRED_DESTROY,

        // holding device/global.rs:2147 while locking:
        //     device/global.rs:2148
        //     device/resource.rs:172
        // holding device/queue.rs:1162 while locking device/queue.rs:1165
        DEVICE_FENCE,

        // holding device/global.rs:2147 while locking:
        //     device/global.rs:265
        //     device/global.rs:580
        //     device/global.rs:831
        //     device/global.rs:1147
        //     device/global.rs:1466
        //     device/global.rs:1529
        //     device/global.rs:1610
        //     device/global.rs:1743
        //     device/resource.rs:3641
        // holding device/global.rs:2505 while locking device/global.rs:2508
        // holding device/queue.rs:1162 while locking:
        //     device/global.rs:265
        //     device/global.rs:831
        //     device/global.rs:1147
        //     device/global.rs:1743
        DEVICE_TRACKERS,

        // holding command/render.rs:1349 while locking track/mod.rs:557
        DEVICE_USAGE_SCOPES,

        // holding device/global.rs:2147 while locking:
        //     identity.rs:107
        //     identity.rs:110
        //     identity.rs:113
        // holding device/queue.rs:838 while locking identity.rs:107
        // holding device/queue.rs:1162 while locking:
        //     identity.rs:107
        //     identity.rs:113
        IDENTITY_MANAGER_VALUES,

        // holding command/render.rs:1349 while locking registry.rs:142
        // holding command/transfer.rs:603 while locking registry.rs:142
        // holding command/transfer.rs:803 while locking registry.rs:142
        // holding command/transfer.rs:969 while locking registry.rs:142
        // holding device/global.rs:2147 while locking:
        //     registry.rs:94
        //     registry.rs:103
        //     registry.rs:110
        //     registry.rs:142
        //     registry.rs:145
        //     registry.rs:156
        //     registry.rs:166
        //     registry.rs:197
        // holding device/queue.rs:838 while locking registry.rs:142
        // holding device/queue.rs:1162 while locking:
        //     registry.rs:94
        //     registry.rs:142
        //     registry.rs:145
        //     registry.rs:166
        REGISTRY_STORAGE,

        // holding device/global.rs:2147 while locking pool.rs:47
        // holding device/queue.rs:1162 while locking pool.rs:47
        RESOURCE_POOL_INNER,

        // holding command/compute.rs:429 while locking track/mod.rs:214
        // holding device/global.rs:2147 while locking track/mod.rs:206
        // holding device/queue.rs:838 while locking track/mod.rs:206
        // holding device/queue.rs:1162 while locking track/mod.rs:206
        // holding device/resource.rs:1014 while locking track/mod.rs:206
        // holding device/resource.rs:2210 while locking track/mod.rs:206
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,

        // holding device/queue.rs:629 while locking device/queue.rs:650
        // holding device/queue.rs:838 while locking:
        //     device/queue.rs:338
        //     device/queue.rs:343
        //     device/queue.rs:920
        STAGING_BUFFER_RAW,

        // holding device/resource.rs:2210 while locking:
        //     track/stateless.rs:41
        //     track/stateless.rs:69
        STATELESS_BIND_GROUP_STATE_RESOURCES,

        // holding device/global.rs:2147 while locking device/global.rs:1139
        // holding device/queue.rs:1162 while locking device/global.rs:1139
        TEXTURE_BIND_GROUPS,

        // holding command/compute.rs:429 while locking:
        //     track/texture.rs:343
        //     track/texture.rs:697
        // holding device/resource.rs:2210 while locking:
        //     track/texture.rs:176
        //     track/texture.rs:197
        TEXTURE_BIND_GROUP_STATE_TEXTURES,

        // holding command/compute.rs:429 while locking command/memory_init.rs:79
        // holding command/transfer.rs:803 while locking command/memory_init.rs:79
        // holding command/transfer.rs:969 while locking command/memory_init.rs:79
        TEXTURE_INITIALIZATION_STATUS,

        // holding command/clear.rs:252 while locking:
        //     command/clear.rs:282
        //     command/clear.rs:324
        // holding command/compute.rs:429 while locking:
        //     command/clear.rs:282
        //     command/clear.rs:324
        // holding command/transfer.rs:969 while locking:
        //     command/clear.rs:282
        //     command/clear.rs:324
        // holding device/queue.rs:828 while locking:
        //     command/clear.rs:282
        //     command/clear.rs:324
        TEXTURE_CLEAR_MODE,

        // holding device/global.rs:2147 while locking device/global.rs:826
        // holding device/queue.rs:1162 while locking device/global.rs:826
        TEXTURE_VIEWS,
    };

    rank BUFFER_MAP_STATE "Buffer::map_state" followed by {
        // holding resource.rs:445 while locking resource.rs:488
        DEVICE_PENDING_WRITES,
    };

    rank DEVICE_PENDING_WRITES "Device::pending_writes" followed by {
        // holding device/queue.rs:456 while locking device/queue.rs:629
        DEVICE_SNATCHABLE_LOCK,

        // holding device/queue.rs:1462 while locking device/resource.rs:323
        // holding resource.rs:574 while locking device/resource.rs:323
        // holding resource.rs:911 while locking device/resource.rs:323
        DEVICE_LIFE_TRACKER,

        // holding device/queue.rs:1462 while locking command/allocator.rs:39
        COMMAND_ALLOCATOR_FREE_ENCODERS,

        // holding device/queue.rs:456 while locking identity.rs:107
        IDENTITY_MANAGER_VALUES,

        // holding device/queue.rs:456 while locking registry.rs:142
        // holding device/queue.rs:1462 while locking registry.rs:142
        REGISTRY_STORAGE,

        // holding device/queue.rs:456 while locking:
        //     device/queue.rs:338
        //     device/queue.rs:343
        STAGING_BUFFER_RAW,

        // holding device/queue.rs:792 while locking device/queue.rs:807
        TEXTURE_INITIALIZATION_STATUS,
    };

    rank DEVICE_LIFE_TRACKER "Device::life_tracker" followed by {
        // holding device/resource.rs:323 while locking device/resource.rs:444
        DEVICE_TEMP_SUSPECTED,

        // holding device/resource.rs:323 while locking:
        //     device/life.rs:841
        //     device/life.rs:869
        BUFFER_MAP_STATE,

        // holding device/resource.rs:323 while locking command/allocator.rs:51
        COMMAND_ALLOCATOR_FREE_ENCODERS,

        // holding device/resource.rs:323 while locking device/mod.rs:362
        BUFFER_INITIALIZATION_STATUS,

        // holding device/resource.rs:323 while locking:
        //     device/mod.rs:330
        //     device/mod.rs:357
        BUFFER_SYNC_MAPPED_WRITES,

        // holding device/resource.rs:323 while locking:
        //     resource.rs:646
        //     resource.rs:1087
        DEVICE_DEFERRED_DESTROY,

        // holding device/resource.rs:323 while locking:
        //     device/life.rs:501
        //     device/life.rs:540
        //     device/life.rs:579
        //     device/life.rs:591
        //     device/life.rs:603
        //     device/life.rs:615
        //     device/life.rs:652
        //     device/life.rs:670
        //     device/life.rs:715
        //     device/life.rs:830
        DEVICE_TRACKERS,

        // holding device/resource.rs:323 while locking pool.rs:106
        RESOURCE_POOL_INNER,

        // holding device/resource.rs:323 while locking track/mod.rs:210
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,

        // holding device/resource.rs:323 while locking resource.rs:698
        STAGING_BUFFER_RAW,
    };

    rank DEVICE_FENCE "Device::fence" followed by {
        // holding device/queue.rs:1165 while locking device/queue.rs:1462
        DEVICE_PENDING_WRITES,

        // holding device/global.rs:2148 while locking device/resource.rs:323
        DEVICE_LIFE_TRACKER,

        // holding device/queue.rs:1165 while locking registry.rs:145
        REGISTRY_STORAGE,
    };

    rank DEVICE_TRACKERS "Device::trackers" followed by {
        // holding device/queue.rs:817 while locking device/queue.rs:828
        // holding device/resource.rs:3641 while locking:
        //     resource.rs:550
        //     resource.rs:878
        DEVICE_SNATCHABLE_LOCK,

        // holding device/resource.rs:3641 while locking:
        //     resource.rs:574
        //     resource.rs:911
        DEVICE_PENDING_WRITES,

        // holding device/resource.rs:3641 while locking resource.rs:559
        BUFFER_BIND_GROUPS,

        // holding device/life.rs:540 while locking track/buffer.rs:83
        BUFFER_BIND_GROUP_STATE_BUFFERS,

        // holding device/queue.rs:1402 while locking command/memory_init.rs:180
        BUFFER_INITIALIZATION_STATUS,

        // holding device/life.rs:501 while locking device/life.rs:510
        RENDER_BUNDLE_SCOPE_BUFFERS,

        // holding device/life.rs:501 while locking device/life.rs:515
        RENDER_BUNDLE_SCOPE_TEXTURES,

        // holding device/life.rs:501 while locking device/life.rs:520
        RENDER_BUNDLE_SCOPE_BIND_GROUPS,

        // holding device/life.rs:501 while locking device/life.rs:525
        RENDER_BUNDLE_SCOPE_RENDER_PIPELINES,

        // holding device/life.rs:501 while locking device/life.rs:530
        RENDER_BUNDLE_SCOPE_QUERY_SETS,

        // holding device/life.rs:501 while locking track/mod.rs:210
        // holding device/life.rs:540 while locking track/mod.rs:210
        // holding device/life.rs:579 while locking track/mod.rs:210
        // holding device/life.rs:591 while locking track/mod.rs:210
        // holding device/life.rs:603 while locking track/mod.rs:210
        // holding device/life.rs:615 while locking track/mod.rs:210
        // holding device/life.rs:652 while locking track/mod.rs:210
        // holding device/life.rs:670 while locking track/mod.rs:210
        // holding device/life.rs:715 while locking track/mod.rs:210
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,

        // holding device/life.rs:540 while locking track/stateless.rs:57
        STATELESS_BIND_GROUP_STATE_RESOURCES,

        // holding device/resource.rs:3641 while locking resource.rs:895
        TEXTURE_BIND_GROUPS,

        // holding device/life.rs:540 while locking track/texture.rs:182
        TEXTURE_BIND_GROUP_STATE_TEXTURES,

        // holding device/queue.rs:1402 while locking:
        //     command/memory_init.rs:281
        //     command/memory_init.rs:341
        TEXTURE_INITIALIZATION_STATUS,

        // holding device/life.rs:591 while locking resource.rs:784
        TEXTURE_CLEAR_MODE,

        // holding device/resource.rs:3641 while locking resource.rs:890
        TEXTURE_VIEWS,
    };

    rank REGISTRY_STORAGE "Registry::storage" followed by {
        // holding registry.rs:145 while locking device/queue.rs:1186
        DEVICE_TEMP_SUSPECTED,

        // holding registry.rs:142 while locking command/mod.rs:430
        // holding registry.rs:176 while locking command/mod.rs:482
        COMMAND_BUFFER_DATA,

        // holding registry.rs:142 while locking:
        //     command/compute.rs:429
        //     command/query.rs:452
        //     device/global.rs:2147
        //     device/resource.rs:2210
        DEVICE_SNATCHABLE_LOCK,

        // holding registry.rs:145 while locking:
        //     device/resource.rs:167
        //     device/resource.rs:3671
        DEVICE_PENDING_WRITES,

        // holding registry.rs:145 while locking device/resource.rs:323
        DEVICE_LIFE_TRACKER,

        // holding registry.rs:145 while locking command/allocator.rs:59
        COMMAND_ALLOCATOR_FREE_ENCODERS,

        // holding registry.rs:142 while locking track/buffer.rs:172
        BUFFER_BIND_GROUP_STATE_BUFFERS,

        // holding registry.rs:142 while locking:
        //     command/bundle.rs:531
        //     command/bundle.rs:570
        //     command/bundle.rs:693
        //     command/bundle.rs:732
        //     command/render.rs:1496
        //     command/render.rs:1693
        //     command/render.rs:1760
        //     command/render.rs:2060
        //     command/render.rs:2369
        BUFFER_INITIALIZATION_STATUS,

        // holding registry.rs:142 while locking device/resource.rs:334
        DEVICE_DEFERRED_DESTROY,

        // holding registry.rs:145 while locking:
        //     device/resource.rs:172
        //     device/resource.rs:3674
        DEVICE_FENCE,

        // holding registry.rs:142 while locking:
        //     device/queue.rs:623
        //     device/resource.rs:3641
        DEVICE_TRACKERS,

        // holding registry.rs:142 while locking:
        //     track/mod.rs:557
        //     track/mod.rs:569
        DEVICE_USAGE_SCOPES,

        // holding registry.rs:145 while locking identity.rs:113
        // holding registry.rs:197 while locking registry.rs:202
        IDENTITY_MANAGER_VALUES,

        // holding registry.rs:142 while locking:
        //     registry.rs:142
        //     registry.rs:145
        // holding registry.rs:145 while locking registry.rs:145
        REGISTRY_STORAGE,

        // holding registry.rs:142 while locking:
        //     command/bundle.rs:369
        //     command/bundle.rs:519
        //     command/bundle.rs:558
        //     command/bundle.rs:685
        //     command/bundle.rs:724
        //     track/mod.rs:527
        //     track/mod.rs:619
        RENDER_BUNDLE_SCOPE_BUFFERS,

        // holding registry.rs:142 while locking:
        //     command/bundle.rs:374
        //     track/mod.rs:530
        //     track/mod.rs:621
        RENDER_BUNDLE_SCOPE_TEXTURES,

        // holding registry.rs:142 while locking:
        //     command/bundle.rs:379
        //     command/bundle.rs:411
        //     track/mod.rs:710
        RENDER_BUNDLE_SCOPE_BIND_GROUPS,

        // holding registry.rs:142 while locking:
        //     command/bundle.rs:384
        //     command/bundle.rs:476
        //     track/mod.rs:712
        RENDER_BUNDLE_SCOPE_RENDER_PIPELINES,

        // holding registry.rs:142 while locking:
        //     command/bundle.rs:389
        //     track/mod.rs:714
        RENDER_BUNDLE_SCOPE_QUERY_SETS,

        // holding registry.rs:145 while locking pool.rs:106
        RESOURCE_POOL_INNER,

        // holding registry.rs:142 while locking:
        //     track/mod.rs:206
        //     track/mod.rs:214
        // holding registry.rs:145 while locking track/mod.rs:210
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,

        // holding registry.rs:142 while locking track/texture.rs:343
        TEXTURE_BIND_GROUP_STATE_TEXTURES,

        // holding registry.rs:142 while locking command/memory_init.rs:79
        TEXTURE_INITIALIZATION_STATUS,
    };

    rank RENDER_BUNDLE_SCOPE_BUFFERS "RenderBundleScope::buffers" followed by {
        // holding track/mod.rs:527 while locking track/buffer.rs:172
        BUFFER_BIND_GROUP_STATE_BUFFERS,

        // holding command/bundle.rs:369 while locking track/mod.rs:214
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank RENDER_BUNDLE_SCOPE_TEXTURES "RenderBundleScope::textures" followed by {
        // holding command/bundle.rs:374 while locking track/mod.rs:214
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,

        // holding track/mod.rs:530 while locking track/texture.rs:343
        TEXTURE_BIND_GROUP_STATE_TEXTURES,
    };

    rank RENDER_BUNDLE_SCOPE_BIND_GROUPS "RenderBundleScope::bind_groups" followed by {
        // holding command/bundle.rs:379 while locking track/mod.rs:214
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank RENDER_BUNDLE_SCOPE_RENDER_PIPELINES "RenderBundleScope::render_pipelines" followed by {
        // holding command/bundle.rs:384 while locking track/mod.rs:214
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank RENDER_BUNDLE_SCOPE_QUERY_SETS "RenderBundleScope::query_sets" followed by {
        // holding command/bundle.rs:389 while locking track/mod.rs:214
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank STAGING_BUFFER_RAW "StagingBuffer::raw" followed by {
        // holding device/queue.rs:650 while locking device/queue.rs:672
        BUFFER_INITIALIZATION_STATUS,

        // holding device/queue.rs:920 while locking device/queue.rs:926
        DEVICE_TRACKERS,

        // holding device/queue.rs:650 while locking registry.rs:142
        REGISTRY_STORAGE,
    };

    rank TEXTURE_INITIALIZATION_STATUS "Texture::initialization_status" followed by {
        // holding device/queue.rs:807 while locking device/queue.rs:838
        DEVICE_SNATCHABLE_LOCK,

        // holding device/queue.rs:807 while locking device/queue.rs:817
        DEVICE_TRACKERS,

        // holding command/memory_init.rs:281 while locking:
        //     command/clear.rs:282
        //     command/clear.rs:324
        TEXTURE_CLEAR_MODE,
    };

    rank TEXTURE_CLEAR_MODE "Texture::clear_mode" followed by {
        // holding command/clear.rs:324 while locking command/clear.rs:455
        TEXTURE_CLEAR_MODE,
    };

    rank COMMAND_ALLOCATOR_FREE_ENCODERS "CommandAllocator::free_encoders" followed by { };
    rank BUFFER_BIND_GROUPS "Buffer::bind_groups" followed by { };
    rank BUFFER_BIND_GROUP_STATE_BUFFERS "BufferBindGroupState::buffers" followed by { };
    rank BUFFER_INITIALIZATION_STATUS "Buffer::initialization_status" followed by { };
    rank BUFFER_SYNC_MAPPED_WRITES "Buffer::sync_mapped_writes" followed by { };
    rank DEVICE_DEFERRED_DESTROY "Device::deferred_destroy" followed by { };
    rank DEVICE_TRACE "Device::trace" followed by { };
    rank DEVICE_USAGE_SCOPES "Device::usage_scopes" followed by { };
    rank IDENTITY_MANAGER_VALUES "IdentityManager::values" followed by { };
    rank RESOURCE_POOL_INNER "ResourcePool::inner" followed by { };
    rank SHARED_TRACKER_INDEX_ALLOCATOR_INNER "SharedTrackerIndexAllocator::inner" followed by { };
    rank STATELESS_BIND_GROUP_STATE_RESOURCES "StatelessBindGroupState::resources" followed by { };
    rank SURFACE_PRESENTATION "Surface::presentation" followed by { };
    rank TEXTURE_BIND_GROUPS "Texture::bind_groups" followed by { };
    rank TEXTURE_BIND_GROUP_STATE_TEXTURES "TextureBindGroupState::textures" followed by { };
    rank TEXTURE_VIEWS "Texture::views" followed by { };
    rank PAWN "pawn" followed by { };
    rank ROOK "rook" followed by { };
    rank KNIGHT "knight" followed by { };
    rank BISHOP "bishop" followed by { };

@jimblandy
Copy link
Member Author

jimblandy commented Apr 26, 2024

Actually, this whole thing is borked by #5610. I'm returning this to draft for the moment.

@jimblandy jimblandy marked this pull request as draft April 26, 2024 01:22
@jimblandy
Copy link
Member Author

This is now rebased on #5646. I haven't actually tried it again.

@jimblandy
Copy link
Member Author

jimblandy commented May 2, 2024

Okay, here's a new batch of output that actually looks usable. The line numbers refer to the current tip of this branch, aaacfb6:

Current output
    rank DEVICE_TEMP_SUSPECTED "Device::temp_suspected" followed by {
        // holding device/queue.rs:1186 while locking:
        //     command/mod.rs:310
        //     command/mod.rs:440
        //     command/mod.rs:451
        //     device/queue.rs:1233
        COMMAND_BUFFER_DATA,

        // holding device/queue.rs:1186 while locking device/queue.rs:1209
        DEVICE_TRACE,

        // holding device/queue.rs:1186 while locking device/queue.rs:1402
        DEVICE_TRACKERS,

        // holding device/queue.rs:1186 while locking track/mod.rs:214
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank COMMAND_BUFFER_DATA "CommandBuffer::data" followed by {
        // holding device/global.rs:1397 while locking device/resource.rs:503
        DEVICE_TEMP_SUSPECTED,

        // holding command/clear.rs:94 while locking command/clear.rs:118
        // holding command/clear.rs:188 while locking command/clear.rs:252
        // holding command/transfer.rs:584 while locking command/transfer.rs:603
        // holding command/transfer.rs:763 while locking command/transfer.rs:803
        // holding command/transfer.rs:934 while locking command/transfer.rs:969
        DEVICE_SNATCHABLE_LOCK,

        // holding device/queue.rs:1233 while locking device/queue.rs:1261
        BUFFER_MAP_STATE,

        // holding device/global.rs:1397 while locking device/resource.rs:323
        DEVICE_LIFE_TRACKER,

        // holding command/clear.rs:94 while locking command/clear.rs:103
        // holding command/clear.rs:188 while locking registry.rs:139
        // holding command/compute.rs:349 while locking command/compute.rs:380
        // holding command/query.rs:365 while locking command/query.rs:381
        // holding command/query.rs:404 while locking command/query.rs:426
        // holding command/render.rs:1352 while locking command/render.rs:1385
        // holding command/render.rs:2417 while locking command/render.rs:2420
        // holding command/transfer.rs:763 while locking registry.rs:139
        // holding command/transfer.rs:934 while locking registry.rs:139
        // holding command/transfer.rs:1119 while locking registry.rs:139
        REGISTRY_STORAGE,

        // holding device/queue.rs:1233 while locking device/queue.rs:1372
        RENDER_BUNDLE_SCOPE_RENDER_PIPELINES,

        // holding device/queue.rs:1233 while locking device/queue.rs:1376
        RENDER_BUNDLE_SCOPE_QUERY_SETS,

        // holding device/queue.rs:1233 while locking track/stateless.rs:47
        STATELESS_BIND_GROUP_STATE_RESOURCES,
    };

    rank DEVICE_SNATCHABLE_LOCK "Device::snatchable_lock" followed by {
        // holding command/render.rs:1349 while locking:
        //     command/render.rs:1352
        //     command/render.rs:2417
        // holding command/transfer.rs:1117 while locking command/transfer.rs:1119
        COMMAND_BUFFER_DATA,

        // holding device/global.rs:235 while locking device/global.rs:252
        // holding resource.rs:439 while locking resource.rs:445
        BUFFER_MAP_STATE,

        // holding command/compute.rs:429 while locking:
        //     track/buffer.rs:73
        //     track/buffer.rs:172
        // holding device/resource.rs:2220 while locking:
        //     track/buffer.rs:66
        //     track/buffer.rs:100
        BUFFER_BIND_GROUP_STATE_BUFFERS,

        // holding command/clear.rs:118 while locking command/clear.rs:158
        // holding command/compute.rs:429 while locking command/compute.rs:496
        // holding command/query.rs:452 while locking command/query.rs:494
        // holding command/transfer.rs:603 while locking:
        //     command/transfer.rs:714
        //     command/transfer.rs:721
        // holding command/transfer.rs:803 while locking command/transfer.rs:885
        // holding command/transfer.rs:969 while locking command/transfer.rs:1064
        // holding device/global.rs:195 while locking device/mod.rs:362
        // holding device/global.rs:235 while locking:
        //     device/global.rs:249
        //     device/global.rs:250
        // holding device/resource.rs:2220 while locking device/resource.rs:2084
        BUFFER_INITIALIZATION_STATUS,

        // holding device/global.rs:195 while locking:
        //     device/mod.rs:330
        //     device/mod.rs:357
        BUFFER_SYNC_MAPPED_WRITES,

        // holding device/global.rs:2146 while locking device/global.rs:2147
        // holding device/queue.rs:1162 while locking device/queue.rs:1165
        DEVICE_FENCE,

        // holding device/global.rs:2503 while locking device/global.rs:2506
        DEVICE_TRACKERS,

        // holding command/render.rs:1349 while locking track/mod.rs:557
        DEVICE_USAGE_SCOPES,

        // holding device/queue.rs:838 while locking identity.rs:107
        IDENTITY_MANAGER_VALUES,

        // holding command/render.rs:1349 while locking registry.rs:139
        // holding command/transfer.rs:603 while locking:
        //     command/transfer.rs:606
        //     command/transfer.rs:632
        // holding command/transfer.rs:803 while locking command/transfer.rs:820
        // holding command/transfer.rs:969 while locking command/transfer.rs:1011
        // holding device/queue.rs:838 while locking registry.rs:139
        REGISTRY_STORAGE,

        // holding command/compute.rs:429 while locking track/mod.rs:214
        // holding device/queue.rs:838 while locking track/mod.rs:206
        // holding device/resource.rs:1016 while locking track/mod.rs:206
        // holding device/resource.rs:2220 while locking track/mod.rs:206
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,

        // holding device/queue.rs:629 while locking device/queue.rs:650
        // holding device/queue.rs:838 while locking:
        //     device/queue.rs:338
        //     device/queue.rs:343
        //     device/queue.rs:920
        STAGING_BUFFER_RAW,

        // holding device/resource.rs:2220 while locking:
        //     track/stateless.rs:41
        //     track/stateless.rs:69
        STATELESS_BIND_GROUP_STATE_RESOURCES,

        // holding command/compute.rs:429 while locking:
        //     track/texture.rs:343
        //     track/texture.rs:697
        // holding device/resource.rs:2220 while locking:
        //     track/texture.rs:176
        //     track/texture.rs:197
        TEXTURE_BIND_GROUP_STATE_TEXTURES,

        // holding command/compute.rs:429 while locking command/memory_init.rs:79
        // holding command/transfer.rs:803 while locking command/memory_init.rs:79
        // holding command/transfer.rs:969 while locking command/memory_init.rs:79
        TEXTURE_INITIALIZATION_STATUS,

        // holding command/clear.rs:252 while locking:
        //     command/clear.rs:282
        //     command/clear.rs:324
        // holding command/compute.rs:429 while locking:
        //     command/clear.rs:282
        //     command/clear.rs:324
        // holding command/transfer.rs:969 while locking:
        //     command/clear.rs:282
        //     command/clear.rs:324
        // holding device/queue.rs:828 while locking:
        //     command/clear.rs:282
        //     command/clear.rs:324
        TEXTURE_CLEAR_MODE,
    };

    rank BUFFER_MAP_STATE "Buffer::map_state" followed by {
        // holding resource.rs:445 while locking resource.rs:488
        DEVICE_PENDING_WRITES,

        // holding resource.rs:445 while locking:
        //     resource.rs:452
        //     resource.rs:515
        DEVICE_TRACE,
    };

    rank DEVICE_PENDING_WRITES "Device::pending_writes" followed by {
        // holding device/queue.rs:456 while locking device/queue.rs:629
        DEVICE_SNATCHABLE_LOCK,

        // holding device/queue.rs:1462 while locking device/resource.rs:323
        // holding resource.rs:574 while locking device/resource.rs:323
        // holding resource.rs:911 while locking device/resource.rs:323
        DEVICE_LIFE_TRACKER,

        // holding device/queue.rs:1462 while locking command/allocator.rs:39
        COMMAND_ALLOCATOR_FREE_ENCODERS,

        // holding device/queue.rs:456 while locking identity.rs:107
        IDENTITY_MANAGER_VALUES,

        // holding device/queue.rs:456 while locking device/queue.rs:619
        // holding device/queue.rs:1462 while locking device/queue.rs:1466
        REGISTRY_STORAGE,

        // holding device/queue.rs:456 while locking:
        //     device/queue.rs:338
        //     device/queue.rs:343
        STAGING_BUFFER_RAW,

        // holding device/queue.rs:792 while locking device/queue.rs:807
        TEXTURE_INITIALIZATION_STATUS,
    };

    rank DEVICE_LIFE_TRACKER "Device::life_tracker" followed by {
        // holding device/resource.rs:323 while locking device/resource.rs:445
        DEVICE_TEMP_SUSPECTED,

        // holding device/resource.rs:323 while locking:
        //     device/life.rs:841
        //     device/life.rs:869
        BUFFER_MAP_STATE,

        // holding device/resource.rs:323 while locking command/allocator.rs:51
        COMMAND_ALLOCATOR_FREE_ENCODERS,

        // holding device/resource.rs:323 while locking device/mod.rs:362
        BUFFER_INITIALIZATION_STATUS,

        // holding device/resource.rs:323 while locking:
        //     device/mod.rs:330
        //     device/mod.rs:357
        BUFFER_SYNC_MAPPED_WRITES,

        // holding device/resource.rs:323 while locking:
        //     resource.rs:646
        //     resource.rs:1087
        DEVICE_DEFERRED_DESTROY,

        // holding device/resource.rs:323 while locking:
        //     binding_model.rs:491
        //     binding_model.rs:637
        //     binding_model.rs:872
        //     device/resource.rs:3702
        //     pipeline.rs:63
        //     pipeline.rs:230
        //     pipeline.rs:480
        //     resource.rs:403
        //     resource.rs:656
        //     resource.rs:1100
        //     resource.rs:1300
        //     resource.rs:1428
        DEVICE_TRACE,

        // holding device/resource.rs:323 while locking:
        //     device/life.rs:501
        //     device/life.rs:540
        //     device/life.rs:579
        //     device/life.rs:591
        //     device/life.rs:603
        //     device/life.rs:615
        //     device/life.rs:652
        //     device/life.rs:670
        //     device/life.rs:715
        //     device/life.rs:830
        DEVICE_TRACKERS,

        // holding device/resource.rs:323 while locking pool.rs:106
        RESOURCE_POOL_INNER,

        // holding device/resource.rs:323 while locking track/mod.rs:210
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,

        // holding device/resource.rs:323 while locking resource.rs:698
        STAGING_BUFFER_RAW,
    };

    rank DEVICE_FENCE "Device::fence" followed by {
        // holding device/queue.rs:1165 while locking device/queue.rs:1462
        DEVICE_PENDING_WRITES,

        // holding device/global.rs:2147 while locking device/resource.rs:323
        // holding device/queue.rs:1165 while locking device/resource.rs:323
        DEVICE_LIFE_TRACKER,

        // holding device/queue.rs:1165 while locking device/queue.rs:1178
        REGISTRY_STORAGE,
    };

    rank DEVICE_TRACKERS "Device::trackers" followed by {
        // holding device/queue.rs:817 while locking device/queue.rs:828
        // holding device/resource.rs:3651 while locking:
        //     resource.rs:550
        //     resource.rs:878
        DEVICE_SNATCHABLE_LOCK,

        // holding device/resource.rs:3651 while locking:
        //     resource.rs:574
        //     resource.rs:911
        DEVICE_PENDING_WRITES,

        // holding device/resource.rs:3651 while locking resource.rs:559
        BUFFER_BIND_GROUPS,

        // holding device/life.rs:540 while locking track/buffer.rs:83
        BUFFER_BIND_GROUP_STATE_BUFFERS,

        // holding device/queue.rs:1402 while locking command/memory_init.rs:180
        BUFFER_INITIALIZATION_STATUS,

        // holding device/life.rs:501 while locking command/bundle.rs:877
        // holding device/life.rs:540 while locking binding_model.rs:872
        // holding device/life.rs:579 while locking resource.rs:1300
        // holding device/life.rs:603 while locking resource.rs:1428
        // holding device/life.rs:615 while locking resource.rs:403
        // holding device/life.rs:652 while locking:
        //     pipeline.rs:63
        //     pipeline.rs:230
        // holding device/life.rs:670 while locking:
        //     pipeline.rs:63
        //     pipeline.rs:480
        // holding device/life.rs:715 while locking resource.rs:1532
        // holding device/resource.rs:3651 while locking:
        //     resource.rs:545
        //     resource.rs:873
        DEVICE_TRACE,

        // holding device/life.rs:501 while locking device/life.rs:510
        RENDER_BUNDLE_SCOPE_BUFFERS,

        // holding device/life.rs:501 while locking device/life.rs:515
        RENDER_BUNDLE_SCOPE_TEXTURES,

        // holding device/life.rs:501 while locking device/life.rs:520
        RENDER_BUNDLE_SCOPE_BIND_GROUPS,

        // holding device/life.rs:501 while locking device/life.rs:525
        RENDER_BUNDLE_SCOPE_RENDER_PIPELINES,

        // holding device/life.rs:501 while locking device/life.rs:530
        RENDER_BUNDLE_SCOPE_QUERY_SETS,

        // holding device/life.rs:501 while locking track/mod.rs:210
        // holding device/life.rs:540 while locking track/mod.rs:210
        // holding device/life.rs:579 while locking track/mod.rs:210
        // holding device/life.rs:591 while locking track/mod.rs:210
        // holding device/life.rs:603 while locking track/mod.rs:210
        // holding device/life.rs:615 while locking track/mod.rs:210
        // holding device/life.rs:652 while locking track/mod.rs:210
        // holding device/life.rs:670 while locking track/mod.rs:210
        // holding device/life.rs:715 while locking track/mod.rs:210
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,

        // holding device/life.rs:540 while locking track/stateless.rs:57
        STATELESS_BIND_GROUP_STATE_RESOURCES,

        // holding device/resource.rs:3651 while locking resource.rs:895
        TEXTURE_BIND_GROUPS,

        // holding device/life.rs:540 while locking track/texture.rs:182
        TEXTURE_BIND_GROUP_STATE_TEXTURES,

        // holding device/queue.rs:1402 while locking:
        //     command/memory_init.rs:281
        //     command/memory_init.rs:341
        TEXTURE_INITIALIZATION_STATUS,

        // holding device/life.rs:591 while locking resource.rs:784
        TEXTURE_CLEAR_MODE,

        // holding device/resource.rs:3651 while locking resource.rs:890
        TEXTURE_VIEWS,
    };

    rank REGISTRY_STORAGE "Registry::storage" followed by {
        // holding device/queue.rs:1178 while locking device/queue.rs:1186
        DEVICE_TEMP_SUSPECTED,

        // holding command/mod.rs:428 while locking command/mod.rs:430
        // holding registry.rs:178 while locking command/mod.rs:482
        COMMAND_BUFFER_DATA,

        // holding command/compute.rs:381 while locking command/compute.rs:429
        // holding command/query.rs:426 while locking command/query.rs:452
        // holding device/global.rs:2176 while locking device/global.rs:2146
        // holding device/resource.rs:2212 while locking device/resource.rs:2220
        DEVICE_SNATCHABLE_LOCK,

        // holding hub.rs:220 while locking:
        //     device/resource.rs:167
        //     device/resource.rs:3681
        // holding hub.rs:235 while locking device/resource.rs:167
        DEVICE_PENDING_WRITES,

        // holding hub.rs:220 while locking device/resource.rs:323
        DEVICE_LIFE_TRACKER,

        // holding hub.rs:220 while locking command/allocator.rs:59
        // holding hub.rs:235 while locking command/allocator.rs:59
        COMMAND_ALLOCATOR_FREE_ENCODERS,

        // holding command/render.rs:1390 while locking track/buffer.rs:172
        BUFFER_BIND_GROUP_STATE_BUFFERS,

        // holding command/bundle.rs:354 while locking:
        //     command/bundle.rs:531
        //     command/bundle.rs:570
        //     command/bundle.rs:693
        //     command/bundle.rs:732
        // holding command/render.rs:1390 while locking:
        //     command/render.rs:1496
        //     command/render.rs:1693
        //     command/render.rs:1760
        //     command/render.rs:2060
        //     command/render.rs:2369
        BUFFER_INITIALIZATION_STATUS,

        // holding device/global.rs:2176 while locking device/resource.rs:334
        DEVICE_DEFERRED_DESTROY,

        // holding hub.rs:220 while locking:
        //     device/resource.rs:172
        //     device/resource.rs:3684
        // holding hub.rs:235 while locking device/resource.rs:172
        DEVICE_FENCE,

        // holding hub.rs:234 while locking binding_model.rs:491
        // holding hub.rs:235 while locking:
        //     binding_model.rs:491
        //     binding_model.rs:637
        DEVICE_TRACE,

        // holding device/global.rs:2176 while locking device/resource.rs:3651
        // holding device/queue.rs:619 while locking device/queue.rs:623
        DEVICE_TRACKERS,

        // holding command/compute.rs:381 while locking:
        //     track/mod.rs:557
        //     track/mod.rs:569
        // holding command/render.rs:1390 while locking:
        //     track/mod.rs:557
        //     track/mod.rs:569
        DEVICE_USAGE_SCOPES,

        // holding instance.rs:1073 while locking identity.rs:113
        // holding registry.rs:199 while locking registry.rs:204
        IDENTITY_MANAGER_VALUES,

        // holding command/bundle.rs:352 while locking command/bundle.rs:353
        // holding command/bundle.rs:353 while locking command/bundle.rs:354
        // holding command/compute.rs:380 while locking command/compute.rs:381
        // holding command/compute_command.rs:82 while locking command/compute_command.rs:83
        // holding command/compute_command.rs:83 while locking command/compute_command.rs:84
        // holding command/compute_command.rs:84 while locking command/compute_command.rs:85
        // holding command/query.rs:426 while locking command/query.rs:437
        // holding command/render.rs:1385 while locking command/render.rs:1386
        // holding command/render.rs:1386 while locking command/render.rs:1387
        // holding command/render.rs:1387 while locking command/render.rs:1388
        // holding command/render.rs:1388 while locking command/render.rs:1389
        // holding command/render.rs:1389 while locking command/render.rs:1390
        // holding device/global.rs:1621 while locking device/global.rs:1622
        // holding device/global.rs:1753 while locking device/global.rs:1754
        // holding device/resource.rs:2210 while locking device/resource.rs:2211
        // holding device/resource.rs:2211 while locking device/resource.rs:2212
        // holding device/resource.rs:2749 while locking device/resource.rs:2751
        // holding device/resource.rs:2888 while locking device/resource.rs:2889
        // holding global.rs:95 while locking hub.rs:220
        // holding global.rs:135 while locking:
        //     hub.rs:220
        //     hub.rs:259
        // holding hub.rs:220 while locking:
        //     hub.rs:227
        //     hub.rs:228
        //     hub.rs:229
        //     hub.rs:230
        //     hub.rs:231
        //     hub.rs:232
        //     hub.rs:233
        //     hub.rs:234
        //     hub.rs:235
        //     hub.rs:236
        //     hub.rs:237
        //     hub.rs:238
        //     hub.rs:254
        REGISTRY_STORAGE,

        // holding command/bundle.rs:354 while locking:
        //     command/bundle.rs:369
        //     command/bundle.rs:519
        //     command/bundle.rs:558
        //     command/bundle.rs:685
        //     command/bundle.rs:724
        //     track/mod.rs:527
        // holding command/render.rs:1390 while locking track/mod.rs:619
        RENDER_BUNDLE_SCOPE_BUFFERS,

        // holding command/bundle.rs:354 while locking:
        //     command/bundle.rs:374
        //     track/mod.rs:530
        // holding command/render.rs:1390 while locking track/mod.rs:621
        RENDER_BUNDLE_SCOPE_TEXTURES,

        // holding command/bundle.rs:354 while locking:
        //     command/bundle.rs:379
        //     command/bundle.rs:411
        // holding command/render.rs:1390 while locking track/mod.rs:710
        RENDER_BUNDLE_SCOPE_BIND_GROUPS,

        // holding command/bundle.rs:354 while locking:
        //     command/bundle.rs:384
        //     command/bundle.rs:476
        // holding command/render.rs:1390 while locking track/mod.rs:712
        RENDER_BUNDLE_SCOPE_RENDER_PIPELINES,

        // holding command/bundle.rs:354 while locking command/bundle.rs:389
        // holding command/render.rs:1390 while locking track/mod.rs:714
        RENDER_BUNDLE_SCOPE_QUERY_SETS,

        // holding hub.rs:234 while locking pool.rs:106
        RESOURCE_POOL_INNER,

        // holding command/bundle.rs:354 while locking track/mod.rs:206
        // holding command/compute.rs:381 while locking track/mod.rs:214
        // holding command/render.rs:1390 while locking track/mod.rs:214
        // holding hub.rs:234 while locking track/mod.rs:210
        // holding hub.rs:235 while locking track/mod.rs:210
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,

        // holding command/render.rs:1390 while locking track/texture.rs:343
        TEXTURE_BIND_GROUP_STATE_TEXTURES,

        // holding command/render.rs:1390 while locking command/memory_init.rs:79
        TEXTURE_INITIALIZATION_STATUS,
    };

    rank RENDER_BUNDLE_SCOPE_BUFFERS "RenderBundleScope::buffers" followed by {
        // holding track/mod.rs:527 while locking track/buffer.rs:172
        BUFFER_BIND_GROUP_STATE_BUFFERS,

        // holding command/bundle.rs:369 while locking track/mod.rs:214
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank RENDER_BUNDLE_SCOPE_TEXTURES "RenderBundleScope::textures" followed by {
        // holding command/bundle.rs:374 while locking track/mod.rs:214
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,

        // holding track/mod.rs:530 while locking track/texture.rs:343
        TEXTURE_BIND_GROUP_STATE_TEXTURES,
    };

    rank RENDER_BUNDLE_SCOPE_BIND_GROUPS "RenderBundleScope::bind_groups" followed by {
        // holding command/bundle.rs:379 while locking track/mod.rs:214
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank RENDER_BUNDLE_SCOPE_RENDER_PIPELINES "RenderBundleScope::render_pipelines" followed by {
        // holding command/bundle.rs:384 while locking track/mod.rs:214
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank RENDER_BUNDLE_SCOPE_QUERY_SETS "RenderBundleScope::query_sets" followed by {
        // holding command/bundle.rs:389 while locking track/mod.rs:214
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank STAGING_BUFFER_RAW "StagingBuffer::raw" followed by {
        // holding device/queue.rs:650 while locking device/queue.rs:672
        BUFFER_INITIALIZATION_STATUS,

        // holding device/queue.rs:920 while locking device/queue.rs:926
        DEVICE_TRACKERS,

        // holding device/queue.rs:650 while locking registry.rs:139
        REGISTRY_STORAGE,
    };

    rank TEXTURE_INITIALIZATION_STATUS "Texture::initialization_status" followed by {
        // holding device/queue.rs:807 while locking device/queue.rs:838
        DEVICE_SNATCHABLE_LOCK,

        // holding device/queue.rs:807 while locking device/queue.rs:817
        DEVICE_TRACKERS,

        // holding command/memory_init.rs:281 while locking:
        //     command/clear.rs:282
        //     command/clear.rs:324
        TEXTURE_CLEAR_MODE,
    };

    rank TEXTURE_CLEAR_MODE "Texture::clear_mode" followed by {
        // holding resource.rs:784 while locking resource.rs:813
        DEVICE_TRACE,

        // holding command/clear.rs:324 while locking command/clear.rs:455
        TEXTURE_CLEAR_MODE,
    };

    rank COMMAND_ALLOCATOR_FREE_ENCODERS "CommandAllocator::free_encoders" followed by { };
    rank BUFFER_BIND_GROUPS "Buffer::bind_groups" followed by { };
    rank BUFFER_BIND_GROUP_STATE_BUFFERS "BufferBindGroupState::buffers" followed by { };
    rank BUFFER_INITIALIZATION_STATUS "Buffer::initialization_status" followed by { };
    rank BUFFER_SYNC_MAPPED_WRITES "Buffer::sync_mapped_writes" followed by { };
    rank DEVICE_DEFERRED_DESTROY "Device::deferred_destroy" followed by { };
    rank DEVICE_TRACE "Device::trace" followed by { };
    rank DEVICE_USAGE_SCOPES "Device::usage_scopes" followed by { };
    rank IDENTITY_MANAGER_VALUES "IdentityManager::values" followed by { };
    rank RESOURCE_POOL_INNER "ResourcePool::inner" followed by { };
    rank SHARED_TRACKER_INDEX_ALLOCATOR_INNER "SharedTrackerIndexAllocator::inner" followed by { };
    rank STATELESS_BIND_GROUP_STATE_RESOURCES "StatelessBindGroupState::resources" followed by { };
    rank SURFACE_PRESENTATION "Surface::presentation" followed by { };
    rank TEXTURE_BIND_GROUPS "Texture::bind_groups" followed by { };
    rank TEXTURE_BIND_GROUP_STATE_TEXTURES "TextureBindGroupState::textures" followed by { };
    rank TEXTURE_VIEWS "Texture::views" followed by { };
    rank PAWN "pawn" followed by { };
    rank ROOK "rook" followed by { };
    rank KNIGHT "knight" followed by { };
    rank BISHOP "bishop" followed by { };

@jimblandy
Copy link
Member Author

jimblandy commented May 2, 2024

Filed #5647 based on that output.

@jimblandy jimblandy force-pushed the core-lock-observation branch 2 times, most recently from d3b595c to 3711329 Compare May 2, 2024 05:01
@jimblandy
Copy link
Member Author

Better output from 3711329, that lists acquisitions of leaf locks last, since they can't cause deadlocks:

Output from `analyze-locks`
    rank DEVICE_TEMP_SUSPECTED "Device::temp_suspected" followed by {
        // holding device/queue.rs:1186 while locking:
        //     command/mod.rs:310
        //     command/mod.rs:440
        //     command/mod.rs:451
        //     device/queue.rs:1233
        COMMAND_BUFFER_DATA,

        // holding device/queue.rs:1186 while locking device/queue.rs:1402
        DEVICE_TRACKERS,

        // leaf lock acquisitions:
        DEVICE_TRACE,
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank COMMAND_BUFFER_DATA "CommandBuffer::data" followed by {
        // holding device/global.rs:1397 while locking device/resource.rs:504
        DEVICE_TEMP_SUSPECTED,

        // holding command/clear.rs:94 while locking command/clear.rs:118
        // holding command/clear.rs:188 while locking command/clear.rs:252
        // holding command/transfer.rs:584 while locking command/transfer.rs:603
        // holding command/transfer.rs:763 while locking command/transfer.rs:803
        // holding command/transfer.rs:934 while locking command/transfer.rs:969
        DEVICE_SNATCHABLE_LOCK,

        // holding device/queue.rs:1233 while locking device/queue.rs:1261
        BUFFER_MAP_STATE,

        // holding device/global.rs:1397 while locking device/resource.rs:568
        DEVICE_LIFE_TRACKER,

        // holding command/clear.rs:94 while locking command/clear.rs:103
        // holding command/clear.rs:188 while locking registry.rs:139
        // holding command/compute.rs:349 while locking command/compute.rs:380
        // holding command/query.rs:365 while locking command/query.rs:381
        // holding command/query.rs:404 while locking command/query.rs:426
        // holding command/render.rs:1352 while locking command/render.rs:1385
        // holding command/render.rs:2417 while locking command/render.rs:2420
        // holding command/transfer.rs:763 while locking registry.rs:139
        // holding command/transfer.rs:934 while locking registry.rs:139
        // holding command/transfer.rs:1119 while locking registry.rs:139
        REGISTRY_STORAGE,

        // holding device/queue.rs:1233 while locking device/queue.rs:1372
        RENDER_BUNDLE_SCOPE_RENDER_PIPELINES,

        // holding device/queue.rs:1233 while locking device/queue.rs:1376
        RENDER_BUNDLE_SCOPE_QUERY_SETS,

        // leaf lock acquisitions:
        STATELESS_BIND_GROUP_STATE_RESOURCES,
    };

    rank DEVICE_SNATCHABLE_LOCK "Device::snatchable_lock" followed by {
        // holding command/render.rs:1349 while locking:
        //     command/render.rs:1352
        //     command/render.rs:2417
        // holding command/transfer.rs:1117 while locking command/transfer.rs:1119
        COMMAND_BUFFER_DATA,

        // holding device/global.rs:235 while locking device/global.rs:252
        // holding resource.rs:439 while locking resource.rs:445
        BUFFER_MAP_STATE,

        // holding device/global.rs:2146 while locking device/global.rs:2147
        // holding device/queue.rs:1162 while locking device/queue.rs:1165
        DEVICE_FENCE,

        // holding device/global.rs:2503 while locking device/global.rs:2506
        DEVICE_TRACKERS,

        // holding command/render.rs:1349 while locking registry.rs:139
        // holding command/transfer.rs:603 while locking:
        //     command/transfer.rs:606
        //     command/transfer.rs:632
        // holding command/transfer.rs:803 while locking command/transfer.rs:820
        // holding command/transfer.rs:969 while locking command/transfer.rs:1011
        // holding device/queue.rs:838 while locking registry.rs:139
        REGISTRY_STORAGE,

        // holding device/queue.rs:629 while locking device/queue.rs:650
        // holding device/queue.rs:838 while locking:
        //     device/queue.rs:338
        //     device/queue.rs:343
        //     device/queue.rs:920
        STAGING_BUFFER_RAW,

        // holding command/compute.rs:429 while locking command/memory_init.rs:79
        // holding command/transfer.rs:803 while locking command/memory_init.rs:79
        // holding command/transfer.rs:969 while locking command/memory_init.rs:79
        TEXTURE_INITIALIZATION_STATUS,

        // holding command/clear.rs:252 while locking:
        //     command/clear.rs:282
        //     command/clear.rs:324
        // holding command/compute.rs:429 while locking:
        //     command/clear.rs:282
        //     command/clear.rs:324
        // holding command/transfer.rs:969 while locking:
        //     command/clear.rs:282
        //     command/clear.rs:324
        // holding device/queue.rs:828 while locking:
        //     command/clear.rs:282
        //     command/clear.rs:324
        TEXTURE_CLEAR_MODE,

        // leaf lock acquisitions:
        BUFFER_BIND_GROUP_STATE_BUFFERS,
        BUFFER_INITIALIZATION_STATUS,
        BUFFER_SYNC_MAPPED_WRITES,
        DEVICE_USAGE_SCOPES,
        IDENTITY_MANAGER_VALUES,
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
        STATELESS_BIND_GROUP_STATE_RESOURCES,
        TEXTURE_BIND_GROUP_STATE_TEXTURES,
    };

    rank BUFFER_MAP_STATE "Buffer::map_state" followed by {
        // holding resource.rs:445 while locking resource.rs:488
        DEVICE_PENDING_WRITES,

        // leaf lock acquisitions:
        DEVICE_TRACE,
    };

    rank DEVICE_PENDING_WRITES "Device::pending_writes" followed by {
        // holding device/queue.rs:456 while locking device/queue.rs:629
        DEVICE_SNATCHABLE_LOCK,

        // holding device/queue.rs:1462 while locking device/queue.rs:1547
        // holding resource.rs:574 while locking resource.rs:581
        // holding resource.rs:911 while locking resource.rs:918
        DEVICE_LIFE_TRACKER,

        // holding device/queue.rs:456 while locking device/queue.rs:619
        // holding device/queue.rs:1462 while locking device/queue.rs:1466
        REGISTRY_STORAGE,

        // holding device/queue.rs:456 while locking:
        //     device/queue.rs:338
        //     device/queue.rs:343
        STAGING_BUFFER_RAW,

        // holding device/queue.rs:792 while locking device/queue.rs:807
        TEXTURE_INITIALIZATION_STATUS,

        // leaf lock acquisitions:
        COMMAND_ALLOCATOR_FREE_ENCODERS,
        IDENTITY_MANAGER_VALUES,
    };

    rank DEVICE_LIFE_TRACKER "Device::life_tracker" followed by {
        // holding device/resource.rs:434 while locking device/resource.rs:446
        DEVICE_TEMP_SUSPECTED,

        // holding device/resource.rs:434 while locking:
        //     device/life.rs:841
        //     device/life.rs:869
        BUFFER_MAP_STATE,

        // holding device/global.rs:2103 while locking:
        //     device/life.rs:501
        //     device/life.rs:540
        //     device/life.rs:579
        //     device/life.rs:591
        //     device/life.rs:603
        //     device/life.rs:615
        //     device/life.rs:652
        //     device/life.rs:670
        //     device/life.rs:715
        // holding device/resource.rs:434 while locking:
        //     device/life.rs:501
        //     device/life.rs:540
        //     device/life.rs:579
        //     device/life.rs:591
        //     device/life.rs:603
        //     device/life.rs:615
        //     device/life.rs:652
        //     device/life.rs:670
        //     device/life.rs:715
        //     device/life.rs:830
        DEVICE_TRACKERS,

        // holding device/resource.rs:434 while locking resource.rs:698
        STAGING_BUFFER_RAW,

        // leaf lock acquisitions:
        COMMAND_ALLOCATOR_FREE_ENCODERS,
        BUFFER_INITIALIZATION_STATUS,
        BUFFER_SYNC_MAPPED_WRITES,
        DEVICE_DEFERRED_DESTROY,
        DEVICE_TRACE,
        RESOURCE_POOL_INNER,
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank DEVICE_FENCE "Device::fence" followed by {
        // holding device/queue.rs:1165 while locking device/queue.rs:1462
        DEVICE_PENDING_WRITES,

        // holding device/global.rs:2147 while locking device/resource.rs:434
        // holding device/queue.rs:1165 while locking device/resource.rs:434
        DEVICE_LIFE_TRACKER,

        // holding device/queue.rs:1165 while locking device/queue.rs:1178
        REGISTRY_STORAGE,
    };

    rank DEVICE_TRACKERS "Device::trackers" followed by {
        // holding device/queue.rs:817 while locking device/queue.rs:828
        // holding device/resource.rs:3652 while locking:
        //     resource.rs:550
        //     resource.rs:878
        DEVICE_SNATCHABLE_LOCK,

        // holding device/resource.rs:3652 while locking:
        //     resource.rs:574
        //     resource.rs:911
        DEVICE_PENDING_WRITES,

        // holding device/life.rs:501 while locking device/life.rs:510
        RENDER_BUNDLE_SCOPE_BUFFERS,

        // holding device/life.rs:501 while locking device/life.rs:515
        RENDER_BUNDLE_SCOPE_TEXTURES,

        // holding device/life.rs:501 while locking device/life.rs:520
        RENDER_BUNDLE_SCOPE_BIND_GROUPS,

        // holding device/life.rs:501 while locking device/life.rs:525
        RENDER_BUNDLE_SCOPE_RENDER_PIPELINES,

        // holding device/life.rs:501 while locking device/life.rs:530
        RENDER_BUNDLE_SCOPE_QUERY_SETS,

        // holding device/queue.rs:1402 while locking:
        //     command/memory_init.rs:281
        //     command/memory_init.rs:341
        TEXTURE_INITIALIZATION_STATUS,

        // holding device/life.rs:591 while locking resource.rs:784
        TEXTURE_CLEAR_MODE,

        // leaf lock acquisitions:
        BUFFER_BIND_GROUPS,
        BUFFER_BIND_GROUP_STATE_BUFFERS,
        BUFFER_INITIALIZATION_STATUS,
        DEVICE_TRACE,
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
        STATELESS_BIND_GROUP_STATE_RESOURCES,
        TEXTURE_BIND_GROUPS,
        TEXTURE_BIND_GROUP_STATE_TEXTURES,
        TEXTURE_VIEWS,
    };

    rank REGISTRY_STORAGE "Registry::storage" followed by {
        // holding device/queue.rs:1178 while locking device/queue.rs:1186
        DEVICE_TEMP_SUSPECTED,

        // holding command/mod.rs:428 while locking command/mod.rs:430
        // holding registry.rs:178 while locking command/mod.rs:482
        COMMAND_BUFFER_DATA,

        // holding command/compute.rs:381 while locking command/compute.rs:429
        // holding command/query.rs:426 while locking command/query.rs:452
        // holding device/global.rs:2176 while locking device/global.rs:2146
        // holding device/resource.rs:2213 while locking device/resource.rs:2221
        DEVICE_SNATCHABLE_LOCK,

        // holding hub.rs:220 while locking:
        //     device/resource.rs:167
        //     device/resource.rs:3682
        // holding hub.rs:235 while locking device/resource.rs:167
        DEVICE_PENDING_WRITES,

        // holding hub.rs:220 while locking device/resource.rs:3694
        DEVICE_LIFE_TRACKER,

        // holding hub.rs:220 while locking:
        //     device/resource.rs:172
        //     device/resource.rs:3685
        // holding hub.rs:235 while locking device/resource.rs:172
        DEVICE_FENCE,

        // holding device/global.rs:2176 while locking device/resource.rs:3652
        // holding device/queue.rs:619 while locking device/queue.rs:623
        DEVICE_TRACKERS,

        // holding command/bundle.rs:352 while locking command/bundle.rs:353
        // holding command/bundle.rs:353 while locking command/bundle.rs:354
        // holding command/compute.rs:380 while locking command/compute.rs:381
        // holding command/compute_command.rs:82 while locking command/compute_command.rs:83
        // holding command/compute_command.rs:83 while locking command/compute_command.rs:84
        // holding command/compute_command.rs:84 while locking command/compute_command.rs:85
        // holding command/query.rs:426 while locking command/query.rs:437
        // holding command/render.rs:1385 while locking command/render.rs:1386
        // holding command/render.rs:1386 while locking command/render.rs:1387
        // holding command/render.rs:1387 while locking command/render.rs:1388
        // holding command/render.rs:1388 while locking command/render.rs:1389
        // holding command/render.rs:1389 while locking command/render.rs:1390
        // holding device/global.rs:1621 while locking device/global.rs:1622
        // holding device/global.rs:1753 while locking device/global.rs:1754
        // holding device/resource.rs:2211 while locking device/resource.rs:2212
        // holding device/resource.rs:2212 while locking device/resource.rs:2213
        // holding device/resource.rs:2750 while locking device/resource.rs:2752
        // holding device/resource.rs:2889 while locking device/resource.rs:2890
        // holding global.rs:95 while locking hub.rs:220
        // holding global.rs:135 while locking:
        //     hub.rs:220
        //     hub.rs:259
        // holding hub.rs:220 while locking:
        //     hub.rs:227
        //     hub.rs:228
        //     hub.rs:229
        //     hub.rs:230
        //     hub.rs:231
        //     hub.rs:232
        //     hub.rs:233
        //     hub.rs:234
        //     hub.rs:235
        //     hub.rs:236
        //     hub.rs:237
        //     hub.rs:238
        //     hub.rs:254
        REGISTRY_STORAGE,

        // holding command/bundle.rs:354 while locking:
        //     command/bundle.rs:369
        //     command/bundle.rs:519
        //     command/bundle.rs:558
        //     command/bundle.rs:685
        //     command/bundle.rs:724
        //     track/mod.rs:527
        // holding command/render.rs:1390 while locking track/mod.rs:619
        RENDER_BUNDLE_SCOPE_BUFFERS,

        // holding command/bundle.rs:354 while locking:
        //     command/bundle.rs:374
        //     track/mod.rs:530
        // holding command/render.rs:1390 while locking track/mod.rs:621
        RENDER_BUNDLE_SCOPE_TEXTURES,

        // holding command/bundle.rs:354 while locking:
        //     command/bundle.rs:379
        //     command/bundle.rs:411
        // holding command/render.rs:1390 while locking track/mod.rs:710
        RENDER_BUNDLE_SCOPE_BIND_GROUPS,

        // holding command/bundle.rs:354 while locking:
        //     command/bundle.rs:384
        //     command/bundle.rs:476
        // holding command/render.rs:1390 while locking track/mod.rs:712
        RENDER_BUNDLE_SCOPE_RENDER_PIPELINES,

        // holding command/bundle.rs:354 while locking command/bundle.rs:389
        // holding command/render.rs:1390 while locking track/mod.rs:714
        RENDER_BUNDLE_SCOPE_QUERY_SETS,

        // holding command/render.rs:1390 while locking command/memory_init.rs:79
        TEXTURE_INITIALIZATION_STATUS,

        // leaf lock acquisitions:
        COMMAND_ALLOCATOR_FREE_ENCODERS,
        BUFFER_BIND_GROUP_STATE_BUFFERS,
        BUFFER_INITIALIZATION_STATUS,
        DEVICE_DEFERRED_DESTROY,
        DEVICE_TRACE,
        DEVICE_USAGE_SCOPES,
        IDENTITY_MANAGER_VALUES,
        RESOURCE_POOL_INNER,
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
        TEXTURE_BIND_GROUP_STATE_TEXTURES,
    };

    rank RENDER_BUNDLE_SCOPE_BUFFERS "RenderBundleScope::buffers" followed by {
        // leaf lock acquisitions:
        BUFFER_BIND_GROUP_STATE_BUFFERS,
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank RENDER_BUNDLE_SCOPE_TEXTURES "RenderBundleScope::textures" followed by {
        // leaf lock acquisitions:
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
        TEXTURE_BIND_GROUP_STATE_TEXTURES,
    };

    rank RENDER_BUNDLE_SCOPE_BIND_GROUPS "RenderBundleScope::bind_groups" followed by {
        // leaf lock acquisitions:
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank RENDER_BUNDLE_SCOPE_RENDER_PIPELINES "RenderBundleScope::render_pipelines" followed by {
        // leaf lock acquisitions:
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank RENDER_BUNDLE_SCOPE_QUERY_SETS "RenderBundleScope::query_sets" followed by {
        // leaf lock acquisitions:
        SHARED_TRACKER_INDEX_ALLOCATOR_INNER,
    };

    rank STAGING_BUFFER_RAW "StagingBuffer::raw" followed by {
        // holding device/queue.rs:920 while locking device/queue.rs:926
        DEVICE_TRACKERS,

        // holding device/queue.rs:650 while locking registry.rs:139
        REGISTRY_STORAGE,

        // leaf lock acquisitions:
        BUFFER_INITIALIZATION_STATUS,
    };

    rank TEXTURE_INITIALIZATION_STATUS "Texture::initialization_status" followed by {
        // holding device/queue.rs:807 while locking device/queue.rs:838
        DEVICE_SNATCHABLE_LOCK,

        // holding device/queue.rs:807 while locking device/queue.rs:817
        DEVICE_TRACKERS,

        // holding command/memory_init.rs:281 while locking:
        //     command/clear.rs:282
        //     command/clear.rs:324
        TEXTURE_CLEAR_MODE,
    };

    rank TEXTURE_CLEAR_MODE "Texture::clear_mode" followed by {
        // holding command/clear.rs:324 while locking command/clear.rs:455
        TEXTURE_CLEAR_MODE,

        // leaf lock acquisitions:
        DEVICE_TRACE,
    };

    rank COMMAND_ALLOCATOR_FREE_ENCODERS "CommandAllocator::free_encoders" followed by { };
    rank BUFFER_BIND_GROUPS "Buffer::bind_groups" followed by { };
    rank BUFFER_BIND_GROUP_STATE_BUFFERS "BufferBindGroupState::buffers" followed by { };
    rank BUFFER_INITIALIZATION_STATUS "Buffer::initialization_status" followed by { };
    rank BUFFER_SYNC_MAPPED_WRITES "Buffer::sync_mapped_writes" followed by { };
    rank DEVICE_DEFERRED_DESTROY "Device::deferred_destroy" followed by { };
    rank DEVICE_TRACE "Device::trace" followed by { };
    rank DEVICE_USAGE_SCOPES "Device::usage_scopes" followed by { };
    rank IDENTITY_MANAGER_VALUES "IdentityManager::values" followed by { };
    rank RESOURCE_POOL_INNER "ResourcePool::inner" followed by { };
    rank SHARED_TRACKER_INDEX_ALLOCATOR_INNER "SharedTrackerIndexAllocator::inner" followed by { };
    rank STATELESS_BIND_GROUP_STATE_RESOURCES "StatelessBindGroupState::resources" followed by { };
    rank SURFACE_PRESENTATION "Surface::presentation" followed by { };
    rank TEXTURE_BIND_GROUPS "Texture::bind_groups" followed by { };
    rank TEXTURE_BIND_GROUP_STATE_TEXTURES "TextureBindGroupState::textures" followed by { };
    rank TEXTURE_VIEWS "Texture::views" followed by { };
    rank PAWN "pawn" followed by { };
    rank ROOK "rook" followed by { };
    rank KNIGHT "knight" followed by { };
    rank BISHOP "bishop" followed by { };

@jimblandy
Copy link
Member Author

As far as I can tell this is working. I'll take it out of draft as soon as #5610 has landed.

@ErichDonGubler, thanks for the WIP feedback, I'll look it over soon.

@jimblandy
Copy link
Member Author

@ErichDonGubler, I think this addresses your comments. Please look over the ones I left unresolved and see what you think.

@jimblandy jimblandy marked this pull request as ready for review May 3, 2024 20:44
@jimblandy
Copy link
Member Author

Prerequisites have landed, so taking this out of draft.

@ErichDonGubler
Copy link
Member

Planning on reviewing on Monday, but may postpone if a higher priority arises for my personal workload. Jim is out for next week, so there's not a ton of pressure on this PR, ATM.

@jimblandy
Copy link
Member Author

jimblandy commented May 6, 2024

@ErichDonGubler I'm "out" but not "out", if you know what I mean. It'd be helpful to me to get this landed this week.

@ErichDonGubler
Copy link
Member

@jimblandy: To be clear, I don't intend to postpone longer than a day or so. I hate leaving open PRs to potentially bitrot and cause headaches.

Copy link
Member

@ErichDonGubler ErichDonGubler left a comment

Choose a reason for hiding this comment

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

I don't see anything blocking left, so :shipit:! @jimblandy: I left s'more notes I'd like to be considered for going forward, but once you mark them as Resolved, you just need to autosquash-rebase and merge!

@ErichDonGubler
Copy link
Member

@jimblandy: I noticed you'd added some link entries in ObservationLog::locations_seen for symbols that were already in scope. Just pushed a fixup! (429040d) to remove those

@ErichDonGubler ErichDonGubler force-pushed the core-lock-observation branch 2 times, most recently from 4a92bfa to 7d5cd55 Compare May 7, 2024 16:25
Add a new module `lock::observing`, enabled by the `observe-locks`
feature, that records all nested lock acquisitions in trace files.

Add a new utility to the workspace, `lock-analyzer`, that reads the
files written by the `observe-locks` feature and writes out a new
`define_lock_ranks!` macro invocation that covers all observed lock
usage, along with comments giving the held and acquired source
locations.
@ErichDonGubler
Copy link
Member

Just rebased this change, and autosquashed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants