-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: lower the default allocation for bignums #4102
Merged
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f1f31ad
perf: lower the default allocation for bignums
ggreif ed38582
add a mini-benchmark
ggreif 5878157
pimp up the test
ggreif 899488a
cleanup
ggreif 6ea6552
add debugging code
ggreif 50420e0
accept
ggreif 7e2ce6c
Quick fix for BigInt shortening
luc-blaeser aad73ab
accept
ggreif 7eac6c6
Merge branch 'master' into gabor/bignum-space
ggreif 3b0eb10
revert RTS code changes for now
ggreif 872d553
accept
ggreif 5e1d947
accept optimised
ggreif ebea3e9
Update Changelog.md
ggreif d61ddee
update heap differences
ggreif File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -921,6 +921,7 @@ pub(crate) unsafe fn block_size(address: usize) -> Words<u32> { | |
|
||
TAG_BIGINT => { | ||
let bigint = address as *mut BigInt; | ||
(*bigint).mp_int.alloc = (*bigint).mp_int.used; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stats are in https://github.com/dfinity/motoko/pull/4102/files/e15afc367f58f61db4756f6f41e513890d7c8163#r1253257503 and also past commits... |
||
size_of::<BigInt>() + bigint.len().to_words() | ||
} | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//MOC-FLAG --force-gc | ||
import { Array_tabulate; performanceCounter; rts_heap_size; debugPrint } = "mo:⛔"; | ||
|
||
actor Bignum { | ||
var steps = 0; | ||
var nat = 3; | ||
|
||
func counters() : (Int, Nat64) = (rts_heap_size(), performanceCounter(0)); | ||
|
||
let arr : [var Nat] = [var 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; | ||
var arr1 : ?[Nat] = null; | ||
|
||
public func go() : async () { | ||
let (size0, perf0) = counters(); | ||
|
||
while (steps < 12) { | ||
nat := nat * 5 * nat; | ||
arr[steps] := nat; | ||
steps := steps + 1 | ||
}; | ||
|
||
let (size1, perf1) = counters(); | ||
|
||
debugPrint(debug_show {size = size1 - size0; cycles = perf1 - perf0 }); | ||
}; | ||
|
||
public func candid() : async () { | ||
let (size0, perf0) = counters(); | ||
let ser = to_candid(Array_tabulate<Nat>(arr.size(), func i = arr[i])); | ||
arr1 := from_candid(ser); | ||
let (size1, perf1) = counters(); | ||
debugPrint(debug_show {size = size1 - size0; cycles = perf1 - perf0 }); | ||
} | ||
} | ||
|
||
//CALL ingress go 0x4449444C0000 | ||
//CALL ingress candid 0x4449444C0000 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101 | ||
ingress Completed: Reply: 0x4449444c0000 | ||
debug.print: {cycles = 2_494_559; size = +59_652} | ||
ingress Completed: Reply: 0x4449444c0000 | ||
debug.print: {cycles = 103_059_688; size = +1_817_872} | ||
ingress Completed: Reply: 0x4449444c0000 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101 | ||
ingress Completed: Reply: 0x4449444c0000 | ||
debug.print: (50_227, +91_377_860, 1_434_593_325) | ||
debug.print: (50_070, +102_586_000, 1_506_674_763) | ||
debug.print: (50_227, +30_261_252, 676_332_164) | ||
debug.print: (50_070, +32_992_212, 730_267_012) | ||
ingress Completed: Reply: 0x4449444c0000 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem with this might be that this changes the value of the bignum (mantissa).