Skip to content

[PERFORMANCE] Cache and reuse Object mappers for writing JMAP responses#440

Merged
chibenwa merged 2 commits intoapache:masterfrom
chibenwa:object-mapper-caching
May 24, 2021
Merged

[PERFORMANCE] Cache and reuse Object mappers for writing JMAP responses#440
chibenwa merged 2 commits intoapache:masterfrom
chibenwa:object-mapper-caching

Conversation

@chibenwa
Copy link
Copy Markdown
Contributor

@chibenwa chibenwa commented May 19, 2021

Clients use a close ensemble of properties combination in JMAP responses.
This enable reuse of jackson assemblies and achieve significant speedup
of JMAP responses serialisation.

Before

~20% of James applicative CPU time is spent doing JMAP response serialization. This is because each request needs a dedicated property filter, which is implemented by always initializing a new ObjectMapper, which takes time and is sub-optimal as it is not warm.

Screenshot from 2021-05-19 14-27-32

Here are the associated gatling run:

Screenshot from 2021-05-19 14-30-29

After

Screenshot from 2021-05-19 14-32-18

By caching common serialization patterns we decreased 6 time CPU utilization for JMAP Draft response serialization.

Here are the associated gatling run:

Screenshot from 2021-05-19 14-49-17

@chibenwa chibenwa self-assigned this May 19, 2021
@chibenwa chibenwa changed the title [REFACTORING] Cache and reuse Object mappers for writing JMAP responses [PERFORMANCE] Cache and reuse Object mappers for writing JMAP responses May 19, 2021
@chibenwa chibenwa force-pushed the object-mapper-caching branch from 4ceac39 to 2d7b0ad Compare May 19, 2021 12:35
@chibenwa
Copy link
Copy Markdown
Contributor Author

13:01:20.832 [ERROR] o.a.j.j.d.m.SetMessagesCreationProcessor - An error occurred when deleting a message
java.lang.IllegalStateException: block()/blockFirst()/blockLast() are blocking, which is not supported in thread reactor-http-epoll-6
	at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:83)
	at reactor.core.publisher.Mono.block(Mono.java:1703)
	at org.apache.james.mailbox.inmemory.mail.InMemoryMessageIdMapper.find(InMemoryMessageIdMapper.java:71)
	at org.apache.james.mailbox.inmemory.mail.InMemoryMessageIdMapper.delete(InMemoryMessageIdMapper.java:127)
	at com.google.common.collect.RegularImmutableMap.forEach(RegularImmutableMap.java:186)
	at org.apache.james.mailbox.store.mail.MessageIdMapper.delete(MessageIdMapper.java:76)
	at org.apache.james.mailbox.store.mail.MessageIdMapper.lambda$deleteReactive$2(MessageIdMapper.java:80)

Looks weird...

chibenwa added 2 commits May 21, 2021 14:53
Clients use a close ensemble of properties combination in JMAP responses.
This enable reuse of jackson assemblies and achieve significant speedup
of JMAP responses serialisation.

Note that protections against hash collision are setted up.
@chibenwa chibenwa force-pushed the object-mapper-caching branch from 078d3c5 to 467f299 Compare May 21, 2021 07:58
@chibenwa chibenwa merged commit 79ee79e into apache:master May 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants