Commit Graph

445 Commits

Author SHA1 Message Date
mergify[bot] 248e0c755a
v2.1: program-runtime: double program cache size (backport of #3481) (#3492)
program-runtime: double program cache size (#3481)

The cache is currently getting thrashed and programs are getting
reloaded pretty much at every single slot. Double the cache size, which
makes reloading happen only due to random eviction sometimes picking a
popular entry.

The JIT code size with the new cache size is about 800MB.

This change reduces jit time 15x.

(cherry picked from commit fb4adda5a8a59d7eafe942157260c023b962925a)

Co-authored-by: Alessandro Decina <alessandro.d@gmail.com>
2024-11-08 12:21:58 +07:00
Kevin Heavey 2ea7fd7ef7
Add const pubkey support and make declare_id a declarative macro (#2348)
* make declare_id a declarative macro

* remove old comment

* deprecate program_declare_id

* deprecate pubkey macro

* put deprecation on the re-export of the pubkey macro

* replace pubkey! with from_str_const in this repo

* fmt

* remove unused import

* Revert "remove unused rustc_version dep from wen-restart (wrong branch)"

This reverts commit 60dbddd03ab3330fc3d86d36ed77ad2babf0afc6.

* avoid wen-restart changes again

* fmt

* fix deprecation text

* make declare_deprecated_id a declarative macro

* put back the deprecation on the re-export of the pubkey macro

* fmt

* don't deprecate the pubkey macro, but make it a declarative macro

* update deprecation note

* re-export the new pubkey macro in solana-sdk (with deprecation) instead of the old one
2024-10-14 15:03:47 +02:00
Kevin Heavey 6082e8434d
Remove frozen-abi build script (#2911)
* replace cfg(RUSTC_WITH_SPECIALIZATION) with cfg(feature = "frozen-abi")

* remove the build scripts for the two frozen-abi crates

* remove all rustc_version deps

* remove a rustc_version dep that I missed

* fix duplicate lines in Cargo.toml files

* remove build.rs from instruction crate

* remove rustc_version from instruction crate

* remove no-longer-needed check-cfg entries

* update lock file after rebase
2024-09-17 06:08:48 +00:00
Kevin Heavey 8116c10021
Extract feature-set crate (#2172)
* extract feature-set crate

* update feature_set dependents

* re-export with deprecation notice

* fix path after rebase

* fmt

* fmt after rebase

* fixes after rebase

* unused import

* fix import

* unused import

* post-rebase fixes

* fix path

* missing frozen-abi support

* update lock file

* use workspace lints

* fix paths

* fix import

* remove unused import

* remove unused deps

* consolidate imports

* add back dep (not unused after all)
2024-09-10 19:27:20 +02:00
Alexander Meißner f6b77526f1
Adjustments of loader-v4 (part 2) (#2750)
* Splits transfer authority and finalize into two instructions.

* Adds next-version-forwarding to finalization.

* Makes loader-v4 a program runtime v1 loader.
2024-08-29 15:46:29 +02:00
Justin Starry 3bf82c9c9e
feat: move precompile verification to SVM (#2441) 2024-08-27 22:11:25 +08:00
Lucas Ste 106d4cf399
Remove `slot_epoch` from SVM (#2720) 2024-08-23 17:47:50 -03:00
Yihau Chen d8e95ac15f
bump rust to 1.80.1 / 2024-08-08 (#2487)
* bump rust to 1.80

* bump nightly version to 2024-07-21

* bump rust stable to 1.80.1, nightly to 2024-08-08

* clippy: macro_metavars_in_unsafe

* fix unexpected tag

* run anchor downstream test with their master

* add no-entrypoint into workspace level lint

* use correct llvm path for coverage test
2024-08-16 11:55:08 +08:00
Kevin Heavey 77ea09a74f
Only run frozen-abi build script when needed (#2443)
* add cfg(feature = "frozen-abi") to build.rs

* only depend on rustc_version when frozen-abi feature is activated

* remove extraneous dirs that snuck in from another branch

* update perf/build.rs as it's different from the standard build script

* use symlink for svm/build.rs

* remove unused build dep rustc_version from wen-restart

* fmt Cargo.toml
2024-08-08 16:18:12 +00:00
Jonathan Bakebwa 169eeec4a3
refactor: Optimize `instruction_accounts` creation in `invoke_context` (#2475)
refactor: optimize instruction_accounts creation in invoke_context
2024-08-07 19:47:14 -06:00
Tao Zhu c7192d37a6
refactor: move process_compute_budget_instructions to reduce dependency (#2392)
refactor: move process_compute_budget_instructions from solana_compute_budget to solana_runtime_transaction, to break circular dependencies. Issue #2169
2024-08-01 17:54:03 -05:00
Lucas Ste 98ded995ce
Add shuttle tests to SVM (#2293) 2024-07-30 20:02:08 -03:00
Alexander Meißner 25b2bbef20
Cleanup - Remove loader from `program_indices` for top-level instructions (#2244)
* Removes loader from program_indices of top-level instructions.

* Removes unused then-Some-branch of `if let`.

* Adjusts tests.
2024-07-23 17:52:35 +02:00
Kevin Heavey 9fd061efcd
add set_sysvar_for_tests to SysvarCache (#1852)
* make SysvarCache fields pub

* add set_sysvar_for_tests to SysvarCache

* make the SysvarCache fields private again

* shorter .expect messages
2024-07-17 20:00:03 +00:00
Kevin Heavey 78ae6c7df9
Extract timings crate (#2026)
* extract solana-timings crate

* update timings dependents

* remove now-unused deps

* fmt
2024-07-11 22:16:05 +00:00
Andrei Silviu Dragnea d441c0f577
Fix BankForks::new_rw_arc memory leak (#1893) 2024-07-09 13:30:18 -07:00
Kevin Heavey ddee03e60d
Extract log collector crate (#2025)
* extract log-collector crate

* update log-collector dependents

* cargo sort

* fmt
2024-07-09 11:32:57 +08:00
Tao Zhu f8630a3522
Refactor cost tracking (#1954)
* Refactor and additional metrics for cost tracking (#1888)

* Refactor and add metrics:
- Combine remove_* and update_* functions to reduce locking on cost-tracker and iteration.
- Add method to calculate executed transaction cost by directly using actual execution cost and loaded accounts size;
- Wireup histogram to report loaded accounts size;
- Report time of block limits checking;
- Move account counters from ExecuteDetailsTimings to ExecuteAccountsDetails;

* Move committed transactions adjustment into its own function

* remove histogram for loaded accounts size due to performance impact
2024-07-02 15:49:22 -05:00
Tao Zhu d5a84daebd
Revert "Refactor and additional metrics for cost tracking (#1888)" (#1936)
This reverts commit c3fadacf69.
2024-07-01 12:17:38 -05:00
Tao Zhu c3fadacf69
Refactor and additional metrics for cost tracking (#1888)
* Refactor and add metrics:
- Combine remove_* and update_* functions to reduce locking on cost-tracker and iteration.
- Add method to calculate executed transaction cost by directly using actual execution cost and loaded accounts size;
- Wireup histogram to report loaded accounts size;
- Report time of block limits checking;
- Move account counters from ExecuteDetailsTimings to ExecuteAccountsDetails;

* Move committed transactions adjustment into its own function
2024-06-27 21:41:59 +00:00
Justin Starry 0d1ad0dc1d
Reuse compute budget processing (#1700)
* refactor: reuse compute budget limits

* fix tests
2024-06-20 19:22:19 +00:00
Alessandro Decina 2107adcf35
bpf_loader: use an explicit thread-local pool for stack and heap memory (#1370)
* Rename ComputeBudget::max_invoke_stack_height to max_instruction_stack_depth

The new name is consistent with the existing
ComputeBudget::max_instruction_trace_length.

Also expose compute_budget:MAX_INSTRUCTION_DEPTH.

* bpf_loader: use an explicit thread-local pool for stack and heap memory

Use a fixed thread-local pool to hold stack and heap memory. This
mitigates the long standing issue of jemalloc causing TLB shootdowns to
serve such frequent large allocations.

Because we need 1 stack and 1 heap region per instruction, and the
current max instruction nesting is hardcoded to 5, the pre-allocated
size is (MAX_STACK + MAX_HEAP) * 5 * NUM_THREADS. With the current
limits that's about 2.5MB per thread. Note that this is memory that
would eventually get allocated anyway, we're just pre-allocating it now.

* programs/sbf: add test for stack/heap zeroing

Add TEST_STACK_HEAP_ZEROED which tests that stack and heap regions are
zeroed across reuse from the memory pool.
2024-06-20 08:57:11 +07:00
Ryo Onodera 3e53b644a8
Adjust replay-related metrics for unified scheduler (#1741)
* Adjust replay-related metrics for unified schduler

* Fix grammar

* Don't compute slowest for unified scheduler

* Rename to is_unified_scheduler_enabled

* Hoist uses to top of file

* Conditionally disable replay-slot-end-to-end-stats

* Remove the misleading fairly balanced text
2024-06-20 09:12:04 +09:00
Lucas Ste ebd063eb79
Add Shuttle multithreading test infrastructure (#1634) 2024-06-17 19:24:43 -03:00
Joe C 3af8f0cfdb
Program Runtime: Unify transaction batch program caches (#1399)
* local program cache: add `modified_entries` field

* use `modified_entries` for modified program cache

* invoke context: make `program_cache_for_tx_batch` mutable

* invoke context: unify local program cache instances

* remove `find_program_in_cache` alias
2024-06-17 17:08:13 -05:00
Joe C 5148dcccf7
SVM: change modified programs result to hash map (#1391)
* SVM: change modified programs result to hash map

* take entries
2024-06-12 22:54:29 +00:00
Justin Starry e4b0055e52
Validate transaction fee payer earlier (#1529) 2024-06-11 07:49:11 -07:00
Joe C b1508010c0
Syscall: `GetEpochStake` (#1152)
* SVM: add `get_vote_accounts` callback

* program-runtime: invoke context: add `vote_accounts`

* sdk: add feature gate for sol-get-epoch-stake

* syscall: get-epoch-stake

* syscall: get-epoch-stake: tests

* drop `get_compute_meter`

* refactor for total stake

* refactor API for total stake
2024-06-11 09:28:31 -05:00
Joe C 0bf34e5ca1
Compute Budget: add `frozen-abi` feature (#1606)
compute budget: add `frozen-abi` feature
2024-06-05 09:20:50 -05:00
Pankaj Garg 9830fb6761
SVM: remove usage of program cache from load_program_with_pubkey() (#1582)
* SVM: remove usage of program cache from Bank::load_program()

* return value instead of reference from get_environments_for_epoch()
2024-06-04 14:44:00 -07:00
Alexander Meißner e43047452a
Metrics - Adds `ProgramCacheStats::water_level` (#1556)
Adds ProgramCacheStats::water_level
2024-06-04 22:53:44 +02:00
Joe C 62eb4cc068
Add Compute Budget Crate (#1121) 2024-06-01 01:38:19 -05:00
Alexander Meißner 6455a2a249
Fix - `ExecuteDetailsTimings::execute_us` (#1499)
Explicitly stops and restarts the execution timer during CPI
2024-05-31 10:25:06 +02:00
Joe C 1c0bd2d6df
Invoke Context: Dedupe compute budgets (#1469)
invoke context: dedupe compute budgets
2024-05-23 14:22:07 +00:00
Kevin Heavey cadba689cb
Make solana-frozen-abi optional in all remaining crates (#1278)
* put most AbiExample derivations behind a cfg_attr

* feature gate all `extern crate solana_frozen_abi_macro;`

* use cfg_attr wherever we were deriving both AbiExample and AbiEnumVisitor

* fix cases where AbiEnumVisitor was still being derived unconditionally

* fix a case where AbiExample was derived unconditionally

* fix more cases where both AbiEnumVisitor and AbiExample were derived unconditionally

* two more cases where AbiExample and AbiEnumVisitor were unconditionally derived

* fix remaining unconditional derivations of AbiEnumVisitor

* fix cases where AbiExample is the first thing derived

* fix most remaining unconditional derivations of AbiExample

* move all `frozen_abi(digest =` behind cfg_attr

* replace incorrect cfg with cfg_attr

* fix one more unconditionally derived AbiExample

* feature gate AbiExample impls

* add frozen-abi feature to required Cargo.toml files

* make frozen-abi features activate recursively

* fmt

* add missing feature gating

* fix accidentally changed digest

* activate frozen-abi in relevant test scripts

* don't activate solana-program's frozen-abi in sdk dev-dependencies

* update to handle AbiExample derivation on new AppendVecFileBacking enum

* revert toml formatting

* remove unused frozen-abi entries from address-lookup-table Cargo.toml

* remove toml references to solana-address-lookup-table-program/frozen-abi

* update lock file

* remove no-longer-used generic param
2024-05-17 14:42:58 +02:00
Joe C 664bf100b5
program-runtime: invoke context: rename `programs_loaded_for_tx` to `program_cache_for_tx_batch` (#1390)
program-runtime: invoke context: rename `programs_loaded_for_tx`
2024-05-16 19:08:01 -05:00
hana d8e9da5b5d
implement SyscallGetSysvar (#1307)
generic mechanism to fetch arbitrary slices of account data for a specially selected list of sysvars
2024-05-16 15:08:15 -07:00
Joe C 10e95fe656
SVM: Hoist program cache recompilation up from Bank (#1077)
* SVM: hoist program cache recompilation up from bank

* program cache: rename `recompilation` to `cache preparation`
2024-05-16 20:01:04 +00:00
hana e3b55cf5ce
Rework SysvarCache implementation (#560)
program-runtime: modify sysvar cache impl

in prep for sol_sysvar_get, rework how SysvarCache stores data internally
we store account data directly, except also storing StakeHistory and SlotHashes as objects
these object representations can be removed after native programs are converted to bpf
2024-05-13 08:41:11 -07:00
Alexander Meißner 9c3c252482
Feature - ProgramCache index implementation switch (#1269)
* Removes direct usage of ProgramCache::entries in get_entries_to_load().

* Adds enum to switch between index implementations.

* Inserts match self.index where ever necessary.
2024-05-11 01:16:55 +02:00
Alexander Meißner 979f619077
Fix - Reloading of unload entries after finishing the recompilation phase (#1199)
* Adds reproducer to test_feature_activation_loaded_programs_epoch_transition.

* Differentiate entries by environment instead of adjusting the effective slot.

* Fixes tests of assign_program().

* Fixes env order in test_feature_activation_loaded_programs_recompilation_phase().

* Turns test_load_program_effective_slot() into test_load_program_environment().

* Adds comments inside ProgramCache::assign_program().
2024-05-09 22:15:02 +02:00
Yihau Chen f050705f98
clippy: unnecessary_get_then_check (#1242) 2024-05-09 00:17:18 +08:00
Alessandro Decina 10e5086343
program cache: reduce contention (#1192)
* program cache: reduce contention

Before this change we used to take the write lock to extract(). This
means that even in the ideal case (all programs are already cached),
the cache was contended by all batches and all operations were
serialized.

With this change we now take the write lock only when we store a new
entry in the cache, and take the read lock to extract(). This means
that in the common case where most/all programs are cached, there is no
contention and all batches progress in parallel.

This improves node replay perf by 20-25% on current mnb traffic.

* ProgramCache: remove SecondLevel structure
2024-05-06 19:26:55 +02:00
Alexander Meißner cf65d2db5e
Refactor - ProgramCache tests (#1047)
* Adds get_entries_to_load().

* Differentiates account not found and unloaded in match_missing().

* Orders assert_eq!(match_missing(), false) in front of cache.extract().

* Makes cargo clippy happy.

* Adds test_extract_nonexistent().
2024-05-03 15:32:59 +02:00
Alexander Meißner 57f92b75c7
Refactor - Reduces direct usage of `ProgramCache::entries` in tests. (#1147)
Reduces direct usage of cache.entries in tests.
2024-05-03 09:39:22 +02:00
Joe C 34b76ac580
Program-Runtime: Add `EnvironmentConfig` to `InvokeContext` (#1059)
* program-runtime: add `EnvironmentConfig` to `InvokeContext`

* move `blockhash` to `EnvironmentConfig`

* move `lamports_per_signature` to `EnvironmentConfig`

* move `feature_set` to `EnvironmentConfig`

* move `sysvar_cache` to `EnvironmentConfig`

* add `get_feature_set` getter
2024-05-01 15:22:43 -05:00
Kevin Heavey 075c79039a
make the LogCollector fields public (#1075) 2024-04-27 07:38:53 +00:00
Ryo Onodera 90bea332b2
Reduce ProgramCache write lock contention (#1037)
* Reduce ProgramCache write-lock contention

* Also consider programs modified by tx

* Memoize program cache write lock
2024-04-27 14:38:11 +09:00
Alexander Meißner 878869b212
Adds comment explaining the possible `ProgramCacheEntryType` transitions. (#908)
Adds comment explaining the possible ProgramCacheEntryType transitions.
2024-04-25 16:17:15 +02:00
Alexander Meißner e43338f3d6
Refactor - Rename `LoadedProgram` to `ProgramCacheEntry` (#880)
LoadedProgramOwner => ProgramCacheEntryOwner.
LoadedProgramType => ProgramCacheEntryType.
LoadedProgram => ProgramCacheEntry.
LoadedProgramStats => ProgramCacheStats.
LoadedProgramMatchCriteria => ProgramCacheMatchCriteria.
LoadedProgramsForTxBatch => ProgramCacheForTxBatch.
2024-04-18 21:38:08 +02:00