dhanasingh / redmine_wktime

ERPmine is an open source free ERP for Service Industries. It runs within Redmine
https://erpmine.org/
Other
120 stars 78 forks source link

New Timesheet very slow page #242

Open Paolo486 opened 3 years ago

Paolo486 commented 3 years ago

In section TIME, it is very slow to show the timesheet after i choose the button "add new timesheet".

My client try to connet to https://cdnjs.cloudflare.com a lot of times, but in my lab envoiroment i do not have internet access.

So i have 1/2 minutes of waiting before the page result..

What can i do?

Thansk a lot, P.

Paolo486 commented 3 years ago

image

Paolo486 commented 3 years ago

image

Paolo486 commented 3 years ago

![Uploading image.png…]()

amutha1997 commented 3 years ago

Have you set any value for setting 'Number of Weeks to consider for previous week template' under plugin configuration? if yes what is it?

Timesheet

Amutha

Webinar on "ERPmine - Inventory" on June 29, 2021, at 3 PM IST (GMT+5:30).

Please click here to register if interested, https://us02web.zoom.us/meeting/register/tZIkcuCoqjgjHtGaleP9gjIQE7UVy-cxJb_R

Topics : ● Receive Goods (Shipments) ● Product and items ● Material Log ● Invoice ● Asset and depreciation ● Disposed Asset ● Asset and stock Report

Paolo486 commented 3 years ago

Yes @amutha1997 it's set like you:

image

amutha1997 commented 3 years ago

What version of Redmine and ERPmine are using?

Paolo486 commented 3 years ago

This is my env informations:

Environment: Redmine version 4.1.0.stable Ruby version 2.5.1-p57 (2018-03-29) [x86_64-linux-gnu] Rails version 5.2.4.1 Environment production Database adapter Mysql2 Mailer queue ActiveJob::QueueAdapters::AsyncAdapter Mailer delivery smtp SCM: Git 2.17.1 Filesystem
Redmine plugins: redmine_ckeditor 1.2.3 redmine_dmsf 2.4.5 redmine_issue_templates 1.0.2 redmine_issues_tree 0.0.14 redmine_wktime 4.1 redmine_work_time 0.4.1

on a

NAME="Ubuntu" VERSION="18.04.4 LTS (Bionic Beaver)"

Thanks for the support, P.

amutha1997 commented 3 years ago

Please check the compatibility matrix here http://erpmine.org/projects/erpmine/wiki/Download?page=Download

I think you need get ERPmine 4.0.

Paolo486 commented 3 years ago

With the version 4.0 is more quick , but i have the same issue, i have a lag with the page because my client try to connect internet when i push the page of new timesheet:

image

Paolo486 commented 3 years ago

After i push "continue" after "new timesheet" the page result is slow like the latest wk time version.. now i have this version:

Environment: Redmine version 4.1.0.stable Ruby version 2.5.1-p57 (2018-03-29) [x86_64-linux-gnu] Rails version 5.2.4.1 Environment production Database adapter Mysql2 Mailer queue ActiveJob::QueueAdapters::AsyncAdapter Mailer delivery smtp SCM: Git 2.17.1 Filesystem
Redmine plugins: redmine_ckeditor 1.2.3 redmine_dmsf 2.4.5 redmine_issue_templates 1.0.2 redmine_issues_tree 0.0.14 redmine_wktime 4.0 redmine_work_time 0.4.1

amutha1997 commented 3 years ago

How many rows are you getting in the new timesheet?

If you blank out the setting 'number of weeks to consider for previous weeks’, does it load fast?

Paolo486 commented 3 years ago

Only 1 row: image

Paolo486 commented 3 years ago

I can't set blank: image

Paolo486 commented 3 years ago

The behaviour is the same of the latest plugin version, but is different the web site my client try to "get", now is:

https://cdn.jsdelivr.net

My PC client do not have internet connection or dns resolution for this domain. And the page wait this delay:

image

Thanks, P.

Arun-TAK commented 3 years ago

If getting those js and css files are causing delays for you, You can copy those css and js files to plugins/redmine_wktime/assets/javascripts and stylesheets folder and Use them directly in the erb files.

