@fjell/registry 4.4.52 → 4.4.53
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/package.json +4 -4
- package/API.md +0 -62
- package/GETTING_STARTED.md +0 -69
- package/build.js +0 -38
- package/docs/README.md +0 -74
- package/docs/TIMING_NODE_OPTIMIZATION.md +0 -207
- package/docs/TIMING_README.md +0 -170
- package/docs/docs.config.ts +0 -114
- package/docs/index.html +0 -26
- package/docs/package-lock.json +0 -5129
- package/docs/package.json +0 -34
- package/docs/public/404.html +0 -53
- package/docs/public/GETTING_STARTED.md +0 -69
- package/docs/public/README.md +0 -623
- package/docs/public/TIMING_NODE_OPTIMIZATION.md +0 -207
- package/docs/public/api.md +0 -62
- package/docs/public/client-api-overview.md +0 -137
- package/docs/public/configuration.md +0 -759
- package/docs/public/error-handling/README.md +0 -356
- package/docs/public/error-handling/network-errors.md +0 -485
- package/docs/public/examples/coordinates-example.ts +0 -253
- package/docs/public/examples/multi-level-keys.ts +0 -374
- package/docs/public/examples/registry-hub-coordinates-example.ts +0 -370
- package/docs/public/examples/registry-hub-types.ts +0 -437
- package/docs/public/examples/simple-example.ts +0 -250
- package/docs/public/examples-README.md +0 -241
- package/docs/public/fjell-icon.svg +0 -1
- package/docs/public/icon.png +0 -0
- package/docs/public/icon2.png +0 -0
- package/docs/public/memory-overhead.svg +0 -120
- package/docs/public/memory.md +0 -430
- package/docs/public/operations/README.md +0 -121
- package/docs/public/operations/all.md +0 -325
- package/docs/public/operations/create.md +0 -415
- package/docs/public/operations/get.md +0 -389
- package/docs/public/package.json +0 -63
- package/docs/public/pano.png +0 -0
- package/docs/public/pano2.png +0 -0
- package/docs/public/timing-range.svg +0 -176
- package/docs/public/timing.md +0 -483
- package/docs/timing-range.svg +0 -174
- package/docs/vitest.config.ts +0 -14
- package/examples/README.md +0 -241
- package/examples/coordinates-example.ts +0 -253
- package/examples/multi-level-keys.ts +0 -382
- package/examples/registry-hub-coordinates-example.ts +0 -370
- package/examples/registry-hub-types.ts +0 -437
- package/examples/registry-statistics-example.ts +0 -264
- package/examples/simple-example.ts +0 -250
- package/tsconfig.docs.json +0 -28
- package/vitest.config.ts +0 -22
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fjell/registry",
|
|
3
3
|
"description": "Dependency injection and service location system for the Fjell ecosystem",
|
|
4
|
-
"version": "4.4.
|
|
4
|
+
"version": "4.4.53",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"registry",
|
|
7
7
|
"dependency-injection",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"docs:test": "cd docs && npm run test"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@fjell/core": "^4.4.
|
|
43
|
-
"@fjell/logging": "^4.4.
|
|
42
|
+
"@fjell/core": "^4.4.51",
|
|
43
|
+
"@fjell/logging": "^4.4.50"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@eslint/eslintrc": "^3.3.1",
|
|
47
47
|
"@eslint/js": "^9.32.0",
|
|
48
|
-
"@fjell/eslint-config": "^1.1.
|
|
48
|
+
"@fjell/eslint-config": "^1.1.28",
|
|
49
49
|
"@swc/core": "^1.13.2",
|
|
50
50
|
"@tsconfig/recommended": "^1.0.10",
|
|
51
51
|
"@types/node": "^22.10.0",
|
package/API.md
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# API Reference
|
|
2
|
-
|
|
3
|
-
Complete Registry API documentation and method reference.
|
|
4
|
-
|
|
5
|
-
## Core Registry Interface
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
interface Registry {
|
|
9
|
-
readonly type: string; // Mandatory type identifier
|
|
10
|
-
createInstance: <...>(...) => Instance<...>;
|
|
11
|
-
get: (...) => Instance | null;
|
|
12
|
-
getCoordinates: () => Coordinate[]; // Discover all registered coordinates
|
|
13
|
-
instanceTree: InstanceTree;
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Primary Methods
|
|
18
|
-
|
|
19
|
-
### `createRegistry(type: string): Registry`
|
|
20
|
-
Creates a new registry with the specified type identifier.
|
|
21
|
-
|
|
22
|
-
### `registry.createInstance(kta, scopes, factory)`
|
|
23
|
-
Registers a new service instance with the given key type array and scopes.
|
|
24
|
-
|
|
25
|
-
### `registry.get(kta, options)`
|
|
26
|
-
Retrieves a service instance by key type array and scope options.
|
|
27
|
-
|
|
28
|
-
### `registry.getCoordinates(): Coordinate[]`
|
|
29
|
-
Returns all registered coordinates for service discovery and introspection.
|
|
30
|
-
|
|
31
|
-
## RegistryHub Interface
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
interface RegistryHub {
|
|
35
|
-
registerRegistry: (registry: Registry) => void;
|
|
36
|
-
get: (registryType: string, kta: string[], options?: GetOptions) => Instance | null;
|
|
37
|
-
getRegistries: () => Registry[];
|
|
38
|
-
getAllCoordinates: () => Array<{coordinate: Coordinate, registryType: string}>;
|
|
39
|
-
}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Coordinate System
|
|
43
|
-
|
|
44
|
-
```typescript
|
|
45
|
-
interface Coordinate {
|
|
46
|
-
kta: string[]; // Key Type Array - hierarchical identifiers
|
|
47
|
-
scopes: string[]; // Context qualifiers
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Complete Documentation
|
|
52
|
-
|
|
53
|
-
For comprehensive API documentation with detailed examples, implementation patterns, and advanced usage scenarios, see the **Foundation** section which contains the complete Registry documentation including:
|
|
54
|
-
|
|
55
|
-
- Interface definitions and type signatures
|
|
56
|
-
- Detailed method documentation with examples
|
|
57
|
-
- Registry and RegistryHub patterns
|
|
58
|
-
- Coordinate system explanation
|
|
59
|
-
- Service discovery and introspection
|
|
60
|
-
- Error handling and best practices
|
|
61
|
-
|
|
62
|
-
The Foundation section serves as the authoritative API reference with full context and examples.
|
package/GETTING_STARTED.md
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# Getting Started
|
|
2
|
-
|
|
3
|
-
Quick start guide to using Fjell Registry in your applications.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @fjell/registry
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Basic Usage
|
|
12
|
-
|
|
13
|
-
The simplest way to get started with Registry:
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
import { createRegistry, createInstance } from '@fjell/registry'
|
|
17
|
-
|
|
18
|
-
// Create a registry with a type identifier
|
|
19
|
-
const registry = createRegistry('services')
|
|
20
|
-
|
|
21
|
-
// Register a simple service
|
|
22
|
-
registry.createInstance(['logger'], [], (coordinate, context) => {
|
|
23
|
-
const service = new LoggerService()
|
|
24
|
-
const instance = createInstance(context.registry, coordinate)
|
|
25
|
-
|
|
26
|
-
// Attach service methods to the instance
|
|
27
|
-
(instance as any).log = service.log.bind(service)
|
|
28
|
-
return instance
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
// Retrieve and use the service
|
|
32
|
-
const logger = registry.get(['logger'], [])
|
|
33
|
-
logger?.log('Hello from Registry!')
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
## Core Concepts Quick Reference
|
|
37
|
-
|
|
38
|
-
- **Registry**: Central service container with a mandatory type identifier
|
|
39
|
-
- **Coordinate**: Unique identifier using key types + scopes
|
|
40
|
-
- **Instance**: Registered service with coordinate and registry reference
|
|
41
|
-
- **Scopes**: Context qualifiers like environment or implementation type
|
|
42
|
-
|
|
43
|
-
## Next Steps
|
|
44
|
-
|
|
45
|
-
- Check out the **Examples** section for complete working examples
|
|
46
|
-
- Read the **Foundation** section for deep understanding of concepts
|
|
47
|
-
- Explore the **API Reference** for complete method documentation
|
|
48
|
-
|
|
49
|
-
## Common Patterns
|
|
50
|
-
|
|
51
|
-
### Single Registry (Simple Apps)
|
|
52
|
-
```typescript
|
|
53
|
-
const registry = createRegistry('app')
|
|
54
|
-
// Register all your services here
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### Multiple Registries (Enterprise)
|
|
58
|
-
```typescript
|
|
59
|
-
const servicesRegistry = createRegistry('services')
|
|
60
|
-
const dataRegistry = createRegistry('data')
|
|
61
|
-
const cacheRegistry = createRegistry('cache')
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### Scoped Services
|
|
65
|
-
```typescript
|
|
66
|
-
// Different implementations for different environments
|
|
67
|
-
registry.createInstance(['database'], ['postgresql'], ...)
|
|
68
|
-
registry.createInstance(['database'], ['firestore'], ...)
|
|
69
|
-
```
|
package/build.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { build } from 'esbuild';
|
|
2
|
-
import { execSync } from 'child_process';
|
|
3
|
-
|
|
4
|
-
// Generate TypeScript declarations first
|
|
5
|
-
console.log('Generating TypeScript declarations...');
|
|
6
|
-
try {
|
|
7
|
-
execSync('npx tsc --emitDeclarationOnly', { stdio: 'inherit' });
|
|
8
|
-
console.log('TypeScript declarations generated successfully!');
|
|
9
|
-
} catch (error) {
|
|
10
|
-
console.error('Failed to generate TypeScript declarations:', error.message);
|
|
11
|
-
process.exit(1);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Build cross-platform version that works in both Node.js and browser
|
|
15
|
-
console.log('Building cross-platform version...');
|
|
16
|
-
await build({
|
|
17
|
-
entryPoints: ['src/index.ts'],
|
|
18
|
-
bundle: true,
|
|
19
|
-
platform: 'neutral', // Neutral platform for cross-platform compatibility
|
|
20
|
-
target: 'es2022',
|
|
21
|
-
format: 'esm',
|
|
22
|
-
outfile: 'dist/index.js',
|
|
23
|
-
external: [
|
|
24
|
-
'console',
|
|
25
|
-
'@fjell/core',
|
|
26
|
-
'@fjell/logging'
|
|
27
|
-
], // Keep external dependencies as they should be installed separately
|
|
28
|
-
define: {
|
|
29
|
-
'process.env.NODE_ENV': '"production"'
|
|
30
|
-
},
|
|
31
|
-
metafile: true,
|
|
32
|
-
minify: false, // Keep readable for debugging
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
console.log('Build completed successfully!');
|
|
36
|
-
console.log(`- Cross-platform build: dist/index.js`);
|
|
37
|
-
console.log(`- TypeScript declarations: dist/index.d.ts`);
|
|
38
|
-
console.log('This build works in both Node.js and browser environments');
|
package/docs/README.md
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
# Fjell Registry Documentation Site
|
|
2
|
-
|
|
3
|
-
This is a React-based documentation site for the Fjell Registry package. It provides an interactive and modern way to view the project documentation with syntax highlighting and responsive design.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- **Responsive Design** - Works on desktop, tablet, and mobile
|
|
8
|
-
- **Modern UI** - Clean, modern interface with Fjell branding
|
|
9
|
-
- **Syntax Highlighting** - Code blocks with proper syntax highlighting
|
|
10
|
-
- **Markdown Support** - Full GitHub Flavored Markdown support
|
|
11
|
-
- **Fast Loading** - Built with Vite for optimal performance
|
|
12
|
-
|
|
13
|
-
## Development
|
|
14
|
-
|
|
15
|
-
### Prerequisites
|
|
16
|
-
|
|
17
|
-
- Node.js 22+
|
|
18
|
-
- npm
|
|
19
|
-
|
|
20
|
-
### Local Development
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
# Install dependencies
|
|
24
|
-
npm install
|
|
25
|
-
|
|
26
|
-
# Start development server
|
|
27
|
-
npm run dev
|
|
28
|
-
|
|
29
|
-
# Build for production
|
|
30
|
-
npm run build
|
|
31
|
-
|
|
32
|
-
# Preview production build
|
|
33
|
-
npm run preview
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Testing
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
# Run tests
|
|
40
|
-
npm run test
|
|
41
|
-
|
|
42
|
-
# Run tests in watch mode
|
|
43
|
-
npm run test:watch
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Deployment
|
|
47
|
-
|
|
48
|
-
The site is automatically deployed to GitHub Pages when changes are pushed to the main branch or any release branch. The deployment is handled by the `.github/workflows/deploy-docs.yml` workflow.
|
|
49
|
-
|
|
50
|
-
## Architecture
|
|
51
|
-
|
|
52
|
-
- **React 19** - Modern React with hooks
|
|
53
|
-
- **TypeScript** - Full type safety
|
|
54
|
-
- **Vite** - Fast build tool and dev server
|
|
55
|
-
- **React Markdown** - Renders README.md dynamically
|
|
56
|
-
- **React Syntax Highlighter** - Beautiful code syntax highlighting
|
|
57
|
-
- **Vitest** - Fast unit testing framework
|
|
58
|
-
|
|
59
|
-
## Configuration
|
|
60
|
-
|
|
61
|
-
The site is configured to:
|
|
62
|
-
- Fetch the main README.md from the project root
|
|
63
|
-
- Use the `/fjell-registry/` base path for GitHub Pages
|
|
64
|
-
- Support dark theme code highlighting
|
|
65
|
-
- Include responsive breakpoints for mobile devices
|
|
66
|
-
|
|
67
|
-
## Contributing
|
|
68
|
-
|
|
69
|
-
The documentation site automatically reflects changes to the main README.md file. To update the site itself:
|
|
70
|
-
|
|
71
|
-
1. Make changes to the React components in `src/`
|
|
72
|
-
2. Test locally with `npm run dev`
|
|
73
|
-
3. Commit your changes
|
|
74
|
-
4. The site will automatically deploy via GitHub Actions
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
# Node.js Optimization for Timing Tests
|
|
2
|
-
|
|
3
|
-
This document outlines Node.js runtime parameters that can be tuned to minimize interference and improve timing test accuracy.
|
|
4
|
-
|
|
5
|
-
## Quick Start: Optimized Timing Test
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm run test:timing:optimized
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
This runs timing tests with pre-configured optimal Node.js flags.
|
|
12
|
-
|
|
13
|
-
## Key Node.js Optimization Flags
|
|
14
|
-
|
|
15
|
-
### Memory Management
|
|
16
|
-
|
|
17
|
-
#### `--max-old-space-size=8192`
|
|
18
|
-
- **Purpose**: Increases maximum heap size to 8GB (default ~1.4GB)
|
|
19
|
-
- **Benefit**: Prevents garbage collection during test runs
|
|
20
|
-
- **Why 8GB**: Provides ample headroom for 100 rounds × multiple tree sizes
|
|
21
|
-
- **Alternative**: `--max-old-space-size=4096` for systems with less RAM
|
|
22
|
-
|
|
23
|
-
#### `--max-semi-space-size=1024`
|
|
24
|
-
- **Purpose**: Increases semi-space size to 1GB (default varies)
|
|
25
|
-
- **Benefit**: Reduces minor GC frequency during object allocation
|
|
26
|
-
- **Impact**: Each semi-space can hold more objects before collection
|
|
27
|
-
|
|
28
|
-
### Garbage Collection Control
|
|
29
|
-
|
|
30
|
-
#### `--expose-gc`
|
|
31
|
-
- **Purpose**: Exposes `global.gc()` function for manual garbage collection
|
|
32
|
-
- **Benefit**: Allows forced GC between test rounds for consistent baselines
|
|
33
|
-
- **Usage**: Can trigger GC at specific points to isolate timing measurements
|
|
34
|
-
|
|
35
|
-
#### `--gc-interval=1000000`
|
|
36
|
-
- **Purpose**: Reduces GC frequency (higher number = less frequent)
|
|
37
|
-
- **Benefit**: Minimizes GC interruptions during timing measurements
|
|
38
|
-
- **Trade-off**: Uses more memory but provides consistent timing
|
|
39
|
-
|
|
40
|
-
### Execution Predictability
|
|
41
|
-
|
|
42
|
-
#### `--predictable`
|
|
43
|
-
- **Purpose**: Makes execution more deterministic
|
|
44
|
-
- **Benefit**: Reduces timing variance from non-deterministic optimizations
|
|
45
|
-
- **Impact**: Slightly slower but more consistent measurements
|
|
46
|
-
|
|
47
|
-
#### `--no-compilation-cache`
|
|
48
|
-
- **Purpose**: Disables V8 compilation cache
|
|
49
|
-
- **Benefit**: Ensures consistent JIT compilation behavior across runs
|
|
50
|
-
- **Use Case**: When testing cold start performance or eliminating cache effects
|
|
51
|
-
|
|
52
|
-
### JIT Compilation Control
|
|
53
|
-
|
|
54
|
-
#### `--optimize-for-size`
|
|
55
|
-
- **Purpose**: Optimizes for code size rather than speed
|
|
56
|
-
- **Benefit**: More predictable compilation behavior
|
|
57
|
-
- **Alternative**: `--max-opt` for maximum optimization (less predictable)
|
|
58
|
-
|
|
59
|
-
#### `--no-opt`
|
|
60
|
-
- **Purpose**: Disables JIT compilation entirely
|
|
61
|
-
- **Benefit**: Eliminates JIT timing variance (but much slower execution)
|
|
62
|
-
- **Use Case**: Testing interpreter-only performance
|
|
63
|
-
|
|
64
|
-
## Complete Optimization Command
|
|
65
|
-
|
|
66
|
-
For maximum timing accuracy, use all optimization flags:
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
# Use NODE_OPTIONS for compatibility with modern Node.js
|
|
70
|
-
NODE_OPTIONS="--max-old-space-size=8192 --max-semi-space-size=1024" \
|
|
71
|
-
vitest run tests/timing.test.ts
|
|
72
|
-
|
|
73
|
-
# Or use direct node invocation (requires vitest executable)
|
|
74
|
-
node --max-old-space-size=8192 --max-semi-space-size=1024 \
|
|
75
|
-
./node_modules/vitest/vitest.mjs run tests/timing.test.ts
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## System-Specific Adjustments
|
|
79
|
-
|
|
80
|
-
### Low-Memory Systems (< 8GB RAM)
|
|
81
|
-
```bash
|
|
82
|
-
NODE_OPTIONS="--max-old-space-size=2048 --max-semi-space-size=256" \
|
|
83
|
-
vitest run tests/timing.test.ts
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### High-Memory Systems (> 16GB RAM)
|
|
87
|
-
```bash
|
|
88
|
-
NODE_OPTIONS="--max-old-space-size=16384 --max-semi-space-size=2048" \
|
|
89
|
-
vitest run tests/timing.test.ts
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
### Docker/Container Environments
|
|
93
|
-
```bash
|
|
94
|
-
NODE_OPTIONS="--max-old-space-size=4096 --max-semi-space-size=512" \
|
|
95
|
-
vitest run tests/timing.test.ts
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
## Environment Variables
|
|
99
|
-
|
|
100
|
-
### Additional V8 Options
|
|
101
|
-
```bash
|
|
102
|
-
export NODE_OPTIONS="--max-old-space-size=8192 --max-semi-space-size=1024"
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Memory Monitoring
|
|
106
|
-
```bash
|
|
107
|
-
export NODE_ENV=production # Disable development overhead
|
|
108
|
-
export UV_THREADPOOL_SIZE=8 # Increase thread pool if needed
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
## Monitoring Memory During Tests
|
|
112
|
-
|
|
113
|
-
Add memory monitoring to timing tests:
|
|
114
|
-
|
|
115
|
-
```typescript
|
|
116
|
-
// Add to timing test setup
|
|
117
|
-
if (global.gc) {
|
|
118
|
-
console.log('Memory before tests:', process.memoryUsage());
|
|
119
|
-
global.gc();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Add between test rounds
|
|
123
|
-
if (global.gc && round % 20 === 0) {
|
|
124
|
-
global.gc();
|
|
125
|
-
console.log(`Memory after round ${round}:`, process.memoryUsage());
|
|
126
|
-
}
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## Platform-Specific Considerations
|
|
130
|
-
|
|
131
|
-
### macOS
|
|
132
|
-
- Default memory limits are generous
|
|
133
|
-
- Use `--max-old-space-size=8192` safely
|
|
134
|
-
- Activity Monitor shows Node.js memory usage
|
|
135
|
-
|
|
136
|
-
### Linux
|
|
137
|
-
- Check `ulimit -v` for virtual memory limits
|
|
138
|
-
- May need `sudo sysctl vm.max_map_count=262144` for large heaps
|
|
139
|
-
- Use `htop` or `ps` to monitor memory
|
|
140
|
-
|
|
141
|
-
### Windows
|
|
142
|
-
- WSL may have memory constraints
|
|
143
|
-
- PowerShell: `Get-Process node | Select-Object WorkingSet64`
|
|
144
|
-
- Task Manager shows detailed memory breakdown
|
|
145
|
-
|
|
146
|
-
### CI/CD Environments
|
|
147
|
-
- GitHub Actions: 7GB RAM limit, use `--max-old-space-size=4096`
|
|
148
|
-
- GitLab CI: Variable memory, check runner specs
|
|
149
|
-
- Docker: Set container memory limits appropriately
|
|
150
|
-
|
|
151
|
-
## Performance Analysis Tools
|
|
152
|
-
|
|
153
|
-
### V8 Profiling
|
|
154
|
-
```bash
|
|
155
|
-
node --prof --log-timer-events ./timing-test.js
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
### Heap Snapshots
|
|
159
|
-
```bash
|
|
160
|
-
node --inspect --heap-prof ./timing-test.js
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
### GC Logging
|
|
164
|
-
```bash
|
|
165
|
-
node --trace-gc --trace-gc-verbose ./timing-test.js
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
## Validation
|
|
169
|
-
|
|
170
|
-
Test that optimizations are working:
|
|
171
|
-
|
|
172
|
-
```bash
|
|
173
|
-
# Run normal timing tests
|
|
174
|
-
npm run test:timing
|
|
175
|
-
|
|
176
|
-
# Run optimized timing tests
|
|
177
|
-
npm run test:timing:optimized
|
|
178
|
-
|
|
179
|
-
# Compare results - optimized should show:
|
|
180
|
-
# 1. Lower timing variance (smaller standard deviations)
|
|
181
|
-
# 2. More consistent Bollinger bands
|
|
182
|
-
# 3. Fewer outlier measurements
|
|
183
|
-
# 4. Reduced memory-related timing spikes
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
## Recommended Configuration
|
|
187
|
-
|
|
188
|
-
For most use cases, the optimized configuration provides the best balance:
|
|
189
|
-
|
|
190
|
-
```json
|
|
191
|
-
{
|
|
192
|
-
"scripts": {
|
|
193
|
-
"test:timing:optimized": "NODE_OPTIONS=\"--max-old-space-size=8192 --max-semi-space-size=1024\" vitest run tests/timing.test.ts"
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
This configuration:
|
|
199
|
-
- ✅ Eliminates most GC interference
|
|
200
|
-
- ✅ Provides consistent execution
|
|
201
|
-
- ✅ Works on most development machines
|
|
202
|
-
- ✅ Maintains reasonable test execution time
|
|
203
|
-
- ✅ Produces reliable performance metrics
|
|
204
|
-
|
|
205
|
-
---
|
|
206
|
-
|
|
207
|
-
*For production timing analysis, always use optimized Node.js flags to ensure accurate performance measurements.*
|
package/docs/TIMING_README.md
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
# Timing Test System
|
|
2
|
-
|
|
3
|
-
This document explains the timing test system implemented for the @fjell/registry project.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
The timing test system measures the performance of key operations in the fjell-registry library using robust multi-round testing and generates comprehensive documentation including heatmap visualizations. It runs hundreds of test rounds to smooth out system load variations and provides reliable performance metrics. The system ensures that performance remains within acceptable bounds and helps detect performance regressions.
|
|
8
|
-
|
|
9
|
-
## Running Timing Tests
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
# Run timing tests specifically
|
|
13
|
-
npm run test:timing
|
|
14
|
-
|
|
15
|
-
# Run all tests (including timing tests)
|
|
16
|
-
npm test
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## Measured Operations
|
|
20
|
-
|
|
21
|
-
The timing system measures the following operations:
|
|
22
|
-
|
|
23
|
-
- **createRegistry**: Time to create a new registry
|
|
24
|
-
- **createRegistryHub**: Time to create a new registry hub
|
|
25
|
-
- **createInstance**: Time to create a new instance
|
|
26
|
-
- **registerInstance**: Time to register an instance in registry
|
|
27
|
-
- **lookupInstance**: Time to lookup an existing instance from registry
|
|
28
|
-
- **completeWorkflow**: Time for complete workflow including all operations
|
|
29
|
-
|
|
30
|
-
### Scaling Tests
|
|
31
|
-
|
|
32
|
-
Additionally, the system includes comprehensive scaling tests that measure performance across a wide range of tree sizes:
|
|
33
|
-
|
|
34
|
-
- **Tree sizes tested**: 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000
|
|
35
|
-
- **registerInstance_[size]**: Registration performance with varying numbers of existing items
|
|
36
|
-
- **lookupInstance_[size]**: Lookup performance with different tree sizes
|
|
37
|
-
|
|
38
|
-
These extensive tests help identify potential O(n) performance issues and ensure the registry scales well from small applications to enterprise-scale deployments.
|
|
39
|
-
|
|
40
|
-
## Timing Constraints
|
|
41
|
-
|
|
42
|
-
The following timing constraints are enforced (all values in microseconds):
|
|
43
|
-
|
|
44
|
-
### Basic Operations
|
|
45
|
-
- **createRegistry**: ≤ 5000µs (5ms)
|
|
46
|
-
- **createRegistryHub**: ≤ 5000µs (5ms)
|
|
47
|
-
- **createInstance**: ≤ 10000µs (10ms)
|
|
48
|
-
- **lookupInstance**: ≤ 2000µs (2ms)
|
|
49
|
-
- **registerInstance**: ≤ 5000µs (5ms)
|
|
50
|
-
- **completeWorkflow**: ≤ 25000µs (25ms)
|
|
51
|
-
|
|
52
|
-
### Scaling Operations
|
|
53
|
-
- **registerInstance** (≤100 items): ≤ 5000µs (5ms)
|
|
54
|
-
- **registerInstance** (100-1000 items): ≤ 10000µs (10ms)
|
|
55
|
-
- **registerInstance** (1000-10000 items): ≤ 20000µs (20ms)
|
|
56
|
-
- **registerInstance** (>10000 items): ≤ 50000µs (50ms)
|
|
57
|
-
- **lookupInstance** (≤100 items): ≤ 2000µs (2ms)
|
|
58
|
-
- **lookupInstance** (100-1000 items): ≤ 5000µs (5ms)
|
|
59
|
-
- **lookupInstance** (1000-10000 items): ≤ 10000µs (10ms)
|
|
60
|
-
- **lookupInstance** (>10000 items): ≤ 25000µs (25ms)
|
|
61
|
-
|
|
62
|
-
## Configuration
|
|
63
|
-
|
|
64
|
-
### Adjusting Timing Constraints
|
|
65
|
-
|
|
66
|
-
Edit the `TIMING_CONSTRAINTS` object in `tests/timing.test.ts`:
|
|
67
|
-
|
|
68
|
-
```typescript
|
|
69
|
-
const TIMING_CONSTRAINTS: TimingConstraints = {
|
|
70
|
-
createRegistry: 5000, // 5000µs (5ms) max
|
|
71
|
-
createRegistryHub: 5000, // 5000µs (5ms) max
|
|
72
|
-
createInstance: 10000, // 10000µs (10ms) max
|
|
73
|
-
lookupInstance: 2000, // 2000µs (2ms) max
|
|
74
|
-
registerInstance: 5000, // 5000µs (5ms) max
|
|
75
|
-
};
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### Adjusting Test Iterations
|
|
79
|
-
|
|
80
|
-
Change the `ITERATIONS` constant to adjust the number of test iterations:
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
const ITERATIONS = 1000; // Number of iterations for timing tests
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## Generated Documentation
|
|
87
|
-
|
|
88
|
-
When timing tests run, they automatically generate documentation at `./docs/timing.md`. This file includes:
|
|
89
|
-
|
|
90
|
-
- Performance summary table for basic operations
|
|
91
|
-
- Scaling performance table showing results for different tree sizes
|
|
92
|
-
- **SVG performance graph** visualizing scaling trends (`./docs/scaling-performance.svg`)
|
|
93
|
-
- **SVG performance range chart** showing performance consistency with ±1σ bands (`./docs/timing-range.svg`)
|
|
94
|
-
- Detailed timing results for each operation (in microseconds)
|
|
95
|
-
- Performance analysis and scaling recommendations
|
|
96
|
-
- System information (Node.js version, platform, etc.)
|
|
97
|
-
|
|
98
|
-
### Multi-Round Testing
|
|
99
|
-
|
|
100
|
-
The system runs 100 test rounds (configurable) for smaller tree sizes and reduces rounds for larger sizes to balance thoroughness with test duration:
|
|
101
|
-
|
|
102
|
-
- **≤1000 items**: 100 rounds × 200 iterations = ~20,000 measurements per operation
|
|
103
|
-
- **1000-10000 items**: 50 rounds × 100 iterations = ~5,000 measurements per operation
|
|
104
|
-
- **>10000 items**: 25 rounds × 50 iterations = ~1,250 measurements per operation
|
|
105
|
-
|
|
106
|
-
For performance range visualization, the system calculates mean and standard deviation for each tree size, displaying ±1σ confidence bands that show performance consistency.
|
|
107
|
-
|
|
108
|
-
**Randomized Batching**: Instead of running all iterations sequentially, the system uses randomized batch sizes (10-50 iterations) with brief pauses between batches. This approach simulates real-world usage patterns and prevents artificial performance artifacts from caching, JIT optimization, and memory allocation patterns.
|
|
109
|
-
|
|
110
|
-
This comprehensive approach provides robust results that smooth out system load variations and clearly show performance characteristics and variability.
|
|
111
|
-
|
|
112
|
-
## Best Practices
|
|
113
|
-
|
|
114
|
-
### When to Update Constraints
|
|
115
|
-
|
|
116
|
-
- **After optimization**: If you've improved performance, consider tightening constraints
|
|
117
|
-
- **Hardware changes**: Adjust constraints when changing build/test infrastructure
|
|
118
|
-
- **Performance regressions**: Investigate and fix before loosening constraints
|
|
119
|
-
|
|
120
|
-
### Interpreting Results
|
|
121
|
-
|
|
122
|
-
- **Average Time**: Most important metric for consistent performance
|
|
123
|
-
- **Max Time**: Helps identify performance spikes
|
|
124
|
-
- **Min Time**: Usually very low due to CPU caching effects
|
|
125
|
-
|
|
126
|
-
### Troubleshooting Failed Tests
|
|
127
|
-
|
|
128
|
-
If timing tests fail:
|
|
129
|
-
|
|
130
|
-
1. **Check recent changes**: Review code changes that might affect performance
|
|
131
|
-
2. **System load**: Ensure the system isn't under heavy load during testing
|
|
132
|
-
3. **Multiple runs**: Run tests multiple times to account for system variance
|
|
133
|
-
4. **Profile code**: Use Node.js profiling tools to identify bottlenecks
|
|
134
|
-
|
|
135
|
-
## Integration with CI/CD
|
|
136
|
-
|
|
137
|
-
The timing tests are designed to be run in CI/CD pipelines:
|
|
138
|
-
|
|
139
|
-
- Tests fail if performance thresholds are exceeded
|
|
140
|
-
- Documentation is automatically updated on each run
|
|
141
|
-
- Results can be tracked over time to monitor performance trends
|
|
142
|
-
|
|
143
|
-
## File Structure
|
|
144
|
-
|
|
145
|
-
```
|
|
146
|
-
docs/
|
|
147
|
-
├── timing.md # Generated timing report (auto-updated)
|
|
148
|
-
└── TIMING_README.md # This documentation file
|
|
149
|
-
|
|
150
|
-
tests/
|
|
151
|
-
└── timing.test.ts # Timing test implementation
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Maintenance
|
|
155
|
-
|
|
156
|
-
### Regular Tasks
|
|
157
|
-
|
|
158
|
-
1. **Review thresholds** quarterly to ensure they remain appropriate
|
|
159
|
-
2. **Update documentation** after significant performance improvements
|
|
160
|
-
3. **Monitor trends** in the generated timing reports over releases
|
|
161
|
-
|
|
162
|
-
### Release Process
|
|
163
|
-
|
|
164
|
-
The timing documentation (`docs/timing.md`) should be:
|
|
165
|
-
|
|
166
|
-
1. Generated before each release
|
|
167
|
-
2. Committed to the repository
|
|
168
|
-
3. Published with the package
|
|
169
|
-
|
|
170
|
-
This ensures users can see performance characteristics of each version.
|