-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MOB] JAMES-2997 Remove byte array from attachment #3061
[MOB] JAMES-2997 Remove byte array from attachment #3061
Conversation
9e30bde
to
ea3b883
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read it
|
It's too big. can you split it into readable parts? |
Note sure about how to do that: it comes as a "big ball of mud", and without disabling features, it will be hard to get that done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall nice, but:
- I'm pretty sure you can extract some refactoring steps into other PR
- do you have some gatling tests to see if it improves thnigs?
(I've not finished reviewing all the changes)
mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
Outdated
Show resolved
Hide resolved
mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentTest.java
Show resolved
Hide resolved
@@ -73,7 +73,7 @@ static CassandraMailboxManager createMailboxManager(CassandraMailboxSessionMappe | |||
SessionProviderImpl sessionProvider = new SessionProviderImpl(mock(Authenticator.class), mock(Authorizator.class)); | |||
|
|||
QuotaComponents quotaComponents = QuotaComponents.disabled(sessionProvider, mapperFactory); | |||
MessageSearchIndex index = new SimpleMessageSearchIndex(mapperFactory, mapperFactory, new DefaultTextExtractor()); | |||
MessageSearchIndex index = new SimpleMessageSearchIndex(mapperFactory, mapperFactory, new DefaultTextExtractor(), null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why null ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To not bother building a complicated value.
mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreBlobManagerTest.java
Outdated
Show resolved
Hide resolved
mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentTest.java
Outdated
Show resolved
Hide resolved
server/container/util/src/main/java/org/apache/james/util/io/SizeInputStream.java
Outdated
Show resolved
Hide resolved
.../store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilderTest.java
Show resolved
Hide resolved
mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreAttachmentStorer.java
Outdated
Show resolved
Hide resolved
mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentMapperTest.java
Show resolved
Hide resolved
mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AttachmentMapperTest.java
Show resolved
Hide resolved
|
||
import org.apache.commons.lang3.NotImplementedException; | ||
|
||
public class SizeInputStream extends InputStream { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably can use ByteSource for this kind of use cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ByteSource is not applicable for any kind of InputStream (think JMAP attachment download).
Should we add a copy to a temporary file in the path?
mailbox/api/src/main/java/org/apache/james/mailbox/model/ParsedAttachment.java
Outdated
Show resolved
Hide resolved
...src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMessage.java
Outdated
Show resolved
Hide resolved
mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
Outdated
Show resolved
Hide resolved
|
||
return mapperFactory.getMessageMapper(session).execute(() -> { | ||
storeAttachment(message, messageAttachments, session); | ||
List<MessageAttachment> attachments = storeAttachments(messageId, content, session); | ||
MailboxMessage message = createMessage(internalDate, size, bodyStartOctet, content, flags, propertyBuilder, attachments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really think that it's not the responsibility of storeAttachments to generate the MessageAttachement ids, It makes everything much more complex than it should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a common pattern we have to have the storage layer generating ids
I don't really alternatives regarding this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had the same problem with blob-store recently. We decided to give the responsibility to the client. It's IMO a very important design decision.
In the case of this PR it will make some things simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I agree. It has not been fixed?
mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
Show resolved
Hide resolved
|
||
public AttachmentWithBytes(Attachment attachment, byte[] bytes) { | ||
this.attachment = attachment; | ||
this.bytes = bytes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does it relate to the commit title?
2067ed0
to
8e383a3
Compare
(forced pushed to try to get a 🍏 build... - there was a rebase conflict ) |
tests are 🍏
test this please |
test this please |
@@ -35,7 +31,7 @@ | |||
|
|||
@FunctionalInterface | |||
interface RequireContent { | |||
RequireName content(InputStream stream); | |||
RequireName content(byte[] bytes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the pr is named "Remove byte array from attachment " and here we put it back, apparently.
Did I missed something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not an attachment stored in the mailbox-api but a result of a parsing.
Different topic! We do not retrieve these bytes on every read!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that means that parsing is no more streamed, while storing is now streamed?
test this please |
test this please |
...er/container/util/src/test/java/org/apache/james/util/io/CurrentPositionInputStreamTest.java
Outdated
Show resolved
Hide resolved
:green: wooot! |
...er/container/util/src/test/java/org/apache/james/util/io/CurrentPositionInputStreamTest.java
Outdated
Show resolved
Hide resolved
...er/container/util/src/test/java/org/apache/james/util/io/CurrentPositionInputStreamTest.java
Outdated
Show resolved
Hide resolved
...er/container/util/src/test/java/org/apache/james/util/io/CurrentPositionInputStreamTest.java
Outdated
Show resolved
Hide resolved
Did you notice the big difference for ListMessages? It's really bad, no? (mean time 40ms -> 169ms) |
I have no idea where it comes from to be honnest |
That's really annoying to praise a 60% improvment on the p99 while not looking at a 4x performance decrease in median and mean! Either you try again to reproduce your issue, or it's worthless to do performance testing at this level. |
Agreed I need to redo it, that's why I did not remove the label, btw. |
28e9d85
to
974ac25
Compare
… messageAttachments
…ageAttachmentMetadata
… message has attachment
…ne if a message has attachment
d111a90
to
147fb9b
Compare
Forced pushed to solve conflict and remove charset commit. |
#3316 discusses the charset issue fixing (if needed) separatly. |
Running perf tests on hosted VMs can trivially explain the difference between two runs separated in time (several hours difference between the two runs in the first one). Do we have a plan for a perf testing platform? Also, the results of run #2 are coherent with the expectations we can have following the changes performed (p99 improvment of GetMessages only, but important). It can be trivially explained by the fact we no longer load useless attachments. Thus I have no concerns accepting the second one. If you still have concerns, is me running systematically perf tests useful, or am I just wasting my time? |
Do you think my goal is to make you wasting time? I see some (very) strange things, I ask for explanation. If I look at the issue globally, either this PR is causing some performance troubles of getMessageList in this context, or we have globally a performance issue on current master. I would like that we dig into the issue instead of grumbling about VMs. |
*/ | ||
Pair<MessageMetaData, Optional<List<MessageAttachmentMetadata>>> appendMessageToStore(Mailbox mailbox, Date internalDate, int size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder, MailboxSession session) throws MailboxException; | ||
|
||
/** | ||
* MessageStorer to parsing, storing and returning AttachmentMetadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or remove theto
, or don't conjugate the verbs parse, store and return
mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageStorer.java
Outdated
Show resolved
Hide resolved
mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageStorer.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some details now, it's globally ok for me even if I'm worry about the performace issue
* If supported by the underlying implementation, this method will parse the messageContent to retrieve associated | ||
* attachments and will store them. | ||
* | ||
* Otherwize an empty optional will be returned on the right side of the pair. | ||
*/ | ||
Pair<MessageMetaData, Optional<List<MessageAttachmentMetadata>>> appendMessageToStore(Mailbox mailbox, Date internalDate, int size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder, MailboxSession session) throws MailboxException; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's at the implementation level, why not Optional<Pair<MessageMetaData, List<MessageAttachmentMetadata>>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You always have the message metadata but the underlying implementation might not return you attachment metadata (because it does not support it)
mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageStorer.java
Outdated
Show resolved
Hide resolved
mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageStorer.java
Outdated
Show resolved
Hide resolved
mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageStorer.java
Outdated
Show resolved
Hide resolved
#3266 (comment) adds significant performance gains by moving GetMessageList into reactive style Before After Looking at the perf test result not benefiting (amongst others) about this improvment, differences in performance can be explained by the different load (not doing 5 GetMessages) This seems consistent to me. And we don't have performance issue on GetMessageList on master as #3266 (comment) proves it. |
Again, it's not exactly the same load than the other (recent) perf tests you have been seeing and the latest test on this lack most of the recent optimization: I'm not worry. |
Merged |
Massive effort to port our MOB into a viable pull request (wooot!)
I did my best to clean up the (very) messy history inherited from the MOC but did not managed to renabe test as part of primary work.