sqreen 1.15.7 → 1.15.8.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29143768deb93b6a47c7804f971242b4700652a3e32ebd7f100346c522da5e73
4
- data.tar.gz: 38eb496eb742d27392ae5587d551668fba57432d29f0dc4199e2f82d6614eb7e
3
+ metadata.gz: 4338bb99bd2f9ed5de996bdb28b9751cdfbbc4385a8caa1f0f7da8ff89a54b01
4
+ data.tar.gz: 410dc9b5f08e2393f73046c3ff17bcd39a3225eca4e5dc6582e8d15ff7d2d9ce
5
5
  SHA512:
6
- metadata.gz: 9a87ceb16ebfbfaa5039ad6425b55bc882d622a448608c7e935e9670e65482ea1d2795c8ef9854d61cfa3a8542354c73cd3e295ea5f85549fe044e60ee529ba1
7
- data.tar.gz: 5dbaeadca8d7fb1f96b4b7710c8ccef57b10b45522b344f7fe2b0440f8cd8b9675e337a52e4a51efbc16d822d43f5ab9397a51ee2647dc38a0948cb7b05bad77
6
+ metadata.gz: 4e8f110c02c0cedbe5afc457f8f743c996359096f0e51fd86ede7ed31d57336e44632b9161e97d6ff1c0be5dac438ac24a48d6bf832d6a2e20407709bfc5c162
7
+ data.tar.gz: 9acf76a1f4c7ac48a4df3955c2ed5d033cb4ce52fa1cd29875007a04e634794d9c7c25c3399be1ed91aec075cf2ee9ac5153b90b2897fba55f67030dba05764b
@@ -59,8 +59,25 @@ module Sqreen
59
59
  end
60
60
  end
61
61
 
62
- def give_back_context(isolate)
63
- @mutex.synchronize { @contexts.push(isolate); }
62
+ def give_back_context(context)
63
+ context.possibly_gc
64
+
65
+ if context.gc_load > 30
66
+ if context.gc_threshold_in_bytes == DEFAULT_GC_THRESHOLD
67
+ context.gc_threshold_in_bytes *= 2
68
+ Sqreen.log.warn('Context %s had too many close garbage collections; ' \
69
+ 'doubling the threshold to %d bytes',
70
+ context, context.gc_threshold_in_bytes)
71
+ context.gc_load = 0
72
+ else
73
+ Sqreen.log.warn('Context %s had too many close garbage ' \
74
+ 'collections; discarding it', context)
75
+ context.dispose
76
+ return
77
+ end
78
+ end
79
+
80
+ @mutex.synchronize { @contexts.push(context); }
64
81
  end
65
82
  end
66
83
 
@@ -194,10 +211,15 @@ module Sqreen
194
211
  private
195
212
 
196
213
  class << self
214
+ DEFAULT_GC_THRESHOLD = 15000000 # 15 MB
215
+
197
216
  def define_sqreen_context(modoole)
198
217
  # Context specialized for Sqreen usage
199
218
  Sqreen::Js.const_set 'SqreenContext', Class.new(modoole.const_get('Context'))
200
219
  SqreenContext.class_eval do
220
+ attr_accessor :gc_threshold_in_bytes
221
+ attr_accessor :gc_load
222
+
201
223
  def has_code?(code_id)
202
224
  return false unless @code_ids
203
225
  @code_ids.include?(code_id)
@@ -233,6 +255,22 @@ module Sqreen
233
255
  end
234
256
  end
235
257
 
258
+ def possibly_gc
259
+ Sqreen.log.warn("Heap usage: #{heap_stats[:total_heap_size]} for #{object_id}")
260
+
261
+ @gc_threshold_in_bytes = DEFAULT_GC_THRESHOLD
262
+ @gc_load ||= 0
263
+
264
+ # garbage collections max 1 in every 4 calls (avg)
265
+ if heap_stats[:total_heap_size] > @gc_threshold_in_bytes
266
+ Sqreen.log.warn("Doing low memory notification for context")
267
+ low_memory_notification
268
+ @gc_load += 4
269
+ else
270
+ @gc_load = [0, @gc_load - 1].max
271
+ end
272
+ end
273
+
236
274
  private
237
275
 
238
276
  def transf_global_funcs(code_id)
data/lib/sqreen/log.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  # Please refer to our terms for more information: https://www.sqreen.io/terms.html
3
3
 
4
4
  require 'logger'
5
+ require 'singleton'
5
6
 
6
7
  require 'sqreen/performance_notifications/log'
7
8
  require 'sqreen/performance_notifications/log_performance'
@@ -1,5 +1,5 @@
1
1
  # Copyright (c) 2015 Sqreen. All Rights Reserved.
2
2
  # Please refer to our terms for more information: https://www.sqreen.io/terms.html
3
3
  module Sqreen
4
- VERSION = '1.15.7'.freeze
4
+ VERSION = '1.15.8.beta1'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqreen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.7
4
+ version: 1.15.8.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sqreen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-29 00:00:00.000000000 Z
11
+ date: 2018-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sq_mini_racer
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.2.sqreen1
19
+ version: 0.2.4.sqreen1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.2.sqreen1
26
+ version: 0.2.4.sqreen1
27
27
  description: Sqreen is a SaaS based Application protection and monitoring platform
28
28
  that integrates directly into your Ruby applications. Learn more at https://sqreen.io.
29
29
  email: contact@sqreen.io
@@ -134,9 +134,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
134
  version: '0'
135
135
  required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - ">="
137
+ - - ">"
138
138
  - !ruby/object:Gem::Version
139
- version: '0'
139
+ version: 1.3.1
140
140
  requirements: []
141
141
  rubyforge_project:
142
142
  rubygems_version: 2.7.7