fiber icon indicating copy to clipboard operation
fiber copied to clipboard

:sparkles: enhancement: use msgp for flash message encoding/decoding

Open efectn opened this issue 6 months ago • 5 comments

Description

Replace current redirection serialization with msgp which is more performant and gives more readable, clean code.

Old Benchmarks:

Benchmark_Redirect_Route-4                                                                    	 6814248	       176.5 ns/op	      16 B/op	       1 allocs/op
Benchmark_Redirect_Route_WithQueries-4                                                        	 3426120	       346.7 ns/op	      16 B/op	       1 allocs/op
Benchmark_Redirect_Route_WithFlashMessages-4                                                  	 3366782	       354.8 ns/op	      32 B/op	       3 allocs/op
Benchmark_Redirect_parseAndClearFlashMessages-4                                               	 1254584	       875.1 ns/op	     820 B/op	       0 allocs/op
Benchmark_Redirect_processFlashMessages-4                                                     	387093091	         3.109 ns/op	       0 B/op	       0 allocs/op
Benchmark_Redirect_Messages-4                                                                 	 4232792	       281.7 ns/op	     336 B/op	       2 allocs/op
Benchmark_Redirect_OldInputs-4                                                                	 4164416	       285.3 ns/op	     336 B/op	       2 allocs/op
Benchmark_Redirect_Message-4                                                                  	24883599	        48.05 ns/op	       0 B/op	       0 allocs/op
Benchmark_Redirect_OldInput-4                                                                 	16826005	        71.45 ns/op	       0 B/op	       0 allocs/op

New Benchmarks:

Benchmark_Redirect_Route-16                         	 9088268	       134.8 ns/op	      16 B/op	       1 allocs/op
Benchmark_Redirect_Route_WithQueries-16             	 3843570	       315.5 ns/op	      16 B/op	       1 allocs/op
Benchmark_Redirect_Route_WithFlashMessages-16       	 4386789	       281.6 ns/op	     117 B/op	       2 allocs/op
Benchmark_Redirect_parseAndClearFlashMessages-16    	 5126095	       228.3 ns/op	      32 B/op	       6 allocs/op
Benchmark_Redirect_processFlashMessages-16          	 7152108	       168.3 ns/op	     112 B/op	       1 allocs/op
Benchmark_Redirect_Messages-16                      	13430538	        93.27 ns/op	     128 B/op	       2 allocs/op
Benchmark_Redirect_OldInputs-16                     	13147718	        83.52 ns/op	      96 B/op	       2 allocs/op
Benchmark_Redirect_Message-16                       	99072417	        11.68 ns/op	       0 B/op	       0 allocs/op
Benchmark_Redirect_OldInput-16                      	175335772	         7.149 ns/op	       0 B/op	       0 allocs/op

Note: Old Benchmark_Redirect_processFlashMessages benchmark is wrong as https://github.com/gofiber/fiber/blob/main/redirect.go#L278 causes its to execute effectively just for once. Right benchmark result is: Benchmark_Redirect_processFlashMessages-16 9702147 122.6 ns/op 0 B/op 0 allocs/op

Changes introduced

  • [x] Benchmarks: Describe any performance benchmarks and improvements related to the changes.

Type of change

  • [x] Enhancement (improvement to existing features and functionality)
  • [x] Performance improvement (non-breaking change which improves efficiency)
  • [x] Code consistency (non-breaking change which improves code reliability and robustness)

Checklist

  • [ ] Followed the inspiration of the Express.js framework for new functionalities, making them similar in usage.
  • [ ] Conducted a self-review of the code and provided comments for complex or critical parts.
  • [ ] Updated the documentation in the /docs/ directory for Fiber's documentation.
  • [ ] Added or updated unit tests to validate the effectiveness of the changes or new features.
  • [ ] Ensured that new and existing unit tests pass locally with the changes.
  • [ ] Verified that any new dependencies are essential and have been agreed upon by the maintainers/community.
  • [ ] Aimed for optimal performance with minimal allocations in the new code.
  • [ ] Provided benchmarks for the new code to analyze and improve upon.

Commit formatting

Please use emojis in commit messages for an easy way to identify the purpose or intention of a commit. Check out the emoji cheatsheet here: CONTRIBUTING.md

efectn avatar Aug 10 '24 14:08 efectn