Increase the table count limit to 100,000 #38
Conversation
100k sounds OK to me. |
@kmiller68 any objections to this value? |
What this tables all include? If this also includes the vtables of objects/classes then it is usual but very large programs with many small classes can become problems. I see no problems today with it. But software developers tend to ever larger software. With software outside the browser (WASI) and many libraries this limit can be overridden. Why must there be such a limit? |
@Horcrux7 The limits are restricted to the JS-API spec. You can see their current values and the purpose of the limits here: https://webassembly.github.io/spec/js-api/index.html#limits In short, it's to help ensure compatibility across engines. |
@Horcrux7 To clarify, a wasm table is basically a huge slab of memory (similar to the linear memory, but for opaque references). A single table can contain And you can have Assuming 32-bit pointers, that's At that point, I think you'll have bigger issues than the |
@Pauan A table does not must have its maximum size. In addition, the table does not have to have different objects. There can be only a different order or only one element is different. In the extreme with 100,000 tables you can have only one object. Of course this make no sense. But your calculation also. If I have a medium table size of 10 then make this for 32 bit pointer 4 Megabytes. This is acceptable for a big fat standalone application with hundreds of megabytes. |
@binji In the list of limits I see 1,000,000 types but only 100,000 tables. If every type need its own vtable then this make no sense for me. I would suggest to use the same limit. This is just a small vote for a larger limit if no disadvantages occur. I can live well with 100,000. |
Yes it does. The I had made a mistake and thought it was
It is completely possible to have different objects in the same table, since the table type can be
I don't understand at all what you're saying. Perhaps you are completely misunderstanding what a wasm table is? Like I explained, wasm tables are just a slab of memory (which can contain many things in it). They don't have anything to do with vtables or object types. You can think of a wasm table as being similar to the heap found in most languages (except the memory is managed by the wasm runtime, not the language).
I explained what the maximum size is. Meaning that a wasm program cannot go higher than that. Obviously you can go lower than that, if you don't need millions of gigabytes of space. You had said earlier you were concerned about the maximum size, and so I explained that the maximum size is much higher than you thought.
No... each type does not need its own table. Wasm tables have nothing at all to do with vtables or types. They are just a storage mechanism, like linear memory, nothing more. You can store millions of vtables and objects in a single wasm table. As I explained, you can have 800,000 gigabytes of different objects in a wasm program. It is not limited to 100,000 objects, or 100,000 types, or 100,000 vtables. |
It's specified as the That said, the JS-API spec also has an implementation-defined limit on the number of table entries: "The maximum size of a table is 10000000." |
Ah, okay, great.
Right, so for JS specifically the limit would be |
This can be right. I have write it in my first post. Currently I does not use it in my compiler (Java bytecode to wasm).
If you think this is a bad idea then forget all what I have write. |
That doesn't sound very good to me. You can't actually store tables into objects, because tables aren't a first-class value in wasm. I don't know what your compiler architecture is, but it seems to me that the right thing to do is:
Basically, treat tables like a heap (or the linear memory): you have a single table with many things in it, and you store table indexes (which are basically pointers). If you need multiple tables, you're likely doing something wrong (there are exceptions to that, of course). Also keep in mind that right now browsers only support 1 table anyways, so technically right now the table limit is 1. So if you care about older browsers you'll need to use 1 table anyways. |
@Pauan Many thanks for your explanation. I will pay attention to it. The features of current browsers are not the problem. I need the GC feature anyway. |
@Horcrux7, if you plan to use GC objects anyway, why would you still use tables? |
@rossberg I need tables of type function for call_indirect. My understand is that this is only possible via tables. |
The GC proposal (or more accurately, the typed function reference proposal it now builds upon) includes a |
@rossberg If this feature will be available in any implementation in a (far) future then I can look into it. |
One valid use case that we have discussed in the past is to narrow the type of a table to a specific function type; so instead of (E.g. https://github.com/titzer/virgil uses this in its native and wasm targets, but currently the mtables are stored in memory in the wasm target, and the entries are indices into the one large function table. It would be a performance improvement to use multiple, typed tables here in the future, to avoid a signature check and additional memory accesses. AFAICT at this point, the mtable implementation will still be faster than typed vtables in the GC proposal.) |
@binji, can you merge this? |
Update for a recent spec change: WebAssembly/reference-types#38 R=binji@chromium.org Bug: v8:7581 Change-Id: I4ac4a4c351dfc100f978e1aead308cbed59149e4 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1690832 Reviewed-by: Ben Smith <binji@chromium.org> Commit-Queue: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/master@{#62576}
With multi-table we need a common implementation limit for the max number of tables. Firefox uses 100K as the limit currently so that's what I'm proposing here, but it's just a strawman value - please discuss.