@nxtedition/slice 1.0.7 → 1.0.8
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.
- package/README.md +29 -17
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -45,29 +45,41 @@ Measured on Apple M3 Pro, Node.js v25.3.0:
|
|
|
45
45
|
### Allocation
|
|
46
46
|
|
|
47
47
|
| Operation | `Buffer.allocUnsafe` | `Buffer.allocUnsafeSlow` | `PoolAllocator` | Speedup |
|
|
48
|
-
| ---------------- |
|
|
49
|
-
| alloc 64 bytes |
|
|
50
|
-
| alloc 256 bytes |
|
|
51
|
-
| alloc 1024 bytes |
|
|
52
|
-
| alloc 4096 bytes |
|
|
48
|
+
| ---------------- | -------------------: | -----------------------: | --------------: | ------: |
|
|
49
|
+
| alloc 64 bytes | 38.08 ns | 41.23 ns | **5.66 ns** | 6.7x |
|
|
50
|
+
| alloc 256 bytes | 52.09 ns | 231.46 ns | **5.90 ns** | 8.8x |
|
|
51
|
+
| alloc 1024 bytes | 91.24 ns | 340.75 ns | **5.83 ns** | 15.6x |
|
|
52
|
+
| alloc 4096 bytes | 446.53 ns | 437.83 ns | **6.24 ns** | 71.6x |
|
|
53
|
+
|
|
54
|
+
### Allocation (GC)
|
|
55
|
+
|
|
56
|
+
| Operation | `Buffer.allocUnsafe` | `Buffer.allocUnsafeSlow` | `PoolAllocator` | Speedup |
|
|
57
|
+
| ---------------- | -------------------: | -----------------------: | --------------: | ------: |
|
|
58
|
+
| alloc 64 bytes | 400.46 ns | 167.94 ns | **6.33 ns** | 63.3x |
|
|
59
|
+
| alloc 256 bytes | 309.57 ns | 500.58 ns | **6.35 ns** | 48.7x |
|
|
60
|
+
| alloc 4096 bytes | 653.40 ns | 620.19 ns | **6.32 ns** | 103.4x |
|
|
61
|
+
|
|
62
|
+
Under GC pressure, the advantage grows dramatically — up to **103x** faster — because `PoolAllocator` reuses slots from a pre-allocated buffer and never creates objects for V8 to trace.
|
|
53
63
|
|
|
54
64
|
### Slice creation vs `Buffer.subarray`
|
|
55
65
|
|
|
56
|
-
| Operation
|
|
57
|
-
|
|
|
58
|
-
| subarray 64 bytes
|
|
59
|
-
| subarray 1024 bytes
|
|
66
|
+
| Operation | `Buffer.subarray` | `Slice` | Speedup |
|
|
67
|
+
| ---------------------- | ----------------: | -----------: | ------: |
|
|
68
|
+
| subarray 64 bytes | 38.11 ns | **12.99 ns** | 2.9x |
|
|
69
|
+
| subarray 1024 bytes | 36.87 ns | **13.26 ns** | 2.8x |
|
|
70
|
+
| subarray 64 bytes (GC) | 127.30 ns | **81.60 ns** | 1.6x |
|
|
60
71
|
|
|
61
72
|
### Combined operations
|
|
62
73
|
|
|
63
|
-
| Operation |
|
|
64
|
-
| ------------------------------------- |
|
|
65
|
-
|
|
|
66
|
-
| alloc/free 64 bytes
|
|
67
|
-
| alloc/free 256 bytes |
|
|
68
|
-
| realloc churn (64 → 128 → 64) |
|
|
69
|
-
| realloc in-place (grow within bucket) |
|
|
70
|
-
| 10 concurrent allocs then free |
|
|
74
|
+
| Operation | `Buffer` | `PoolAllocator` | Speedup |
|
|
75
|
+
| ------------------------------------- | --------: | --------------: | ------: |
|
|
76
|
+
| alloc/free 64 bytes | 32.72 ns | **30.80 ns** | 1.1x |
|
|
77
|
+
| alloc/free 64 bytes (GC) | 273.35 ns | **73.34 ns** | 3.7x |
|
|
78
|
+
| alloc/free 256 bytes | 58.88 ns | **29.38 ns** | 2.0x |
|
|
79
|
+
| realloc churn (64 → 128 → 64) | 93.63 ns | **26.99 ns** | 3.5x |
|
|
80
|
+
| realloc in-place (grow within bucket) | 60.16 ns | **11.06 ns** | 5.4x |
|
|
81
|
+
| 10 concurrent allocs then free | 406.26 ns | **337.83 ns** | 1.2x |
|
|
82
|
+
| 10 concurrent allocs then free (GC) | 647.95 ns | **649.73 ns** | 1.0x |
|
|
71
83
|
|
|
72
84
|
## API
|
|
73
85
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxtedition/slice",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"rimraf": "^6.1.2",
|
|
29
29
|
"typescript": "^5.9.3"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "12c38fec15bd155797cb1edae372a81061715df3"
|
|
32
32
|
}
|