|
| 1 | +# CPU Core Scaling Protection |
| 2 | + |
| 3 | +> BotBrowser constrains Worker thread parallelism to match the profile's `navigator.hardwareConcurrency`, keeping computation scaling consistent with the claimed core count. |
| 4 | +
|
| 5 | +--- |
| 6 | + |
| 7 | +<a id="prerequisites"></a> |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +- **BotBrowser** installed. See [Installation Guide](../../../INSTALLATION.md). |
| 12 | +- **A profile file** (`.enc` for production). |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +<a id="overview"></a> |
| 17 | + |
| 18 | +## Overview |
| 19 | + |
| 20 | +`navigator.hardwareConcurrency` tells JavaScript how many CPU cores are available. Tracking systems can verify this value by measuring actual parallel computation speed. If a profile claims 4 cores but the host has 16, Worker-based benchmarks will complete faster than expected for a 4-core machine. |
| 21 | + |
| 22 | +BotBrowser solves this by constraining Worker threads to match the profile's claimed core count via CPU affinity on Linux and Windows. The computation scaling curve aligns with the reported value. |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +<a id="quick-start"></a> |
| 27 | + |
| 28 | +## Quick Start |
| 29 | + |
| 30 | +```bash |
| 31 | +# Profile defines hardwareConcurrency. Workers are automatically constrained. |
| 32 | +chromium-browser \ |
| 33 | + --bot-profile="/path/to/profile.enc" \ |
| 34 | + --user-data-dir="$(mktemp -d)" |
| 35 | +``` |
| 36 | + |
| 37 | +No extra flags needed. When the profile sets `navigator.hardwareConcurrency`, BotBrowser automatically applies CPU affinity to Worker threads. |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +<a id="how-it-works"></a> |
| 42 | + |
| 43 | +## How It Works |
| 44 | + |
| 45 | +1. **Profile sets the value.** The profile defines `navigator.hardwareConcurrency` (e.g., 4 cores). |
| 46 | + |
| 47 | +2. **Workers are constrained.** When a Worker, SharedWorker, or ServiceWorker is created, BotBrowser pins it to a subset of physical cores matching the claimed count. |
| 48 | + |
| 49 | +3. **Computation scales correctly.** A parallel benchmark using 4 Workers on a "4-core" profile will show the same scaling behavior as a real 4-core machine, even if the host has more cores. |
| 50 | + |
| 51 | +--- |
| 52 | + |
| 53 | +<a id="common-scenarios"></a> |
| 54 | + |
| 55 | +## Common Scenarios |
| 56 | + |
| 57 | +### High-core server running low-core profiles |
| 58 | + |
| 59 | +A 32-core server running a mobile profile (4 cores) will constrain all Workers to 4 physical cores: |
| 60 | + |
| 61 | +```javascript |
| 62 | +const browser = await chromium.launch({ |
| 63 | + executablePath: process.env.BOTBROWSER_EXEC_PATH, |
| 64 | + headless: true, |
| 65 | + args: [ |
| 66 | + "--bot-profile=/path/to/mobile-profile.enc", |
| 67 | + ], |
| 68 | +}); |
| 69 | + |
| 70 | +const page = await browser.newPage(); |
| 71 | +const cores = await page.evaluate(() => navigator.hardwareConcurrency); |
| 72 | +console.log(cores); // 4 (from profile) |
| 73 | +// Worker-based parallel benchmarks will show 4-core scaling behavior |
| 74 | +await browser.close(); |
| 75 | +``` |
| 76 | + |
| 77 | +### Multiple profiles on same host |
| 78 | + |
| 79 | +Each browser instance is constrained independently based on its profile. A 4-core profile and an 8-core profile on the same 32-core server show different computation scaling curves matching their respective claims. |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +<a id="platform-support"></a> |
| 84 | + |
| 85 | +## Platform Support |
| 86 | + |
| 87 | +| Platform | CPU Affinity | Notes | |
| 88 | +|----------|-------------|-------| |
| 89 | +| **Linux** | Supported | Uses CPU affinity to pin Worker threads | |
| 90 | +| **Windows** | Supported | Uses CPU affinity to pin Worker threads | |
| 91 | +| **macOS** | Not supported | macOS does not expose CPU affinity APIs. Workers run on all cores. `navigator.hardwareConcurrency` is still set from the profile, but parallel timing may not match. | |
| 92 | + |
| 93 | +--- |
| 94 | + |
| 95 | +<a id="troubleshooting"></a> |
| 96 | + |
| 97 | +## Troubleshooting / FAQ |
| 98 | + |
| 99 | +| Problem | Solution | |
| 100 | +|---------|----------| |
| 101 | +| `hardwareConcurrency` shows wrong value | Ensure your profile contains the correct core count. The value comes from the profile, not from a CLI flag. | |
| 102 | +| Parallel benchmark still fast on macOS | macOS does not support CPU affinity. Consider running on Linux for full protection. | |
| 103 | +| Workers seem slow | Expected when the profile claims fewer cores than the host. Workers are intentionally constrained. | |
| 104 | + |
| 105 | +--- |
| 106 | + |
| 107 | +<a id="next-steps"></a> |
| 108 | + |
| 109 | +## Next Steps |
| 110 | + |
| 111 | +- [Performance Optimization](../deployment/PERFORMANCE_OPTIMIZATION.md). Tune throughput on multi-core servers. |
| 112 | +- [Navigator Properties](NAVIGATOR_PROPERTIES.md). Other navigator-level fingerprint surfaces. |
| 113 | +- [Stack Depth Protection](STACK_DEPTH.md). Control JavaScript recursive stack depth. |
| 114 | +- [CLI Flags Reference](../../../CLI_FLAGS.md). Complete flag documentation. |
| 115 | + |
| 116 | +--- |
| 117 | + |
| 118 | +**Related documentation:** [Advanced Features: CPU Core Scaling](../../../ADVANCED_FEATURES.md#cpu-core-scaling) | [CLI Flags](../../../CLI_FLAGS.md) |
| 119 | + |
| 120 | +--- |
| 121 | + |
| 122 | +**[Legal Disclaimer & Terms of Use](https://github.com/botswin/BotBrowser/blob/main/DISCLAIMER.md) • [Responsible Use Guidelines](https://github.com/botswin/BotBrowser/blob/main/RESPONSIBLE_USE.md)**. BotBrowser is for authorized fingerprint protection and privacy research only. |
0 commit comments