project-oak / oak

Meaningful control of data in distributed systems.
Apache License 2.0
991 stars 107 forks source link

Micro-optimizations for Oak Functions #5002

Closed andrisaar closed 3 months ago

andrisaar commented 3 months ago

a) If we're built with deny_sensitive_logging, elide the log_sensitive calls altogether.

As the logger is hidden behind a Box<dyn OakLogger>, the compiler can make no assumptions about which logger is in use and even when we build with deny_sensitive_logging, we format the debug strings only then to immediately throw them away.

This is the reason why the log crate has info! and friends macros: with a macro, you can check if logging is enabled, and only format the string if it is. We should consider implementing similar macros; but for now, let's see if using the same crate feature gets rid of all the CPU we're burning on string formatting.

b) When constructing the response, move the contents of the vector, don't clone it. Doing a move removes an unnecessary allocation and a copy.