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

Investigating on the size of Source types #131

Closed
h-a-n-a opened this issue Dec 4, 2024 · 2 comments
Closed

Investigating on the size of Source types #131

h-a-n-a opened this issue Dec 4, 2024 · 2 comments

Comments

@h-a-n-a
Copy link
Collaborator

h-a-n-a commented Dec 4, 2024

RawSource contains two variants:

  • Buffer
  • Source

Buffer was required to convert to String to satisfy trait Source. With the signature sign of stream_chunks, string converted from RawSource::Buffer needs to be stored on the RawSource to get a satisfying lifetime. Most of the used variant of RawSource is String, so this would add extra 40-byte size overhead for creating RawSource::String (64-byte RawSource, String only takes 24 bytes)

I'm here to propose splitting RawSource into two types: RawStringSource and RawBufferSource.

(on 64-bit machine)

@h-a-n-a
Copy link
Collaborator Author

h-a-n-a commented Dec 4, 2024

Cached Source types like CachedSource creates a copy of the original data.

For type RawSource which was wrapped by CachedSource would contain two copies of raw data.
This just probably does not make any sense for caching source code or any other source code types.

I don't know if we can remove source cache from intermediate source types. Consider of this scenario:

OriginalSource -> ReplaceSource -> CachedSource -> ConcatSource -> CachedSource.

This would create three copies of code and the first CachedSource contains source code that is an intermediate result. Maybe we should cache the last one(OriginalSource and edits and cache are stored) or we just give up on caching source code(only OriginalSource and edits are stored).

@h-a-n-a
Copy link
Collaborator Author

h-a-n-a commented Dec 17, 2024

Fixed #144

@h-a-n-a h-a-n-a closed this as completed Dec 17, 2024
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

No branches or pull requests

1 participant