Collections of async profiler collected enhancements
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 51
Description
### Describe the bug
While profiling [Apache James]() email server, that does an extensive usage of object storage (S3 driver) to store and retrieve email content, I noticed the overall calls though the S3 drivers could easily be optimized (CPU, memory allocation) and could thus contribute to make James a faster email server.
It started with a call noticed to `Pattern.compile` which, should be avoided. Using a pre-compiler regex is the way to go:

(5% of CPU and 6.5% of memory allocation for S3 getObject calls)
On the other suspicious calls that I located, there are repeated calls to checksum algorithms parsing. The parsing itself does an iteration of the constants using stream API. Stream API, while handy (I love it!) comes with a cost... Here we could easily build a map to resolve the calls and not pay this price.

(4.87% of CPU and 17.79% of memory allocation for S3 getObject calls)
Furthermore, path marshallers do compile their patterns on each runs. Java do not offer a way to reuse the format and forces to always re-parse it. This takes 2.14% of the CPU and 1.45% of memory allocation for S3 getObject calls - 2.85% and 1.75% if we count the all String.format call. Here the formatting is naive and can be replaced with string concatenation.

Furthermore, the requestid log is being formatted while I never log it, which is wasteful. (This one was is AWS netty stack) I suggest formatting the log message lazily only if needed. This takes 2.4% of CPU dedicated to S3 (including background processes).

### Expected Behavior
I would be glad to contribute some of these little performance improvements. This could improve performance of the S3 driver by a handful of percents for me and other users,
### Current Behavior
Currently the S3 driver spends significant amount of time/ memory on easy to optimize code.
### Reproduction Steps
Profiling S3 driver getObjects with Async profiler https://github.com/jvm-profiling-tools/async-profiler
### Possible Solution
- Use string concatenation in place of String.format in PathMarshalling
- Provide a map to back Algorithm lookups for checksum
- Use a preconpiled regex for regions
- Format requestId log only if needed
On that very one, the use of codegen [revented me to come up with a proposal as I just don't understand how codegen works...
### Additional Information/Context
Would a pull request on this be welcomed?
### AWS Java SDK version used
2.17.170
### JDK version used
openjdk version "11.0.14.1" 2022-02-08
### Operating System and version
Ubuntu 20.04.4 LTS
Contributor guide
Assessment
This issue has not been assessed yet.