ol.css.zip ol.js.zip select2.min.css.zip select2.min.js.zip

These are the erb files you need to change,

  1. /plugins/redmine_wktime/app/views/wkgeolocation/_location_map.html.erb
  2. /plugins/redmine_wktime/app/views/wktime/_edit_issues2.html.erb

Here is the changes you need to make

  1. In _location_map.html.erb replace lines 1 and 2 with following lines. <%= javascript_include_tag 'ol', :plugin => "redmine_wktime" %> <%= stylesheet_link_tag 'ol', :plugin => "redmine_wktime" %>
  2. In _edit_issues2.html.erb replace lines 1 and 2 with following lines. <%= javascript_include_tag 'select2.min', :plugin => "redmine_wktime" %> <%= stylesheet_link_tag 'select2.min', :plugin => "redmine_wktime" %>

Can you try these and let me know ?

Paolo486 commented 3 years ago

Hello Arun-TAK, I donwloaded the css and js files, i upload on my redmine_wktime folders, after i modify the files html.erb with the lines you pasteed here.

I restarted redmine.

After this my redmine site does not run correctly and goes crash with this errors:

root@ITprojectTEST:/opt/redmine/tmp# grep -ri 8d24468b /var/log/ /var/log/nginx/error.log.1: Error ID: 8d24468b /var/log/nginx/error.log.1:[ E 2021-06-14 13:14:25.9548 1505/Td age/Cor/Con/CheckoutSession.cpp:276 ]: [Client 3-913] Cannot checkout session because a spawning error occurred. The identifier of the error is 8d24468b. Please see earlier logs for details about the error.

root@ITprojectTEST:/opt/redmine/tmp# tail -10 /var/log/nginx/error.log.1 App 18802 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:189:in block in <module:App>' App 18802 output: /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:380:inrun_block_and_record_step_progress' App 18802 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:188:in <module:App>' App 18802 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:30:in' App 18802 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `

' [ E 2021-06-14 13:14:25.9503 1505/Tm1 age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /opt/redmine: The application encountered the following error: Could not copy /opt/redmine/plugins/redmine_wktime/assets/stylesheets/ol.css to /opt/redmine/public/plugin_assets/redmine_wktime/stylesheets/ol.css: Permission denied @ rb_sysopen - /opt/redmine/public/plugin_assets/redmine_wktime/stylesheets/ol.css (RuntimeError) Error ID: 8d24468b Error details saved to: /tmp/passenger-error-ADfpWi.html

[ E 2021-06-14 13:14:25.9548 1505/Td age/Cor/Con/CheckoutSession.cpp:276 ]: [Client 3-913] Cannot checkout session because a spawning error occurred. The identifier of the error is 8d24468b. Please see earlier logs for details about the error.

Arun-TAK commented 3 years ago

It says there is a permission error to this folder /opt/redmine/public/plugin_assets/redmine_wktime/stylesheets/

Please check folder permission then restart the server and try again.

Paolo486 commented 3 years ago

Hello Arun, i set 777 for stylesheets folders and for redmine_wktime:

chmod 777 /opt/redmine/public/plugin_assets/redmine_wktime/ chmod 777 /opt/redmine/public/plugin_assets/redmine_wktime/stylesheets/

i restart redmine

touch restart.txt

But the same error page and the same error on log:

