macOS上的应用程序运行速度极慢

问题描述 投票:3回答:1

几周以来,我的rails应用程序出现了问题。首先,我必须精确地说,只有一个应用程序会出现此问题,但是该同一个应用程序在同事的计算机上(具有类似的性能)以及在过渡环境中的服务器上都可以很好地运行。

当我说非常慢时,它非常慢。有时,一个简单的ajax请求有时会花费5秒钟以上。当我单击徽标进入根页面时,单击和开始加载之间会有几秒钟的延迟。每次更改页面至少需要5秒钟...

这是我的development.rb:

# frozen_string_literal: true

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports.
  config.consider_all_requests_local = true

  # Enable/disable caching. By default caching is disabled.
  # Run rails dev:cache to toggle caching.
  if Rails.root.join('tmp', 'caching-dev.txt').exist?
    config.action_controller.perform_caching = true

    config.cache_store = :memory_store
    config.public_file_server.headers = {
      'Cache-Control' => "public, max-age=#{2.days.to_i}"
    }
  else
    config.action_controller.perform_caching = false

    config.cache_store = :null_store
  end

  # Store uploaded files on the local file system (see config/storage.yml for options)
  config.active_storage.service = :local

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Highlight code that triggered database queries in logs.
  config.active_record.verbose_query_logs = true

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = false
  config.assets.digest = false

  # Suppress logger output for asset requests.
  config.assets.quiet = true

  # Raises error for missing translations
  # config.action_view.raise_on_missing_translations = true

  # Use an evented file watcher to asynchronously detect changes in source code,
  # routes, locales, etc. This feature depends on the listen gem.
  # config.file_watcher = ActiveSupport::EventedFileUpdateChecker

  config.action_mailer.raise_delivery_errors = false
  config.action_mailer.perform_caching = false
  config.action_mailer.default_url_options = { host: '0.0.0.0', port: '3000' }
  config.action_mailer.asset_host = 'http://0.0.0.0:3000'
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address: 'localhost',
    port:    1025
  }

  config.after_initialize do
    Bullet.enable = true
    Bullet.console = true
    Bullet.alert = true
  end
end

我的配置没有任何更改可能导致此问题。它出现在Firefox,Chrome和Safari上,并且每个浏览器都是最新的。

另一方面,我的Mac在出现问题后不久就出现了奇怪的行为,并以非常长的负载重新启动,例如更新(但不是)并使用美国键盘配置(从未这样做过)和一些不再存在的本地宝石(例如Rails本身,capistrano,rspec ...),所以我不知道它是否相关。

奇怪的事实是:

例如,ajax请求在Chrome基准测试中需要2600毫秒。在基准测试中,脚本,渲染,绘画和其他花费约90毫秒,而空闲则花费约2510毫秒。

如果我检查日志,则有以下内容:Completed 200 OK in 228ms (Views: 0.2ms | ActiveRecord: 27.7ms)

加载后(超过2秒),完成状态会显示在日志中,但指示的时间类似于登台或在我的朋友笔记本电脑上的时间,就像没有问题一样。

所以我不知道在哪里看,当然我清空了缓存,重新启动了服务器和我的计算机,试图更改开发环境配置(没有明显的变化...

这好像是问题不是来自Rails服务器,而是服务器和浏览器之间(因为在基准测试中,'idle'花费了很长时间),但是我不知道这可能是什么。

我还必须澄清,对于MacOS活动监视器,一切正常,并且没有饱和(不活动的CPU约为70%,并且我有超过3.5Gb的可用RAM)

Ruby version: 2.5.1p57
Rails version: 5.2.2

Laptop :
  Macbook Pro 2016 macOS Mojave 10.14.3
  2,6 GHz Intel Core i7
  16 Go 2133 MHz LPDDR3

有人遇到过类似的问题吗?这可能是彪马的问题,如果是的话,怎么知道?

ruby-on-rails macos puma macos-mojave
1个回答
0
投票

您能解决这个问题吗?这正是我现在本地开发机上正在发生的事情。如果您能解决此问题,我将很乐意提供更新,如果可以,如何解决。

谢谢!

© www.soinside.com 2019 - 2024. All rights reserved.