mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
ClickHouse® is a real-time analytics DBMS
9276384977
Recently (#32094) test database had been overlapped, and random prefix for database had been increased from 6 to 8. But actually 6 bytes for random prefix should be enough (with existing alphabet (0-9a-z) it is 36**6=2'176'782'336), and the real reason of this overlap is that random generator by default uses shared state [1]: The functions supplied by this module are actually bound methods of a hidden instance of the random.Random class. You can instantiate your own instances of Random to get generators that don’t share state. [1]: https://docs.python.org/3/library/random.html I've played a little bit with random in python, and using default random generator it generates non-unique strings pretty fast, just in a few runs, but using SystemRandom (that uses /dev/urandom) it takes ~1 minute. Test: ```sh $ while /tmp/test.py | LANG=c sort -S5G | LANG=c uniq -d | tee /dev/stderr | wc -l | fgrep -q -x -c 0; do :; done ``` ```python #!/usr/bin/env python3 import multiprocessing import string import random def random_str(length=6): alphabet = string.ascii_lowercase + string.digits return ''.join(random.SystemRandom().choice(alphabet) for _ in range(length)) def worker(_): print(random_str()) with multiprocessing.Pool(processes=2) as pool: pool.map(worker, range(0, int(10e3))) ``` So let's switch to SystemRandom and use 6-byte prefix. |
||
---|---|---|
.github | ||
base | ||
benchmark | ||
cmake | ||
contrib | ||
debian | ||
docker | ||
docs | ||
programs | ||
src | ||
tests | ||
utils | ||
website | ||
.clang-format | ||
.clang-tidy | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.gitmodules | ||
.potato.yml | ||
.pylintrc | ||
.vimrc | ||
.yamllint | ||
AUTHORS | ||
CHANGELOG.md | ||
CMakeLists.txt | ||
CODE_OF_CONDUCT.md | ||
CONTRIBUTING.md | ||
docker-compose.yml | ||
format_sources | ||
LICENSE | ||
PreLoad.cmake | ||
README.md | ||
release | ||
SECURITY.md | ||
uncrustify.cfg |
ClickHouse® is an open-source column-oriented database management system that allows generating analytical data reports in real-time.
Useful Links
- Official website has a quick high-level overview of ClickHouse on the main page.
- Tutorial shows how to set up and query a small ClickHouse cluster.
- Documentation provides more in-depth information.
- YouTube channel has a lot of content about ClickHouse in video format.
- Slack and Telegram allow chatting with ClickHouse users in real-time.
- Blog contains various ClickHouse-related articles, as well as announcements and reports about events.
- Code Browser with syntax highlight and navigation.
- Contacts can help to get your questions answered if there are any.