Go to file
Brian Clozel ce7278aaf4 Optimize HTTP headers management
Several benchmarks underlined a few hotspots for CPU and GC pressure in
the Spring Framework codebase:

1. `org.springframework.util.MimeType.<init>(String, String, Map)`
2. `org.springframework.util.LinkedCaseInsensitiveMap.convertKey(String)`

Both are linked with HTTP request headers parsing and response headers
writin during the exchange processing phase.

1) is linked to repeated calls to `HttpHeaders.getContentType`
within a single request handling. The media type parsing operation
is expensive and the result doesn't change between calls, since
the request headers are immutable at that point.

This commit improves this by caching the parsed `MediaType` for the
`"Content-Type"` request header in the `ReadOnlyHttpHeaders` class.
This change is available for both Spring MVC and Spring WebFlux.

2) is linked to insertions/lookups in the `LinkedCaseInsensitiveMap`,
which is the data structure behind `HttpHeaders`.
Those operations are creating a lot of garbage (including a lot of
`String` created by `toLowerCase`). We could choose a more efficient
data structure for storing HTTP headers data.

As a first step, this commit is focusing on Spring WebFlux and
introduces `MultiValueMap` implementations mapped by native HTTP headers
for the following servers: Tomcat, Jetty, Netty and Undertow.
Such implementations avoid unnecessary copying of the headers
and leverages as much as possible optimized operations provided by the
native implementations.

This change has a few consequences:

* `HttpHeaders` can now wrap a `MultiValueMap` directly
* The default constructor of `HttpHeaders` is still backed by a
`LinkedCaseInsensitiveMap`
* The HTTP request headers for the websocket HTTP handshake now need to
be cloned, because native headers are likely to be pooled/recycled by
the server implementation, hence gone when the initial HTTP exchange is
done

Issue: SPR-17250
2018-10-11 12:11:47 +02:00
buildSrc Latest dependency updates (POI 3.17, Rome 1.8, EhCache 3.4, Caffeine 2.5.6, RxJava 2.1.4, Tomcat 8.5.21, JRuby 9.1.13, Rhino 1.7.7.2) 2017-09-23 11:28:19 +02:00
gradle Upgrade to Gradle 4.10.2 2018-09-20 11:11:50 +02:00
spring-aop Do not proxy test instances based on "original instance" convention 2018-08-24 00:49:01 +02:00
spring-aspects Upgrade to Mockito 2.22, XMLUnit 2.6.2, JavaMail 1.6.2 2018-09-10 10:52:24 +02:00
spring-beans Restore original factory method caching (addressing Boot regressions) 2018-10-10 23:53:13 +02:00
spring-context Updated Javadoc: date format patterns SPR-17366 2018-10-11 10:52:32 +02:00
spring-context-indexer Move indexer implementation to index.processor subpackage (for Jigsaw) 2018-07-03 17:55:24 +02:00
spring-context-support Polishing 2018-10-09 23:14:49 +02:00
spring-core Polishing 2018-10-09 23:14:49 +02:00
spring-expression Avoid regex pattern matching for simple String replacement steps 2018-09-17 14:22:19 +02:00
spring-framework-bom Remove dependency management noise from POMs 2018-06-11 15:57:54 +02:00
spring-instrument Use consistent class design 2018-06-28 10:28:44 +02:00
spring-jcl Defensively use Class.forName instead of ClassLoader.loadClass 2018-10-09 23:14:05 +02:00
spring-jdbc Polishing 2018-09-18 17:19:37 +02:00
spring-jms Polishing 2018-08-16 13:02:27 +02:00
spring-messaging Move MonoToListenableFutureAdapter to spring-core 2018-10-09 16:26:24 -04:00
spring-orm SpringBeanContainer exposes bean instance returned from initializeBean 2018-10-09 23:13:58 +02:00
spring-oxm Upgrade to Mockito 2.22, XMLUnit 2.6.2, JavaMail 1.6.2 2018-09-10 10:52:24 +02:00
spring-test Full alignment of spring-test vs spring-web MockCookie variants 2018-10-09 23:13:18 +02:00
spring-tx Transactional timeout documented as seconds in annotation javadoc 2018-08-31 12:40:43 +02:00
spring-web Optimize HTTP headers management 2018-10-11 12:11:47 +02:00
spring-webflux Optimize HTTP headers management 2018-10-11 12:11:47 +02:00
spring-webmvc Correct Javadoc in ServletUriComponentsBuilder 2018-10-09 16:51:41 -04:00
spring-websocket Update links to http://java.net/jira 2018-10-01 12:01:28 -04:00
src Fix bullet list layout 2018-10-07 13:45:46 +02:00
.editorconfig Add EditorConfig 2017-06-12 08:07:54 +02:00
.gitignore Reorganize spring-web-reactive .gitignore 2016-07-18 17:31:18 +02:00
.mailmap Change gopivotal.com to pivotal.io 2014-10-05 18:12:50 +02:00
CODE_OF_CONDUCT.adoc Add Code of Conduct 2016-02-01 14:37:35 -06:00
CONTRIBUTING.md Fix typo in CONTRIBUTING.md 2018-08-22 13:04:07 +02:00
README.md Update README.md 2017-11-28 09:28:34 -05:00
build.gradle Upgrade to Reactor Californium SNAPSHOTs 2018-10-11 10:46:01 +02:00
gradle.properties Next Development Version 2018-09-21 07:27:05 +00:00
gradlew Upgrade to Gradle 4.1 2017-08-08 17:26:21 +02:00
gradlew.bat Upgrade build to Gradle 3.0 2016-08-15 21:26:39 +02:00
import-into-eclipse.md Update eclipse setting and instructions 2018-06-25 17:56:53 -07:00
import-into-idea.md Polish 2017-05-29 17:04:10 +02:00
settings.gradle Consistently use double quotes (even if no interpolation needed) 2018-08-16 15:32:44 +02:00

README.md

Spring Framework

This is the home of the Spring Framework, the foundation for all Spring projects. Together the Spring Framework and the family of Spring projects make up what we call "Spring".

Spring provides everything you need beyond the Java language to create enterprise applications in a wide range of scenarios and architectures. Please read the Overview section in the reference for a more complete introduction.

Code of Conduct

This project is governed by the Spring Code of Conduct. By participating you are expected to uphold this code. Please report unacceptable behavior to spring-code-of-conduct@pivotal.io.

Access to Binaries

For access to artifacts or a distribution zip, see the Spring Framework Artifacts wiki page.

Documentation

The Spring Frameworks maintains reference documentation (published and source), Github wiki pages, and an API reference. There are also guides and tutorials across Spring projects.

Build from Source

See the Build from Source wiki page and also CONTRIBUTING.md.

Stay in Touch

Follow @SpringCentral, @SpringFramework, and its team members on Twitter. In-depth articles can be found at The Spring Blog, and releases are announced via our news feed.

License

The Spring Framework is released under version 2.0 of the Apache License.