App 14667 output: /usr/share/passenger/helper-scripts/rack-preloader.rb:29:in `

' [ E 2021-06-15 08:18:18.3361 1505/Tq8 age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /opt/redmine: The application encountered the following error: Could not copy /opt/redmine/plugins/redmine_wktime/assets/javascripts/select2.min.js to /opt/redmine/public/plugin_assets/redmine_wktime/javascripts/select2.min.js: Permission denied @ rb_sysopen - /opt/redmine/public/plugin_assets/redmine_wktime/javascripts/select2.min.js (RuntimeError) Error ID: a4415eb8 Error details saved to: /tmp/passenger-error-TUgRu5.html

[ E 2021-06-15 08:18:18.3424 1505/Ta age/Cor/Con/CheckoutSession.cpp:276 ]: [Client 2-922] Cannot checkout session because a spawning error occurred. The identifier of the error is a4415eb8. Please see earlier logs for details about the error.

amutha1997 commented 3 years ago

Hi,

There is another folder /opt/redmine/public/plugin_assets/redmine_wktime/javascripts You have to change the permission.

Paolo486 commented 3 years ago

OK, i changed the permission and now the redmine website started. But the plugin does not work correctly.

When i push on "new timesheet" the issue list is without the table sheet. i't not possibile to insert times..

I disinstalled e re installed the plug in.

I repeat test and give you a new feedback, thanks.

P.

surebrec commented 2 years ago

image

i am also have the same issue. delay is about 5 sec, but it has nothing with loading JS or CSS from the web

system:

Environment:
  Redmine version                4.2.2.stable
  Ruby version                   2.7.2-p137 (2020-10-01) [x86_64-linux]
  Rails version                  5.2.6
  Environment                    production
  Database adapter               Mysql2
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                smtp
SCM:
  Filesystem                     
Redmine plugins:
  redmine_wktime                 4.3.1
JeffDess commented 1 year ago

Having the same issue with a very large database (migrated from Redmine v3). A single request to an existing timesheet requires about 4~6 sec to respond. During this time, the web server (Puma) jumps to 95%+ CPU.

From what I observed, it seems to scale with concurrent requests. When two users load a timesheet simultaneously, the first would get a response in about 5sec and the second would have to wait about 10sec to get the response. Imagine dozens of users, this is a serious performance issue!

I've tried to replicate with an empty database on a staging environment and the load times were normal. So it looks like the web server is doing some intense calculations with the SQL response? Perhaps using some sort of caching would help? And/Or making it non-blocking?

I've tried database optimization and scaling the server CPU/Memory, but it made no difference.

I'm running the default Redmine Docker image:

Environment:
  Redmine version                5.0.5.stable
  Ruby version                   3.1.4-p223 (2023-03-30) [x86_64-linux-musl]
  Rails version                  6.1.7.2
  Environment                    production
  Database adapter               Mysql2
  [...]
Redmine plugins: 
  [...]
  redmine_wktime                 4.7
cdhana17 commented 1 year ago

How many rows are you seeing in the new timesheet ?

How many unique projects are listed in the rows ? and how many issues each of those projects have ?

JeffDess commented 1 year ago

It's the same load times for new timesheet and saved timesheet with a single row with a small project (~5s). However the project dropdown contains 200 projects (with sub-projects nested up to 5 levels deep). Projects can have up to 2000 issues.

Fillings 10 rows with random projects/issues then saving the timesheet requires over 10 seconds, then reloading the same timesheet with 10 rows takes also over 10~11 seconds. I tested this request 4 times concurrently and the responses arrived from 30 to 38 seconds after the request:

image

Nobody is using this server right now, so it is really the only requests the server is handling.

cdhana17 commented 11 months ago

I think loading the issue dropdown with 2000 issues may be slowing it down. May be we will have to have a searchable textbox instead of a dropdown, we will try and include this in the next release

JeffDess commented 11 months ago

Ok thanks, that would be great! In the meantime I may perform some testing with that specific dataset in order to pinpoint more precisely the source of the slowdown.

JeffDess commented 11 months ago

So I got to test it a bit with my dataset and I found out that in wktime_controller:141 there's a a member loop nested in a project loop. Commenting these 4 lines alone results in 25% loading times for a new timesheet (say 1\~1.5s instead of 4~6s). So I guess it have more to do with members/projects counts rather than issues/projects? https://github.com/dhanasingh/redmine_wktime/blob/f977049ce3d59fff80f78b47fb2e5358ca1223ee/app/controllers/wktime_controller.rb#L141-L144

JeffDess commented 11 months ago

Hi, just to let you know that I found a fix. I'll benchmark it on the same environment as my other tests, then I could submit a PR if you'd like. But it's looking good so far, about 5x faster and load time is similar to any other pages.