Skip to content
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

Slow to render layout, and too much object(memory) Allocations #105

Open
Kohei909Otsuka opened this issue Mar 23, 2023 · 1 comment
Open

Comments

@Kohei909Otsuka
Copy link

Kohei909Otsuka commented Mar 23, 2023

Using gem "mjml-rails", "~> 4.8.0" it takes too long time to render layout, 20 seconds when worst.

Can you help me?

I have no idea why it takes so long time.

log

2023-03-22T07:00:23.1429795Z	pre-sidekiq	I, [2023-03-21T22:00:20.461420 #161]  INFO -- : [ActiveJob] Enqueued ActionMailer::MailDeliveryJob (Job ID: 3a2596bc-c818-442f-935a-742979d4cff1) to Sidekiq(default) with arguments: "SupplierMailers::SupplierMailer", "quotation_answer_reminder_to_supplier_email", "deliver_now", {:params=>{:quotation_request_member=>#<GlobalID:0x00007fd1791eb520 @uri=#<URI::GID gid://tenant-backend/QuotationRequestMember/29>>}, :args=>[]}	PrimaryResult
2023-03-22T07:02:12.1794285Z	pre-sidekiq	I, [2023-03-21T22:02:11.558580 #161]  INFO -- : [ActiveJob] [ActionMailer::MailDeliveryJob] [3a2596bc-c818-442f-935a-742979d4cff1]   Rendered supplier_mailers/supplier_mailer/quotation_answer_reminder_to_supplier_email.html.mjml within layouts/supplier_mailer (Duration: 179.7ms | Allocations: 9239)	PrimaryResult
2023-03-22T07:02:12.1794285Z	pre-sidekiq	I, [2023-03-21T22:02:10.965977 #161]  INFO -- : [ActiveJob] [ActionMailer::MailDeliveryJob] [3a2596bc-c818-442f-935a-742979d4cff1] Performing ActionMailer::MailDeliveryJob (Job ID: 3a2596bc-c818-442f-935a-742979d4cff1) from Sidekiq(default) enqueued at 2023-03-21T22:00:20Z with arguments: "SupplierMailers::SupplierMailer", "quotation_answer_reminder_to_supplier_email", "deliver_now", {:params=>{:quotation_request_member=>#<GlobalID:0x00007f92df570d40 @uri=#<URI::GID gid://tenant-backend/QuotationRequestMember/29>>}, :args=>[]}	PrimaryResult
2023-03-22T07:02:33.1309723Z	pre-sidekiq	I, [2023-03-21T22:02:31.861821 #161]  INFO -- : [ActiveJob] [ActionMailer::MailDeliveryJob] [3a2596bc-c818-442f-935a-742979d4cff1]   Rendered layout layouts/supplier_mailer.text.erb (Duration: 1.9ms | Allocations: 377)	PrimaryResult
2023-03-22T07:02:33.1309723Z	pre-sidekiq	I, [2023-03-21T22:02:31.859163 #161]  INFO -- : [ActiveJob] [ActionMailer::MailDeliveryJob] [3a2596bc-c818-442f-935a-742979d4cff1]   Rendered layout layouts/supplier_mailer.html.mjml (Duration: 20480.5ms | Allocations: 76291)	PrimaryResult
2023-03-22T07:02:33.1309723Z	pre-sidekiq	I, [2023-03-21T22:02:31.861299 #161]  INFO -- : [ActiveJob] [ActionMailer::MailDeliveryJob] [3a2596bc-c818-442f-935a-742979d4cff1]   Rendered supplier_mailers/supplier_mailer/quotation_answer_reminder_to_supplier_email.text.erb within layouts/supplier_mailer (Duration: 1.3ms | Allocations: 241)	PrimaryResult
2023-03-22T07:02:34.4510409Z	pre-sidekiq	I, [2023-03-21T22:02:33.662105 #161]  INFO -- : [ActiveJob] [ActionMailer::MailDeliveryJob] [3a2596bc-c818-442f-935a-742979d4cff1] Performed ActionMailer::MailDeliveryJob (Job ID: 3a2596bc-c818-442f-935a-742979d4cff1) from Sidekiq(default) in 22992.59ms	PrimaryResult
2023-03-22T07:02:34.4510409Z	pre-sidekiq	I, [2023-03-21T22:02:33.661777 #161]  INFO -- : [ActiveJob] [ActionMailer::MailDeliveryJob] [3a2596bc-c818-442f-935a-742979d4cff1] Delivered mail 641a2977eafad_a1141406962e@pre-sidekiq--26r31ts-858bf784f9-8x2rx.mail (1700.7ms)	PrimaryResult

point is ...

Rendered layout layouts/supplier_mailer.text.erb (Duration: 1.9ms | Allocations: 377)  PrimaryResult
Rendered layout layouts/supplier_mailer.html.mjml (Duration: 20480.5ms | Allocations: 76291) PrimaryResult
====> 20seconds to render layout!!

content of layouts/supplier_mailer.html.mjml

<mjml>
  <mj-head>
    <mj-attributes>
      <mj-button background-color="#1976d2" color="white" />
      <mj-divider border-width="1px" border-style="solid" border-color="#cccccc" />
      <mj-all font-family="Hiragino Sans, sans-serif" font-size="15px" />
    </mj-attributes>
    <mj-style>
      .receiver {
        font-size: 18px !important;
        font-weight: bold;
      }

      .important {
        color: #1976d2 !important;
        font-weight: bold;
      }

      .alert {
        color: #d21919 !important;
        font-weight: bold;
      }

      .from {
      	font-size: 13px;
      	background-color: #ddd;
        padding:3px;
        border-radius:15%
      }

      p {
        line-height: 0.7;
      }
    </mj-style>
  </mj-head>
  <mj-body background-color="#f0f0f0">
    <mj-section padding-top="30px" padding-bottom="0px">
      <mj-column>
        <mj-text align="center" color="#085995" font-family="Roboto">
          <h1>Nitoel</h1>
        </mj-text>
      </mj-column>
    </mj-section>

    <mj-section background-color="#fff">
      <%= yield %>
    </mj-section>

    <mj-section>
      <mj-column>
        <mj-text font-size="12px" align="center">
          本メールは送信専用メールアドレスから送信されております。<br />
          ご返信いただいてもお答えできませんのでご了承ください。<br />
          ご不明点がございましたら、依頼元担当者様宛にお問い合わせをお願いいたします。
        </mj-text>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>
@sighmon
Copy link
Owner

sighmon commented Mar 23, 2023

@Kohei909Otsuka How are you installing it? Have you tried anything in this thread: #76 (comment)

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

No branches or pull requests

2 participants