Skip to content

Follow-up from "Optimize binary decoder for unions"

The following discussion from !24 (merged) should be addressed:

  • @raphael-proust started a discussion:

    When we build the union originally, there's sharing between the array and the list: elements of the lists that have the Tag tag are physically equal to one element of the array.

    After lifting, there is no sharing. I don't know if this is a problem, it shouldn't take too much space, and for the cache it should also be ok because for most encodings we use either the json or the binary encoding, but rarely both repeatedly.


    If we want to preserve sharing, we can do something along the lines of:

    let tagged_cases = Array.copy tagged_cases in
    let cases =
      List.map
        (fun case ->
          let case = lift case in
          if is_tagged case then
            update_array tagged_cases case;
          case)
    in
    

    (Note: the same comment applies to other occurrences of this pattern of code.)

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information