async_render 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4233e16eefe728ce0620a058495d7daecaee4a591f433b3637d01c5489896a2
4
- data.tar.gz: dc2d826a7de38fd8140f696cdc2abd64080ccaa8ec0ad291a3645e68b065b62e
3
+ metadata.gz: 4198331a3b4cea32f2e5efb02ca0f616bca9d77796ba0e39df3bf467258cc878
4
+ data.tar.gz: 2e99dfe1fc5cf022f96b5df0175e1ed1c7dda1412aad4254f53cdb05b26774a7
5
5
  SHA512:
6
- metadata.gz: 7bebb2d37c302a42c6af8847850cb6efab86ea40576a31673db7ca9604f19cf091cb9e59326b05fb6fe4c21aee2d1f425ec0919ecfc6e70835ea5d07b56a2450
7
- data.tar.gz: 9930ca4a9f7db3225ca6fb9407ba62c673a57e70eb2b6dfcf0ed24cf90035ef6836a5f76fa924cd52729ad98e7b32d1b597c76737d7a8934be0d77cae66c0ab3
6
+ metadata.gz: befb63ff7447523674815182bbf5728ce0f0bf0995aeb0072f1b5d51912e05738f69a57588d47682c1b7ab2a6a6ed1ab1a5bed35cba2b1755b125c76f42b52f3
7
+ data.tar.gz: a54e8796393bd64f4262c555fc5245efd71ea44fe38c939bd486bf00df2b1e29ebd140622879edd2e3466a2220c7878e4cd2068109ac48ef4a5cbdbd8cb119e0
data/README.md CHANGED
@@ -11,6 +11,7 @@ On my pet project and my benchmark, I've seen 5-15% improvement in response time
11
11
  - you have heavy partials
12
12
  - you have partials, with calculations inside, that can be done in background
13
13
  - your partials has none or a few dependencies on locals
14
+ - you have 2+ partials with rendering time more than 100ms
14
15
  - you have HTML request format (see `Limitations` section)
15
16
  - you are curious about performance :)
16
17
 
@@ -19,16 +20,27 @@ On my pet project and my benchmark, I've seen 5-15% improvement in response time
19
20
  ![AsyncRender Logo](docs/idea.png)
20
21
 
21
22
  ### 🔄 Async Rendering
23
+
22
24
  Render multiple view partials asynchronously in background threads, reducing overall page load time by executing independent renders concurrently.
23
25
 
26
+ Use cases:
27
+ - heavy partials, maybe with calculations inside
28
+ - 2+ partials with rendering time more than 100ms
29
+
24
30
  ### 🔥 Warmup Rendering
31
+
25
32
  Pre-render partials in your controller actions before the main view is processed. This allows expensive computations to start early and be ready when needed. This must be used in combination with async rendering.
26
33
 
34
+ Use cases:
35
+ - you are sure that some partials will be rendered
36
+
27
37
  ### 💾 Memoized Rendering
38
+
28
39
  Cache rendered partials in memory across requests within the same Ruby process, eliminating redundant rendering of static or rarely-changing content. Warning: do not use it for large amount of content, it will eat up your memory.
29
40
 
30
- ### ⚡ Smart Thread Pool Management
31
- Automatically configures thread pool size based on your database connection pool and Rails configuration to prevent resource contention.
41
+ Use cases:
42
+ - you have static or rarely-changing content (like google analytics, modal, etc)
43
+ - it's okay to cache it in memory, and it will be reset after next deployment
32
44
 
33
45
  ## 📦 Installation
34
46
 
@@ -160,6 +172,7 @@ For content that rarely changes, use memoized rendering to cache results in memo
160
172
  - if you use "Current" attributes, you need to pass them as locals, or pass as state to render (see `dump_state_proc` and `restore_state_proc` in the initializer)
161
173
  - warmup rendering under the hood uses simply before_action, so you need to prepare data in the controller action, not in the view.
162
174
  - for now only HTML request format is supported, but I'm working on it.
175
+ - it will mess up your logs, because some rendering may happen after logs like "Completed 200 OK in 1761ms".
163
176
 
164
177
  ### ✅ Do
165
178
 
@@ -175,6 +188,18 @@ For content that rarely changes, use memoized rendering to cache results in memo
175
188
  - Rely on request-specific data without proper state management
176
189
  - Use excessive async rendering that could exhaust database connections
177
190
 
191
+ ## Testing in Production
192
+
193
+ For example you can disable async rendering:
194
+
195
+ ```ruby
196
+ class ApplicationController < ActionController::Base
197
+ before_action do
198
+ AsyncRender.enabled = params[:skip_async].blank?
199
+ end
200
+ end
201
+ ```
202
+
178
203
  ## Performance Considerations
179
204
 
180
205
  - The gem automatically limits parallelism based on available database connections
@@ -1,3 +1,3 @@
1
1
  module AsyncRender
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async_render
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Kasyanchuk