misalcedo / tortuga

A CGI and WCGI server for HTTP/1.1
Apache License 2.0
7 stars 0 forks source link

Test buffers vs. counting emitter #36

Closed misalcedo closed 3 years ago

misalcedo commented 3 years ago

Benchmark the differences between writing to a buffer, then copying, vs. counting then writing again for emitting to binary.

misalcedo commented 3 years ago

Need to learn how to pass a dynamic output to the emit function in emit_section.

misalcedo commented 3 years ago

https://github.com/rust-lang/rust/issues/68589

misalcedo commented 3 years ago

The counting emitter worked, but I had to remove the implicit Sized bound on most emit functions, though not all. The section ones still require a sized bound for now.

The benchmarks were inconclusive for the module buffer, but seemed to show improvements when removing the function buffer. I think the bigger win here is not having to determine a pre-allocation size for buffers. For larger modules this may prove beneficial as setting an initial capacity was the best perf improvement.

The section emitters need to be marked as sized in order for the emit_section to be able to cast O to dyn Write.