[
https://issues.apache.org/jira/browse/JAMES-3477?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17248983#comment-17248983
]
ASF GitHub Bot commented on JAMES-3477:
---------------------------------------
chibenwa commented on a change in pull request #280:
URL: https://github.com/apache/james-project/pull/280#discussion_r542366228
##########
File path:
server/mailet/integration-testing/src/test/java/org/apache/james/mailets/MimeMessageBenchTest.java
##########
@@ -0,0 +1,146 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailets;
+
+import static org.apache.james.mailets.configuration.Constants.DEFAULT_DOMAIN;
+import static org.apache.james.mailets.configuration.Constants.FROM;
+import static org.apache.james.mailets.configuration.Constants.LOCALHOST_IP;
+import static org.apache.james.mailets.configuration.Constants.PASSWORD;
+import static
org.apache.james.mailets.configuration.Constants.awaitAtMostOneMinute;
+
+import java.util.concurrent.TimeUnit;
+import java.util.stream.IntStream;
+
+import org.apache.james.MemoryJamesServerMain;
+import org.apache.james.core.builder.MimeMessageBuilder;
+import org.apache.james.mailets.configuration.CommonProcessors;
+import org.apache.james.mailets.configuration.MailetConfiguration;
+import org.apache.james.mailets.configuration.MailetContainer;
+import org.apache.james.mailets.configuration.ProcessorConfiguration;
+import org.apache.james.modules.protocols.SmtpGuiceProbe;
+import org.apache.james.probe.DataProbe;
+import org.apache.james.server.core.MailImpl;
+import org.apache.james.transport.mailets.LogMessage;
+import org.apache.james.transport.matchers.RecipientIs;
+import org.apache.james.utils.DataProbeImpl;
+import org.apache.james.utils.SMTPMessageSender;
+import org.apache.james.utils.SpoolerProbe;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.rules.TemporaryFolder;
+
+import com.github.fge.lambdas.Throwing;
+import com.google.common.base.Stopwatch;
+
+/**
+ * This benches the efficiency at which James mailetcontainer splits emails.
+ */
+@Disabled
+public class MimeMessageBenchTest {
+ private static String CONTENT = "0123456789\r\n".repeat(1024 * 10); //
120KB message
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+ @Rule
+ public SMTPMessageSender messageSender = new
SMTPMessageSender(DEFAULT_DOMAIN);
+
+ private TemporaryJamesServer jamesServer;
+
+ @Before
+ public void setup() throws Exception {
+ jamesServer = TemporaryJamesServer.builder()
+ .withBase(MemoryJamesServerMain.SMTP_AND_IMAP_MODULE)
+ .withMailetContainer(
+ generateMailetContainerConfiguration())
+ .build(temporaryFolder.newFolder());
+ jamesServer.start();
+
+ DataProbe dataProbe = jamesServer.getProbe(DataProbeImpl.class);
+ dataProbe.addDomain(DEFAULT_DOMAIN);
+ dataProbe.addUser("rcpt1@" + DEFAULT_DOMAIN, PASSWORD);
+ dataProbe.addUser("rcpt2@" + DEFAULT_DOMAIN, PASSWORD);
+ dataProbe.addUser("rcpt3@" + DEFAULT_DOMAIN, PASSWORD);
+ dataProbe.addUser("rcpt4@" + DEFAULT_DOMAIN, PASSWORD);
+ dataProbe.addUser("rcpt5@" + DEFAULT_DOMAIN, PASSWORD);
+ }
+
+ @After
+ public void tearDown() {
+ jamesServer.shutdown();
+ }
+
+ @Test
+ public void receivedMessagesShouldContainDeliveredToHeaders() throws
Exception {
+ messageSender.connect(LOCALHOST_IP,
jamesServer.getProbe(SmtpGuiceProbe.class).getSmtpPort());
+
+ Stopwatch stopwatch = Stopwatch.createStarted();
+ IntStream.range(0, 100)
+ .forEach(Throwing.intConsumer(i ->
messageSender.sendMessage(MailImpl.builder()
+ .name("name" + i)
+ .sender(FROM)
+ .addRecipients("rcpt1@" + DEFAULT_DOMAIN,
+ "rcpt2@" + DEFAULT_DOMAIN,
+ "rcpt3@" + DEFAULT_DOMAIN,
+ "rcpt4@" + DEFAULT_DOMAIN,
+ "rcpt5@" + DEFAULT_DOMAIN)
+ .mimeMessage(MimeMessageBuilder.mimeMessageBuilder()
+ .setSubject("subject i")
+ .setText(CONTENT))
+ .build())));
+
+ awaitAtMostOneMinute.until(() ->
jamesServer.getProbe(SpoolerProbe.class).processingFinished());
+ System.out.println("Spent: " +
stopwatch.elapsed(TimeUnit.MILLISECONDS));
+ }
+
+
+ private MailetContainer.Builder generateMailetContainerConfiguration() {
+ return TemporaryJamesServer.defaultMailetContainerConfiguration()
+ .putProcessor(ProcessorConfiguration.transport()
+ .addMailet(MailetConfiguration.builder()
+ .matcher(RecipientIs.class)
+ .matcherCondition("rcpt1@" + DEFAULT_DOMAIN)
+ .mailet(LogMessage.class)
+ .addProperty("passThrough", "true"))
+ .addMailet(MailetConfiguration.builder()
+ .matcher(RecipientIs.class)
+ .matcherCondition("rcpt2@" + DEFAULT_DOMAIN)
+ .mailet(LogMessage.class)
+ .addProperty("passThrough", "true"))
+ .addMailet(MailetConfiguration.builder()
+ .matcher(RecipientIs.class)
+ .matcherCondition("rcpt3@" + DEFAULT_DOMAIN)
+ .mailet(LogMessage.class)
+ .addProperty("passThrough", "true"))
+ .addMailet(MailetConfiguration.builder()
+ .matcher(RecipientIs.class)
+ .matcherCondition("rcpt4@" + DEFAULT_DOMAIN)
+ .mailet(LogMessage.class)
+ .addProperty("passThrough", "true"))
+ .addMailet(MailetConfiguration.builder()
+ .matcher(RecipientIs.class)
+ .matcherCondition("rcpt5@" + DEFAULT_DOMAIN)
+ .mailet(LogMessage.class)
+ .addProperty("passThrough", "true"))
+ .addMailetsFrom(CommonProcessors.deliverOnlyTransport()));
Review comment:
If "writes" are performed, then content are not shareable anymore, and
copy will happen anyway with the cow proxy.
Doing only reads, where things can be shared, and avoiding copy, was my
intention...
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> MimeMessageCopyOnWriteProxy is not thread safe
> ----------------------------------------------
>
> Key: JAMES-3477
> URL: https://issues.apache.org/jira/browse/JAMES-3477
> Project: James Server
> Issue Type: Wish
> Reporter: Benoit Tellier
> Priority: Major
>
> https://www.mail-archive.com/[email protected]/msg69221.html
> &
> https://github.com/jeantil/james-project/commit/c0354ea21c5b0a8f6d46e9919f7db0d97db9eb23
> proves there is a concurrency issue in MimeMessageCopyOnWriteProxy class that
> we need to investigate.
> It causes our test suite to be flacky.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]