Skip to content

Conversation

@hawkfish
Copy link
Contributor

Replace the use of rand/srand with pcg32_fast in the pool. This also seems to improve performance by about 15%.

fixes: duckdblabs/duckdb-internal#766

Replace the use of rand/srand with pcg32_fast in the pool.
This also seems to improve performance by about 15%.

fixes: duckdblabs/duckdb-internal#766
@hawkfish
Copy link
Contributor Author

Benchmark improvements:

image

@carlopi
Copy link
Contributor

carlopi commented Nov 22, 2023

More curiosity that anything, does it change something doing:

_nodeRefs.push_back(this, _nodeRefs.height() ? 0 : 1);
uint32_t random_number = _pool.prng();
while (random_number % 2) {
	_nodeRefs.push_back(this, _nodeRefs.height() ? 0 : 1);
        random_number /= 2;
}

This moves from expected 2 invocations of random generator per iteration to exactly 1 (assuming than depth > 32 are not relevant).

@hawkfish
Copy link
Contributor Author

It doesn't appear to have any noticeable effect.

@Mytherin Mytherin merged commit 95fb6b3 into duckdb:main Nov 23, 2023
@Mytherin
Copy link
Collaborator

Thanks!

@hawkfish hawkfish deleted the skiplist-rand branch November 27, 2023 15:44
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Dec 14, 2023
Merge pull request duckdb/duckdb#9772 from hawkfish/skiplist-rand
Merge pull request duckdb/duckdb#9767 from samansmink/fix-vcpkg-patching-on-windows
Merge pull request duckdb/duckdb#9757 from Tmonster/712-unicode-bugs
Merge pull request duckdb/duckdb#9758 from samansmink/fix-issue-9727
Merge pull request duckdb/duckdb#9759 from samansmink/update-vcpkg-2023.10.19
Merge pull request duckdb/duckdb#9761 from samansmink/add-nightly-deploy-script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants