Skip to content

Conversation

@hardlyardi
Copy link

@deviaze
Copy link
Contributor

deviaze commented Dec 27, 2025

Is it possible we could check if a buffer has been sliced (if there's any active buffer sliced from its memory that hasn't been GCed), or if there's any overlap between buffers?

With slices, we could have multiple mutable references to the same part of memory. This means if a buffer is passed to a function, the function doesn't know if it truly owns the buffer or if it could be written to by somewhere else at any point in the program. It would be much easier to maintain memory safety if we could check.

@jackdotink
Copy link
Contributor

You can already have multiple mutable references to the same part of memory, just pass a buffer to multiple functions.

@vegorov-rbx
Copy link
Collaborator

Big part of the buffer design was to ensure it is a very performant data structure.
Buffer slicing introduces multiple complications: the data will now be a separate pointer with an additional indirection (minor), it increases buffer object size (minor) and requires an additional allocation.
It will also be possible to have aliasing of data in multiple buffer references at different offsets (interfering with optimizations) and the garbage collection is getting more complicated (solvable).

It is still an interesting area to explore and it might be something we revisit at a later date, but in short term we are not ready to introduce this functionality.
Going to close this for now, but we can reopen once the team takes time to explore more about the implementation side of slicing.

@vegorov-rbx vegorov-rbx closed this Jan 3, 2026
@hardlyardi
Copy link
Author

hardlyardi commented Jan 3, 2026

I understand the performance considerations are many, and that ultimately your team has the final say on what is in the best interest for the language right now. But I urge you to reconsider the priority of this - the usecases for this on Rōblox alone are massive:

  • network compression
  • data storage
  • parallel luau
  • built-in event systems (bindables)

Rōblox does not provide any ability for interacting with any of these APIs (namely, parallel luau) without sending empty data or allocating large buffers repetitively. There are also tools used on the platform by hundreds, or even thousands of people and games which would benefit massively from aliasing memory.

The pure Luau benefits are there too, it isn't ergonomic or performant to pass around offsets and size limits defined in tables or buffers. If someone wants fine-grained control over the layout of data between multiple references, they almost certainly have to provide something worse and less familiar to a user.

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.

4 participants