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

Optimize encoding #224

Merged
merged 22 commits into from
Dec 7, 2023
Merged

Optimize encoding #224

merged 22 commits into from
Dec 7, 2023

Conversation

guregu
Copy link
Owner

@guregu guregu commented Nov 20, 2023

Reworked the unmarshaling system, resulting in around a 1.5x speedup and less allocations.
Still need to test it a bit more but it should work the same as the old way without any breaking changes.
I will look at marshaling as well, but haven't gotten to it yet.

Before:

BenchmarkDecodeVeryComplex-12    239828         4363 ns/op        4324 B/op    58 allocs/op
BenchmarkDecodeSimple-12        3366724        351.5 ns/op         448 B/op     6 allocs/op

After:

BenchmarkDecodeVeryComplex-12    353025         2985 ns/op        1597 B/op      28 allocs/op
BenchmarkDecodeSimple-12         5403024       209.7 ns/op          40 B/op       3 allocs/op

@guregu guregu mentioned this pull request Nov 20, 2023
@guregu
Copy link
Owner Author

guregu commented Nov 23, 2023

Almost done, just need to finish encoding and clean it up.
Results so far:

Before:
BenchmarkEncodeVeryComplex-12     252729     4109 ns/op	    5421 B/op	      89 allocs/op
BenchmarkEncodeSimple-12    	 2548044    468.7 ns/op	     688 B/op	      12 allocs/op

After:
BenchmarkEncodeVeryComplex-12    491612	       2363 ns/op   4712 B/op	      50 allocs/op
BenchmarkEncodeSimple-12    	 3866780      277.6 ns/op    611 B/op	       7 allocs/op

@guregu guregu changed the title Draft: Optimize encoding Optimize encoding Nov 24, 2023
@guregu
Copy link
Owner Author

guregu commented Dec 1, 2023

I'm happy with where this is now. I have been testing it on one of my sites and will merge in a few days.

@guregu guregu merged commit e8575d2 into master Dec 7, 2023
@guregu guregu deleted the optimize branch June 15, 2024 21:41
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