This repository has been archived by the owner on Feb 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trie: don't copy when we are the exclusive owner of the trie
Currently, to make the trie copy perform well, we only copy the trie's node on write. However, there is no tracking on whether the trie is copied or not, so we always perform copy-on-write even though we are the only owner of the trie. This commit adds a shared bool to trie, this is set when trie copy is performed. When the trie is not shared, it is safe to do all the modification in-place without the need of creating a new copy. > go test -test.v -test.run=^$ -test.bench=BenchmarkUpdate │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ UpdateBE-8 1247.0n ± 36% 378.4n ± 34% -69.66% (p=0.000 n=10) UpdateLE-8 1675.5n ± 1% 430.8n ± 31% -74.29% (p=0.000 n=10) geomean 1.445µ 403.7n -72.07% │ old.txt │ new.txt │ │ B/op │ B/op vs base │ UpdateBE-8 1796.0 ± 0% 226.0 ± 0% -87.42% (p=0.000 n=10) UpdateLE-8 1848.0 ± 0% 228.5 ± 1% -87.64% (p=0.000 n=10) geomean 1.779Ki 227.2 -87.53% │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ UpdateBE-8 9.000 ± 0% 4.000 ± 0% -55.56% (p=0.000 n=10) UpdateLE-8 9.000 ± 0% 4.000 ± 0% -55.56% (p=0.000 n=10) geomean 9.000 4.000 -55.56%
- Loading branch information
Showing
2 changed files
with
79 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters