lowevent 0.8.12 → 0.8.13

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: e0ead6daf7542fde072ab1907f6bf05e3fb32765594ce1d593f105b6d202f0ab
4
- data.tar.gz: 2645e7b2805d4d14d7b1f4bcebf10bee50bedd4a8616b8933fbc06e01da768a7
3
+ metadata.gz: 32b73c3799451315006e5b139bfbc6f18957acc05825a39ad67d0646bbf1c2e5
4
+ data.tar.gz: 4d6675e9d725f3025cbe0556330fbe350e92a83455c61e2700ed52bb4e2498ab
5
5
  SHA512:
6
- metadata.gz: cda989f70964640745573a5f30f30d36c611cf3796afd678073aad5c45de94de111fcb0de0723faf14718a26a69951d8f5f7d646ce78d7128254269d146eacb8
7
- data.tar.gz: 176429dae4e69a11672c2b46b57b5630d998179ebb002e0dc3f2d5d76f19abe89a7560be2a915cc12040a7deb0e2b18f8f3dc847293124cefe3fea124270109a
6
+ metadata.gz: ea2d842804d1a9af242d081c057a9fdb6130fc6d58227c9398d9aadbd91e81d8518ada8aca6e2948fde1121d01e456d72ce601ff46fc3d3043e72c2e79ad1e86
7
+ data.tar.gz: 4c5feca4a64ae7edd11a783506aaad864d69e8167ca5134fc68d019a86dd54ac4463a87549e0c7914b87b8b5d996d8076643c037274c6006ea2657a05eeaed36
@@ -13,6 +13,8 @@ module Low
13
13
 
14
14
  BUFFER_SIZE = 100
15
15
  KEPT_APART_SIZE = 20
16
+ REQUEST_COUNT_BITS = 32
17
+ REQUEST_COUNT_MASK = (1 << REQUEST_COUNT_BITS) - 1
16
18
 
17
19
  # The app's trees, and how many events run each second, however their tree is kept.
18
20
  attr_reader :event_trees, :action_rate
@@ -22,7 +24,6 @@ module Low
22
24
  @event_trees = Support::PoolHash.new(BUFFER_SIZE)
23
25
  @kept_apart_trees = Support::PoolHash.new(KEPT_APART_SIZE)
24
26
  @request_counts = Support::PoolHash.new(BUFFER_SIZE)
25
- @request_ids = Support::PoolHash.new(BUFFER_SIZE) # Each fiber's current request ID, made once for all its events.
26
27
  @kept_apart = nil
27
28
  end
28
29
 
@@ -66,15 +67,17 @@ module Low
66
67
  current_request_id(fiber_id)
67
68
  end
68
69
 
70
+ # The fiber's ID and its count of requests in one Integer, as a string of them would be made for every request.
71
+ # A count of 0 is the fiber's events before its first request. Its count wraps after 4 billion requests, by when
72
+ # trees with the same ID have long left the pool.
69
73
  def current_request_id(fiber_id)
70
- @request_ids[fiber_id] || "#{fiber_id}-#{@request_counts[fiber_id]}"
74
+ (fiber_id << REQUEST_COUNT_BITS) | (@request_counts[fiber_id] || 0)
71
75
  end
72
76
 
73
77
  # Added rather than set, so only the last fibers' counts are kept, as each connection can have a fiber of its own.
74
78
  def increment_request_counts(fiber_id:)
75
- count = (@request_counts[fiber_id] || 0) + 1
79
+ count = ((@request_counts[fiber_id] || 0) + 1) & REQUEST_COUNT_MASK
76
80
  @request_counts.add(fiber_id, count)
77
- @request_ids.add(fiber_id, "#{fiber_id}-#{count}".freeze)
78
81
  end
79
82
  end
80
83
  end
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Low
4
- EVENT_VERSION = '0.8.12'
4
+ EVENT_VERSION = '0.8.13'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lowevent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.12
4
+ version: 0.8.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - maedi