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

org.jetbrains.org.objectweb.asm.MethodTooLargeException: Method too large #252

Closed
sliskiCode opened this issue Mar 27, 2023 · 5 comments · Fixed by #277
Closed

org.jetbrains.org.objectweb.asm.MethodTooLargeException: Method too large #252

sliskiCode opened this issue Mar 27, 2023 · 5 comments · Fixed by #277
Labels
bug Something isn't working component-codegen
Milestone

Comments

@sliskiCode
Copy link

sliskiCode commented Mar 27, 2023

Hi there,

I have discovered that codegen breaks when message has to many cases in oneof {} block. It looks like generated function under descriptor is too large for JVM byte code. Function could be sliced in a way that every add() list invocation is a separate method. Wdyt?

Can be reproduce by writing UT under:
pbandk.gen.CodeGeneratorTest

@Test
fun testBigOneof() {
    val result = compileProto("test_big_oneof.proto", "kotlin_package_mapping=foobar->newname.pkg")

    assertEquals(ExitCode.OK, result.exitCode, result.messages)
}

test_big_oneof.proto

syntax = "proto3";
package sample.events;

import "google/protobuf/descriptor.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";

message Metadata {
  string team_owner = 1;
  string description = 2;
}

extend google.protobuf.FieldOptions {
  Metadata metadata = 100000;
}

message AnalyticsEvent2 {
  oneof only_one_event_limiter {
    Tap tap = 1;
  }
}

message Tap {
  oneof tap_details {
    Message1 message_1 = 1 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message2 message_2 = 2 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message3 message_3 = 3 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message4 message_4 = 4 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message5 message_5 = 5 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message6 message_6 = 6 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message7 message_7 = 7 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message8 message_8 = 8 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message9 message_9 = 9 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message10 message_10 = 10 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message11 message_11 = 11 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message12 message_12 = 12 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message13 message_13 = 13 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message14 message_14 = 14 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message15 message_15 = 15 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message16 message_16 = 16 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message17 message_17 = 17 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message18 message_18 = 18 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message19 message_19 = 19 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message20 message_20 = 20 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message21 message_21 = 21 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message22 message_22 = 22 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message23 message_23 = 23 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message24 message_24 = 24 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message25 message_25 = 25 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message26 message_26 = 26 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message27 message_27 = 27 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message28 message_28 = 28 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message29 message_29 = 29 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message30 message_30 = 30 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message31 message_31 = 31 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message32 message_32 = 32 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message33 message_33 = 33 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message34 message_34 = 34 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message35 message_35 = 35 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message36 message_36 = 36 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message37 message_37 = 37 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message38 message_38 = 38 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message39 message_39 = 39 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message40 message_40 = 40 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message41 message_41 = 41 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message42 message_42 = 42 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message43 message_43 = 43 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message44 message_44 = 44 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message45 message_45 = 45 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message46 message_46 = 46 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message47 message_47 = 47 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message48 message_48 = 48 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message49 message_49 = 49 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message50 message_50 = 50 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message51 message_51 = 51 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message52 message_52 = 52 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message53 message_53 = 53 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message54 message_54 = 54 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message55 message_55 = 55 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message56 message_56 = 56 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message57 message_57 = 57 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message58 message_58 = 58 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message59 message_59 = 59 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message60 message_60 = 60 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message61 message_61 = 61 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message62 message_62 = 62 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message63 message_63 = 63 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message64 message_64 = 64 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message65 message_65 = 65 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message66 message_66 = 66 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message67 message_67 = 67 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message68 message_68 = 68 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message69 message_69 = 69 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message70 message_70 = 70 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message71 message_71 = 71 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message72 message_72 = 72 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message73 message_73 = 73 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message74 message_74 = 74 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message75 message_75 = 75 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message76 message_76 = 76 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message77 message_77 = 77 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message78 message_78 = 78 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message79 message_79 = 79 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message80 message_80 = 80 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message81 message_81 = 81 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message82 message_82 = 82 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message83 message_83 = 83 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message84 message_84 = 84 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message85 message_85 = 85 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message86 message_86 = 86 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message87 message_87 = 87 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message88 message_88 = 88 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message89 message_89 = 89 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message90 message_90 = 90 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message91 message_91 = 91 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message92 message_92 = 92 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message93 message_93 = 93 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message94 message_94 = 94 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message95 message_95 = 95 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message96 message_96 = 96 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message97 message_97 = 97 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message98 message_98 = 98 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message99 message_99 = 99 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message100 message_100 = 100 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message101 message_101 = 101 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message102 message_102 = 102 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message103 message_103 = 103 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message104 message_104 = 104 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message105 message_105 = 105 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message106 message_106 = 106 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message107 message_107 = 107 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message108 message_108 = 108 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message109 message_109 = 109 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message110 message_110 = 110 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message111 message_111 = 111 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message112 message_112 = 112 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message113 message_113 = 113 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message114 message_114 = 114 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message115 message_115 = 115 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message116 message_116 = 116 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message117 message_117 = 117 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message118 message_118 = 118 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message119 message_119 = 119 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message120 message_120 = 120 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message121 message_121 = 121 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message122 message_122 = 122 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message123 message_123 = 123 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message124 message_124 = 124 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message125 message_125 = 125 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message126 message_126 = 126 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message127 message_127 = 127 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message128 message_128 = 128 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message129 message_129 = 129 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message130 message_130 = 130 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message131 message_131 = 131 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
    Message132 message_132 = 132 [
      (metadata).team_owner = "team_owner",
      (metadata).description = "Lorem ipsum Lorem ipsum Lorem ipsum Lorem ipsum"
    ];
  }
}

