{"id":28000412,"url":"https://github.com/xtrayambak/kaleidoscope","last_synced_at":"2025-07-27T19:10:33.739Z","repository":{"id":267790711,"uuid":"902369038","full_name":"xTrayambak/kaleidoscope","owner":"xTrayambak","description":"Fast SIMD accelerated routines for strings in pure Nim","archived":false,"fork":false,"pushed_at":"2025-05-08T13:31:01.000Z","size":63,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-08T23:52:46.213Z","etag":null,"topics":["avx","avx2","high-performance","nim","simd","sse","string","string-matching","x86"],"latest_commit_sha":null,"homepage":"","language":"Nim","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xTrayambak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-12T12:37:44.000Z","updated_at":"2025-05-08T13:31:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"b9a7d098-4f24-4a47-a576-1eaf237b242e","html_url":"https://github.com/xTrayambak/kaleidoscope","commit_stats":null,"previous_names":["xtrayambak/kaleidoscope"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xTrayambak/kaleidoscope","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xTrayambak%2Fkaleidoscope","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xTrayambak%2Fkaleidoscope/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xTrayambak%2Fkaleidoscope/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xTrayambak%2Fkaleidoscope/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xTrayambak","download_url":"https://codeload.github.com/xTrayambak/kaleidoscope/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xTrayambak%2Fkaleidoscope/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267408912,"owners_count":24082526,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["avx","avx2","high-performance","nim","simd","sse","string","string-matching","x86"],"created_at":"2025-05-08T23:52:41.367Z","updated_at":"2025-07-27T19:10:33.688Z","avatar_url":"https://github.com/xTrayambak.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kaleidoscope\nKaleidoscope is a library that provides fast SIMD accelerated routines for strings.\n\nIt aims to implement some of `std/strutils`'s routines in a compatible manner, whilst being either faster than their implementation or equal in terms of performance in the worst case. \\\nKaleidoscope automatically detects what features your CPU has and uses the best algorithm available for it. If it cannot find one, it uses a scalar implementation. \\\nIn order to always force the scalar implementation to be used, compile your program with `--define:kaleidoscopeNoSimd`.\n\nThis library is written in pure Nim.\n\n# Performance\nYou can run `tests/test1.nim` on your system to find out. On my laptop, with a Ryzen 5 5500H, this is the result:\n```\n$ nim c -d:release -r tests/test1.nim\n   min time    avg time  std dv   runs name\n   0.006 ms    0.006 ms  ±0.000  x1000 find needle in haystack (std/strutils)\n   0.000 ms    0.000 ms  ±0.000  x1000 find needle in haystack (kaleidoscope)\n```\n\nAlthough, keep in mind that whilst Kaleidoscope outperforms the standard library in release mode, it does not in debug builds with array-checks switched on as it bottlenecks the SIMD operations by a considerable margin.\n```\n$ nim c -r tests/test1.nim\n   min time    avg time  std dv   runs name\n   0.006 ms    0.006 ms  ±0.000  x1000 find needle in haystack (std/strutils)\n   0.032 ms    0.033 ms  ±0.002  x1000 find needle in haystack (kaleidoscope)\n```\n\n# Supported CPUs\n- x86 CPUs with AVX2 or SSE4.1\n\nWant to add support for another architecture? Send in a PR!\n\n# Credits\nThis project would have not been possible without the following articles and/or gists.\n- [easyaspi314's SSE4.1-based case-conversion code](https://gist.github.com/easyaspi314/9d31e5c0f9cead66aba2ede248b74d64)\n- [Wojciech Muła's article \"SIMD-friendly algorithms for substring searching\"](http://0x80.pl/articles/simd-strfind.html)\n\n# Security\nThis project can be fuzzed via LLVM's fuzzing infrastructure alongside AddressSanitizer. That's already helped me in squashing a few bugs here. \\\nThere's still some issues left, and as such, I would not recommend you to use this library in production as of right now.\n\n# Real World Usage\nThis project has been used in the [Bali JavaScript engine](https://github.com/ferus-web/bali) for implementing the following methods:\n- `String.prototype.indexOf` (string-find)\n- `String.prototype.toLowerCase` (case-conversion)\n- `String.prototype.toUpperCase` (case-conversion)\n\nIt blows other JavaScript engines like SpiderMonkey and Boa's implementations out of the water in [this benchmark](https://github.com/ferus-web/bali/blob/master/benchmarks/string-find.sh), but does get outperformed by QuickJS (although that's probably due to other engine details, not Kaleidoscope itself)\n\n# Installation\n```command\n$ nimble add kaleidoscope\n```\n\n# Usage\nKaleidoscope works on both the C and C++ backends.\n\n```nim\nimport pkg/kaleidoscope\n\nlet haystack = \"Hello world!\"\nlet needle = \"world\"\n\nlet pos = haystack.find(needle)\n```\n\n# Roadmap\n- Add ARM support (I do not own an ARM CPU apart from my phone.)\n- Add RISC-V support (Same as above, I do not own a RISC-V machine)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtrayambak%2Fkaleidoscope","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxtrayambak%2Fkaleidoscope","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtrayambak%2Fkaleidoscope/lists"}