{"id":"akari-yn/corefinder","name":"corefinder","scope":"akari-yn","platform":"roblox","description":"Estimates the number of parallel execution cores available to Roblox Actors at runtime.","version":"1.0.0","latest":"1.0.0","versions":["0.1.2","0.1.3","0.1.4","0.2.0","1.0.0","0.1.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":false,"dependencies":{},"integrity":"b42323b2578faffe45dbc805c7f27c7bb8bd06035401f105ecc79da90d28c389","likes":0,"downloads":0,"install":"forest install akari-yn/corefinder","url":"https://forest.dev/p/roblox/akari-yn/corefinder","files":"https://api.forest.dev/ai/package/roblox/akari-yn/corefinder/files","readme":"# CoreFinder\r\n\r\nEstimates the number of parallel execution cores available to Roblox Actors at runtime.\r\n\r\n## Why\r\n\r\nKnowing how many CPU cores are available lets you split work into the right number of parallel tasks. Creating more tasks than cores forces some to wait; creating fewer leaves cores idle. The best performance comes when the number of tasks matches the number of cores.\r\n\r\n### Example\r\n\r\nConsider a task that takes **10 seconds** on a machine with **3 available cores**:\r\n\r\n| Strategy | Subtasks | Time per subtask | Execution | Total time | Issue |\r\n|---|---|---|---|---|---|\r\n| Over‑split (4 tasks) | 4 | 2.5 s | 3 run, then 1 waits | **5 s** | One task queued |\r\n| Under‑split (2 tasks) | 2 | 5 s | 2 run in parallel | **5 s** | One core idle |\r\n| **Matched (3 tasks)** | 3 | ~3.3 s | All 3 run in parallel | **~3.3 s** | None |\r\n\r\nSplitting into exactly **3** subtasks — matching the available cores — completes the work in about **3.3 s** instead of 5 s (ignoring overhead).\r\n\r\n## How It Works\r\n\r\nCoreFinder dispatches parallel Actor workers that deliberately occupy execution cores for a fixed **spin window**. Each worker atomically increments a `SharedTable` counter, then busy-spins for the duration of the window to hold its core. The number of workers that successfully run within the same window reflects how many workers executed concurrently.\r\n\r\nThe search space starts small and **doubles exponentially** until a stable count is found (i.e. fewer actors respond than were dispatched) or a maximum pool size is reached, indicating that available parallelism has been saturated.\r\n\r\n## Installation\r\n\r\n### Wally\r\n\r\n```toml\r\n[dependencies]\r\nCoreFinder = \"akari_yn/corefinder@0.1.0\"\r\n```\r\n\r\n### Manual\r\n\r\nDrop the `CoreFinder` folder into your project so it is accessible via `require()`. The module is self-contained — no external dependencies are needed.\r\n\r\nThe folder structure should look like:\r\n\r\n```\r\nCoreFinder/\r\n├── init.luau              -- Module source & worker logic\r\n├── Requirer.client.luau   -- Requires init.luau on the client so the module\r\n│                          -- can clone itself to create worker Actors\r\n└── Requirer.server.luau   -- Requires init.luau on the server so the module\r\n                           -- can clone itself to create worker Actors\r\n```\r\n\r\n## Usage\r\n\r\n```luau\r\nlocal GetCoreCount = require(path.to.CoreFinder)\r\n\r\nlocal cores = GetCoreCount()       -- uses default 0.1s spin window\r\nprint(\"Detected\", cores, \"core(s)\")\r\n\r\n-- or with a custom spin window for more accuracy\r\nlocal cores = GetCoreCount(0.5)\r\n```\r\n\r\n### Parameters\r\n\r\n| Parameter | Type | Default | Description |\r\n|---|---|---|---|\r\n| `spinWindowDuration` | `number?` | `0.1` | Duration of each spin window in seconds. |\r\n\r\n### Returns\r\n\r\n`number` — Estimated number of parallel execution cores (lower bound).\r\n\r\n## Tips\r\n\r\n- **Longer spin windows** improve accuracy when other scripts may temporarily occupy execution cores (e.g. during startup/shutdown) at the cost of higher detection latency.\r\n- Results represent a **lower bound** on available parallelism and may be reduced by system load or engine limits.\r\n- You can run the function **multiple times** and take the maximum for a more reliable estimate.\r\n\r\n## Default Search Sizes\r\n\r\n| Context | Initial Search Size |\r\n|---|---|\r\n| Studio | 17 (16 + 1 buffer) |\r\n| Server | 4 (3 + 1 buffer) |\r\n| Client | 3 (2 + 1 buffer) |\r\n\r\nThe search pool caps at **1024** actors to prevent runaway allocation.\r\n\r\n## License\r\n\r\nSee [LICENSE.md](LICENSE.md).\r\n","readmeBorrowedFrom":{"version":"0.1.2","source":"wally"},"readmeTruncated":false}