message Message1 {}
message Message2 {}
message Message3 {}
message Message4 {}
message Message5 {}
message Message6 {}
message Message7 {}
message Message8 {}
message Message9 {}
message Message10 {}
message Message11 {}
message Message12 {}
message Message13 {}
message Message14 {}
message Message15 {}
message Message16 {}
message Message17 {}
message Message18 {}
message Message19 {}
message Message20 {}
message Message21 {}
message Message22 {}
message Message23 {}
message Message24 {}
message Message25 {}
message Message26 {}
message Message27 {}
message Message28 {}
message Message29 {}
message Message30 {}
message Message31 {}
message Message32 {}
message Message33 {}
message Message34 {}
message Message35 {}
message Message36 {}
message Message37 {}
message Message38 {}
message Message39 {}
message Message40 {}
message Message41 {}
message Message42 {}
message Message43 {}
message Message44 {}
message Message45 {}
message Message46 {}
message Message47 {}
message Message48 {}
message Message49 {}
message Message50 {}
message Message51 {}
message Message52 {}
message Message53 {}
message Message54 {}
message Message55 {}
message Message56 {}
message Message57 {}
message Message58 {}
message Message59 {}
message Message60 {}
message Message61 {}
message Message62 {}
message Message63 {}
message Message64 {}
message Message65 {}
message Message66 {}
message Message67 {}
message Message68 {}
message Message69 {}
message Message70 {}
message Message71 {}
message Message72 {}
message Message73 {}
message Message74 {}
message Message75 {}
message Message76 {}
message Message77 {}
message Message78 {}
message Message79 {}
message Message80 {}
message Message81 {}
message Message82 {}
message Message83 {}
message Message84 {}
message Message85 {}
message Message86 {}
message Message87 {}
message Message88 {}
message Message89 {}
message Message90 {}
message Message91 {}
message Message92 {}
message Message93 {}
message Message94 {}
message Message95 {}
message Message96 {}
message Message97 {}
message Message98 {}
message Message99 {}
message Message100 {}
message Message101 {}
message Message102 {}
message Message103 {}
message Message104 {}
message Message105 {}
message Message106 {}
message Message107 {}
message Message108 {}
message Message109 {}
message Message110 {}
message Message111 {}
message Message112 {}
message Message113 {}
message Message114 {}
message Message115 {}
message Message116 {}
message Message117 {}
message Message118 {}
message Message119 {}
message Message120 {}
message Message121 {}
message Message122 {}
message Message123 {}
message Message124 {}
message Message125 {}
message Message126 {}
message Message127 {}
message Message128 {}
message Message129 {}
message Message130 {}
message Message131 {}
message Message132 {}
@sliskiCode
Copy link
Author

