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

Reduce Memory Usage by Optimizing Order of Fields #101

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gaby
Copy link

@gaby gaby commented Jul 21, 2024

Optimized the order of fields in several structs, this results in a reduction of memory usage by quicktemplate.

Summary:

/quicktemplate/jsonstring.go:61:19: 256 bytes saved: struct with 264 pointer bytes could be 8
/quicktemplate/parser/parser.go:15:13: 8 bytes saved: struct of size 96 could be 88
/quicktemplate/parser/scanner.go:33:12: 8 bytes saved: struct with 16 pointer bytes could be 8
/quicktemplate/parser/scanner.go:53:14: 16 bytes saved: struct of size 192 could be 176
/quicktemplate/parser/scanner_test.go:325:9: 8 bytes saved: struct with 16 pointer bytes could be 8

@gaby
Copy link
Author

gaby commented Jul 21, 2024

@valyala Quick optimization that should reduce memory usage by around ~300 bytes.

I also submitted the same optimization to bytebufferpool valyala/bytebufferpool#29

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.

1 participant