Open ashrafalzyoud opened 1 week ago
@picman
I'm reading more about this topic how I can increase performance because I'm using your plugins to calculate custom field and change statues and assigne And some time to execute code tack more than 15 second because I'm using to update sub task and parents
I hope if there option like using sidekiq and cache
This what I found
Improving performance for redmine_custom_workflows
involves optimizing its custom workflows implementation within Redmine. Here are specific coding strategies and examples to enhance performance:
Optimize Database Queries:
includes
method to eager load associations and avoid N+1 query issues. For example:
@issue = Issue.includes(:custom_field_values).find(params[:id])
where
clauses or joins are indexed appropriately in your database schema.Cache Frequently Accessed Data:
Rails.cache.fetch("custom_workflows_#{project.id}") do
CustomWorkflow.where(project_id: project.id).to_a
end
expires_in
, touch: true
) to invalidate caches when data changes.Refactor and Optimize Code:
Review existing code for performance bottlenecks, such as loops or conditionals that can be optimized. Example:
def calculate_due_date(issue)
# Inefficient version
due_date = issue.start_date + 7.days if issue.start_date.present?
# Optimized version
due_date = issue.start_date + 7.days if issue.start_date
end
Background Jobs for Heavy Tasks:
Sidekiq
or Delayed::Job
to free up resources and improve response times.Reduce Rendering Times:
Monitor and Benchmark:
rack-mini-profiler
, New Relic) to identify slow parts of the application. Benchmark critical sections of code to measure improvements.Handle Large Data Sets Efficiently:
find_each
for ActiveRecord queries to process records in batches.Database and Server Optimization:
By applying these coding strategies and examples specific to redmine_custom_workflows
, you can effectively enhance the performance of custom workflows within your Redmine application. Remember to profile and benchmark changes to validate performance improvements.
A very interesting reading but I don't know how can I help here though.
@picman In number 2,4
Are custom workflow using cache?! Can I using sidekiq in custom workflow?!
No cache is used in the plugin. The plugin is very simple in principle. I just run scripts entered by users. I don't see much what I can speed up. On the other hand you can do whatever you want in your scripts. If you think that some caching would help, give it a try.
Can I use in sidekiq.yml
:verbose: false
:pidfile: ../sidekiq.pid
:logfile: ./log/sidekiq.log
:concurrency: <%= ENV["SIDEKIQ_WORKERS"] || 2 %>
:queues:
- custom_workflow
If I want use cache Where I can configuration it inside the plugin
Rails.cache.fetch("custom_workflows_#{project.id}") do
CustomWorkflow.where(project_id: project.id).to_a
end
Use cache
I want use sidekiq with radis to increase efficiency and performance For recalculate custom field
Sidekiq.yml
What I can do to put queues for Redmine custom work flow