sliskiCode commented Mar 27, 2023

I can see that CodeGenerator.writeMessageDescriptor function already supports chunking. Right now property is fixed and set to 200.

protected fun writeMessageDescriptor(type: File.Type.Message) {
    val allFields = type.sortedStandardFieldsWithOneOfs()
    val chunkSize = 200 // This should be configurable.
    val needToChunk = allFields.size > chunkSize

This should be adjusted or exposed as configurable property.

Wdyt @garyp?

@garyp
Copy link
Collaborator

garyp commented Mar 28, 2023

@sliskiCode what would be the benefit of making it configurable? In other words, in what conditions would you use a different chunk size?

@garyp garyp added bug Something isn't working component-codegen labels Mar 28, 2023
@sliskiCode
Copy link
Author

sliskiCode commented Mar 28, 2023

So benefit is simple. Fixed size of 200 is not good enough. It works for a golden path case but does not when oneof cases hold some metadata. In my example oneof has 132 cases + metadata and generated descriptor exceeds JVM method limit. I am not sure if this should be configurable but at least tweaked for more complex cases. Maybe 100 would be a good value candidate 🤔.

@garyp garyp added this to the 0.16.0 milestone Jul 9, 2024
@garyp
Copy link
Collaborator

garyp commented Jul 9, 2024

Sorry for letting this sit for over a year 🙈 Let's try reducing the chunk threshold to 100 and see if that's good enough in practice. If it isn't, we can investigate a more complex heuristic. I'll try to get this change added in the upcoming release.

garyp added a commit that referenced this issue Aug 29, 2024
The previous size of 200 worked fine when a message contained lots of
fields without any custom options. But custom options on a field
increase the size of the code that is generated for the field's field
descriptor.  Which means we can fit fewer field descriptor constructor
calls in a single method before the method's bytecode becomes too big
and generates a `MethodTooLargeException`.

For now we'll just reduce the chunking size from 200 to 100 to give us
some more breathing room. Sufficiently large and complex protobuf
message definitions can still lead to an exception though. If that
happens often then we can implement further improvements to the
chunking.

Fixes #252
garyp added a commit that referenced this issue Aug 29, 2024
The previous size of 200 worked fine when a message contained lots of
fields without any custom options. But custom options on a field
increase the size of the code that is generated for the field's field
descriptor.  Which means we can fit fewer field descriptor constructor
calls in a single method before the method's bytecode becomes too big
and generates a `MethodTooLargeException`.

For now we'll just reduce the chunking size from 200 to 100 to give us
some more breathing room. Sufficiently large and complex protobuf
message definitions can still lead to an exception though. If that
happens often then we can implement further improvements to the
chunking.

Fixes #252
@garyp
Copy link
Collaborator

garyp commented Aug 29, 2024

I've reduced the chunk size from 200 to 100. I'm sure we can come up with a degenerate test case that will still fail even with a chunk size of 100. I don't know if there's any real-word protobuf usage that would do this though. If pbandk users do still run into this issue even with the reduced chunk size, then I can see two future paths forward:

  1. Make the chunk size configurable via a command-line option to protoc-gen-pbandk. Users who have unusually large messages can override the chunk size to something smaller that works for them.
  2. Add a heuristic to the code that automatically reduces the chunk size based on the number/size of custom options present on the message's fields. I believe custom options are the only thing currently that can cause the generated code to increase in size.

garyp added a commit that referenced this issue Sep 5, 2024
The previous size of 200 worked fine when a message contained lots of
fields without any custom options. But custom options on a field
increase the size of the code that is generated for the field's field
descriptor.  Which means we can fit fewer field descriptor constructor
calls in a single method before the method's bytecode becomes too big
and generates a `MethodTooLargeException`.

For now we'll just reduce the chunking size from 200 to 100 to give us
some more breathing room. Sufficiently large and complex protobuf
message definitions can still lead to an exception though. If that
happens often then we can implement further improvements to the
chunking.

Fixes #252
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component-codegen
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants