# Nested map lookups are very inefficient

**URL:** <https://forums.unrealengine.com/t/nested-map-lookups-are-very-inefficient/2753912>\
**Category:** Issues and Bug Reporting\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, closed, fortnite\
**Created:** [September 1, 2026, 9:36pm UTC](https://forums.unrealengine.com/t/nested-map-lookups-are-very-inefficient/2753912 "2026-09-01T21:36:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [September 1, 2026, 9:36pm UTC](https://forums.unrealengine.com/t/nested-map-lookups-are-very-inefficient/2753912/1 "2026-09-01T21:36:32Z")

</div>

### Summary

Not sure how to explain this, nested map lookups are extremely inefficient somehow, looks like the entire inner map gets copied on each lookup

Happens with `[][t]u` and `[t][u]v` but not `[][]t` nor `[t][]u`. The performance cost is exponential, it is 100x in the following repro :

```verse
MakeBigArray()<transacts>:[]logic = for(I := 0..1000). true

MakeBigMap()<transacts>:[int]logic =
    var TempMap : [int]logic = map{}
    for(I := 0..1000):
        option. set TempMap[I] = true
    TempMap

# Forces lookup by reference
big_array(t:type) := class:
    Array: []t
    Get(Index: int)<reads><decides>:t = Array[Index]

# Forces lookup by reference
big_map(t:type) := class:
    Map: [int]t
    Get(Index: int)<reads><decides>:t = Map[Index]

LookUpArrays()<suspends>:void=
    #####################################################
    ####### NOT LAGGY (first dimension is array) ########
    #####################################################

    # SomeBigArray : []logic = MakeBigArray()

    # # Slow
    # var BigNestedMap : [][]logic = array{MakeBigArray()}

    # profile("Slow Lookup"):
    # for(__ := 0..1000):
    # option. BigNestedMap[0][0]
    
    # # Fast
    # var BetterBigNestedMap : []big_array(logic) = array{big_array(logic){Array := SomeBigArray}}

    # profile("Fast Lookup"):
    # for(__ := 0..1000):
    # option. BetterBigNestedMap[0].Get[0]

    # SomeBigArray : []logic = MakeBigArray()

    # # Slow
    # var BigNestedMap : [int][]logic = map{}
    # option. set BigNestedMap[0] = MakeBigArray()

    # profile("Slow Lookup"):
    # for(__ := 0..1000):
    # option. BigNestedMap[0][0]
    
    # # Fast
    # var BetterBigNestedMap : [int]big_array(logic) = map{}
    # option. set BetterBigNestedMap[0] = big_array(logic){Array := SomeBigArray}

    # profile("Fast Lookup"):
    # for(__ := 0..1000):
    # option. BetterBigNestedMap[0].Get[0]

    #####################################################
    ################ LAGGY REPROS #######################
    #####################################################

    # Slow
    var BigNestedMap : [][int]logic = array{MakeBigMap()}

    profile("Slow Lookup"): # 500ms
        for(__ := 0..1000):
            option. BigNestedMap[0][0]
    
    # Fast
    var BetterBigNestedMap : []big_map(logic) = array{big_map(logic){Map := MakeBigMap()}}

    profile("Fast Lookup"): # 5ms
        for(__ := 0..1000):
            option. BetterBigNestedMap[0].Get[0]

    # # Slow
    # var BigNestedMap : [int][int]logic = map{}
    # option. set BigNestedMap[0] = MakeBigMap()

    # profile("Slow Lookup"):
    # for(__ := 0..1000):
    # option. BigNestedMap[0][0]
    
    # # Fast
    # var BetterBigNestedMap : [int]big_map(logic) = map{}
    # option. set BetterBigNestedMap[0] = big_map(logic){Map := MakeBigMap()}

    # profile("Fast Lookup"):
    # for(__ := 0..1000):
    # option. BetterBigNestedMap[0].Get[0]

```

### Please select what you are reporting on:

Verse

### What Type of Bug are you experiencing?

Stability

### Steps to Reproduce

See repro

### Expected Result

Nested lookups shouldn’t pass anything by copy (?)

### Observed Result

Nested lookups pass the whole map by copy (?)

### Platform(s)

PC

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [September 1, 2026, 10:56pm UTC](https://forums.unrealengine.com/t/nested-map-lookups-are-very-inefficient/2753912/3 "2026-09-01T22:56:36Z")

</div>

Just did the same with BigNestedMap[0].Length the cost is 250x after storing the last known Length in the custom big\_map container

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [September 2, 2026, 11:54am UTC](https://forums.unrealengine.com/t/nested-map-lookups-are-very-inefficient/2753912/4 "2026-09-02T11:54:18Z")

</div>

Issue also occurs with weak\_map(agent, \<some\_map\>) and weak\_map(session, \<some\_map\>) which is REALLY unfortunate since you can’t iterate over them in order to clean up a key (weak\_map(agent) hits the hardest here).

It’s less unfortunate if weak\_map(agent) are not handled the same way weak\_map(player) are (as a global weak\_map and/or a nested one). I couldn’t try adding 1k players on my map but could repro with 50 participant agents (which is easy to get in a real session if the weak\_map keys are never removed)

---

<div class="post-metadata">

**Author:** ![NickDroz](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/nickdroz/32/891051_2.png) [@NickDroz](https://forums.unrealengine.com/u/NickDroz)\
**Post date:** [September 8, 2026, 7:18pm UTC](https://forums.unrealengine.com/t/nested-map-lookups-are-very-inefficient/2753912/6 "2026-09-08T19:18:08Z")

</div>

Hello @im_a_lama this bug is going to be closed/backlogged due to the fact that this should be resolved when we ship the New VM this year.

---

<div class="post-metadata">

**Author:** ![Bug-Reporter](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bug-reporter/32/1223650_2.png) [@Bug-Reporter](https://forums.unrealengine.com/u/Bug-Reporter)\
**Post date:** [September 8, 2026, 8:00pm UTC](https://forums.unrealengine.com/t/nested-map-lookups-are-very-inefficient/2753912/7 "2026-09-08T20:00:30Z")

</div>

FORT-1148028 has been ‘Closed’. This is working as intended by design.
