-
Notifications
You must be signed in to change notification settings - Fork 84
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
dev: optimized bitshifts by using a lookup table for powers of two #984
dev: optimized bitshifts by using a lookup table for powers of two #984
Conversation
bc92946
to
55866c1
Compare
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.
Great!
For curiosity, if you're interested, you can do some profiling to see how many steps are saved when doing bitshifts. The biggest difference should be when shifting 255 bits as it saves a lot of steps by skipping the expensive exponenciation
https://foundry-rs.github.io/starknet-foundry/snforge-advanced-features/profiling.html
edit: actually, tests don't pass because POW_2
only gives powers of two up to 128. You could introduce a new POW_2_256
variable with powers of two defined up to 2**255
The easiest way would be to use python to generate cairo code, like so:
|
Thank you for the review, I'll add a new constant as instructed and try profiling as well! |
55866c1
to
ec4b853
Compare
ec4b853
to
f8310b9
Compare
f8310b9
to
9558dd7
Compare
* add validate_eth_tx test * polish: fmt + docstrings
* First batch of replacements * Second batch of replacements * Clean commented code * scarb fmt * Apply code review recommendations
* ceil to bytes32 * overflow and nits
* load word to bytes * unwrap and nits
* implement eth_get_balance * add missing files * made requested changes * fmt --------- Co-authored-by: enitrat <msaug@protonmail.com>
* dev: use native in ci * remove outdated gas reports * fix fmt * fix runtime location * avoid clearing the ssj checkout * use correct working dir * update stack size when running rust ef-tests * update workflows * simplify workflows by avoiding re-building runtimes * rework workflow structure
9558dd7
to
e05a888
Compare
* dev: implement compile-time filtering * fmt
e05a888
to
7c374e9
Compare
* Implementation of eth_get_transaction_count function * Refactoring validate nonce in validation.cairo * Changing the deprecated function * Validating nonce without new function * Adding method to interface and test it * fix tests * fmt --------- Co-authored-by: enitrat <msaug@protonmail.com>
* fix: mulmod * fmt
* fix: overflow in message_call_gas * fmt
* fix typos * fix typo * fix typos * fix typo * fix typo
* fix: saturate jumpi index taken on stack * scout: remove print
dev: optimized bitshifts by using a lookup table for powers of two tmp
31b3096
to
8d0aa04
Compare
hi @augustin-v it seems that the changes brought in scope of these PR highlight a memory-management related issue in Cairo Native which crashes our CI runner, thus I will have to keep it open until it is fixed |
Hi @enitrat, understood. Thank you for the update, and please let me know if there's anything I can do to assist with resolving the issue |
8d0aa04
to
189671b
Compare
* fix: conversion of stack values in opcode execution * fix test
* test_kakarot_core_get_starknet_address * ci: downgrade cairo native (kkrt-labs#1008) * dev: use checked math (kkrt-labs#1009) * fix get_starknet_address test --------- Co-authored-by: Mathieu <60658558+enitrat@users.noreply.github.com>
hey @augustin-v i ran some profiling on It's nearly 10x better :) |
@enitrat wow it improved much more than I thought it would, bitshift operations looking good |
189671b
to
96dea68
Compare
Pull Request type
Please check the type of change your PR introduces:
What is the current behavior?
The bit shifting operations in the existing implementation are not optimized, leading to potential inefficiencies.
Resolves: #905
What is the new behavior?
Does this introduce a breaking change?
This change is