Avatar for the FuelLabs user
FuelLabs
sway
BlogDocsChangelog

Performance History

Latest Results

Fix swayfmt comment placement after multibyte comments (#7652) Fixes #7651. ## Description This fixes `forc fmt` displacing line comments after earlier inserted comments contain multibyte characters such as `≥`. The formatter compares parser leaf spans and reinserts comments into formatted code. Those spans are byte offsets, but the comment insertion path returned the inserted comment length as a character count. After a multibyte character appeared in an inserted comment, later insertion offsets drifted, causing comments to lose indentation or attach to the previous statement. The comment insertion path now stays byte-indexed throughout, validates insertion points against UTF-8 char boundaries, and uses direct string insertion at the computed byte offset. ## Validation - `cargo test -p swayfmt` - `cargo fmt -p swayfmt -- --check` - Smoke-formatted the pre-workaround `storage_vec.sw` from PR #7649 commit `2a879cd4338a4ec118c4412685f1347f63a11a5d` and confirmed the reported comment blocks remain correctly indented.
master
7 hours ago
update tests
xunilrj/improve-rawptr-write
7 hours ago
Implement chunk-based dynamic storage `StorageVec` (#7649) ## Description This PR implements a chunk-based dynamic storage `StorageVec<V>`: - vec content is stored in consecutive dynamic storage slots each holding at most `CHUNK_MAX_SIZE` bytes of element data. - all slots hold the same maximum number of elements: `CHUNK_MAX_SIZE / size_of::<V>()`. - individual elements are always stored in a single slot; i.e. they never cross slot boundaries. - the first slot contains a `u64` length header followed by up to `CHUNK_MAX_SIZE` bytes of element data. As shown in Performance Comparison, this implementation outperform the current one (where all the elements are stored in a single slot, without the length header) in almost all the operations except: - for small vectors - for bulk operations like `reverse` and growing `resize` ## Future Improvements Additional measurements have shown that: - having all the content in a single slot, but with the length header, performs better than the current implementation (single slot, no length header) on all benchmarks for small vectors. - different chunk sizes in the chunk-based `StorageVec` sizes have different trade-offs for different methods. Being able to choose the `CHUNK_MAX_SIZE` based on an application particular storage usage is benefitial. - bulk operations like `remove`, `fill`, `revert`, etc. might benefit from two different implementations, one that is allocation-heavy and does the operation in memory, vs. one that is more allocation-friendly but requires more storage access. Based on those insights, we plan the following future improvements: - including a `SmallStorageVec<V>` in the `std` which will implement a single slot plus length header storage vec optimized for content up to ~2kb. - implementing a `ChunkedStorageVec<V, const CHUNK_MAX_SIZE>` which will allow devs to specify the size. Standard `StorageVec` will than be just a type alias: `type StorageVec<V> = ChunkedStorageVec<V, 1024>`. To be able to implement this, we first need to the language support for generic type aliases. - additionally, we might consider additionally parameterizing the `ChunkedStorageVec` with different strategies for bulk operations. ## Performance Comparison This is the performance comparison between the current `StorageVec` implementation and the chunk-based one, for the `storage_vec_s8` and `storage_vec_s96` projects. For smaller vectors, having the whole vector in a single slot gives better performance (and justifies having a `SmallStorageVec`). The chunked based `StorageVec` performs better on vectors whose element size is greater than ~2kb. | Bench | Before | After | Difference | Percentage | |:----------------------------------------|---------:|---------:|-----------:|-----------:| | bench_push_n10 | 734 | 998 | -264 | -35.97% | | bench_push_n100 | 784 | 1096 | -312 | -39.80% | | bench_push_n1000 | 1049 | 1104 | -55 | -5.24% | | bench_push_n5000 | 2273 | 1074 | 1199 | 52.75% | | bench_push_n_elems_into_empty_vec_n10 | 7810 | 11074 | -3264 | -41.79% | | bench_push_n_elems_into_empty_vec_n100 | 72513 | 103074 | -30561 | -42.15% | | bench_push_n_elems_into_empty_vec_n1000 | 855685 | 1067659 | -211974 | -24.77% | | bench_push_n_elems_into_empty_vec_n5000 | 7334420 | 5356522 | 1977898 | 26.97% | | bench_pop_n10 | 301 | 379 | -78 | -25.91% | | bench_pop_n100 | 374 | 471 | -97 | -25.94% | | bench_pop_n1000 | 899 | 504 | 395 | 43.94% | | bench_pop_n5000 | 3166 | 480 | 2686 | 84.84% | | bench_get_n10 | 245 | 275 | -30 | -12.24% | | bench_get_n100 | 302 | 330 | -28 | -9.27% | | bench_get_n1000 | 743 | 350 | 393 | 52.89% | | bench_get_n5000 | 2683 | 350 | 2333 | 86.95% | | bench_set_n10 | 253 | 309 | -56 | -22.13% | | bench_set_n100 | 330 | 384 | -54 | -16.36% | | bench_set_n1000 | 843 | 421 | 422 | 50.06% | | bench_set_n5000 | 3037 | 421 | 2616 | 86.14% | | bench_first_n10 | 252 | 266 | -14 | -5.56% | | bench_first_n100 | 304 | 316 | -12 | -3.95% | | bench_first_n1000 | 735 | 324 | 411 | 55.92% | | bench_first_n5000 | 2675 | 325 | 2350 | 87.85% | | bench_last_n10 | 269 | 298 | -29 | -10.78% | | bench_last_n100 | 326 | 353 | -27 | -8.28% | | bench_last_n1000 | 766 | 366 | 400 | 52.22% | | bench_last_n5000 | 2706 | 342 | 2364 | 87.36% | | bench_len_n10 | 44 | 43 | 1 | 2.27% | | bench_len_n100 | 88 | 85 | 3 | 3.41% | | bench_len_n1000 | 316 | 102 | 214 | 67.72% | | bench_len_n5000 | 1286 | 102 | 1184 | 92.07% | | bench_is_empty_n10 | 82 | 81 | 1 | 1.22% | | bench_is_empty_n100 | 96 | 93 | 3 | 3.12% | | bench_is_empty_n1000 | 319 | 105 | 214 | 67.08% | | bench_is_empty_n5000 | 1289 | 105 | 1184 | 91.85% | | bench_swap_n10 | 576 | 655 | -79 | -13.72% | | bench_swap_n100 | 725 | 802 | -77 | -10.62% | | bench_swap_n1000 | 1919 | 818 | 1101 | 57.37% | | bench_swap_n5000 | 7277 | 764 | 6513 | 89.50% | | bench_swap_remove_n10 | 323 | 685 | -362 | -112.07% | | bench_swap_remove_n100 | 366 | 797 | -431 | -117.76% | | bench_swap_remove_n1000 | 886 | 842 | 44 | 4.97% | | bench_swap_remove_n5000 | 3153 | 818 | 2335 | 74.06% | | bench_remove_n10 | 351 | 670 | -319 | -90.88% | | bench_remove_n100 | 374 | 762 | -388 | -103.74% | | bench_remove_n1000 | 903 | 2817 | -1914 | -211.96% | | bench_remove_n5000 | 3250 | 10875 | -7625 | -234.62% | | bench_insert_n10 | 1015 | 1247 | -232 | -22.86% | | bench_insert_n100 | 1118 | 1375 | -257 | -22.99% | | bench_insert_n1000 | 2106 | 3384 | -1278 | -60.68% | | bench_insert_n5000 | 6567 | 11301 | -4734 | -72.09% | | bench_reverse_n10 | 424 | 460 | -36 | -8.49% | | bench_reverse_n100 | 1517 | 1483 | 34 | 2.24% | | bench_reverse_n1000 | 12357 | 334571 | -322214 | -2607.54% | | bench_reverse_n5000 | 60624 | 1679483 | -1618859 | -2670.33% | | bench_fill_n10 | 326 | 1698 | -1372 | -420.86% | | bench_fill_n100 | 1257 | 1748 | -491 | -39.06% | | bench_fill_n1000 | 10549 | 2898 | 7651 | 72.53% | | bench_fill_n5000 | 51846 | 8076 | 43770 | 84.42% | | bench_resize_grow_n10 | 5440 | 7586 | -2146 | -39.45% | | bench_resize_grow_n100 | 51760 | 75387 | -23627 | -45.65% | | bench_resize_grow_n1000 | 514943 | 751303 | -236360 | -45.90% | | bench_resize_grow_n5000 | 2573538 | 3755298 | -1181760 | -45.92% | | bench_resize_shrink_n10 | 310 | 304 | 6 | 1.94% | | bench_resize_shrink_n100 | 349 | 344 | 5 | 1.43% | | bench_resize_shrink_n1000 | 822 | 360 | 462 | 56.20% | | bench_resize_shrink_n5000 | 2925 | 360 | 2565 | 87.69% | | bench_store_vec_n10 | 5232 | 6659 | -1427 | -27.27% | | bench_store_vec_n100 | 50603 | 52030 | -1427 | -2.82% | | bench_store_vec_n1000 | 504235 | 506811 | -2576 | -0.51% | | bench_store_vec_n5000 | 2520489 | 2528277 | -7788 | -0.31% | | bench_load_vec_n10 | 294 | 311 | -17 | -5.78% | | bench_load_vec_n100 | 333 | 348 | -15 | -4.50% | | bench_load_vec_n1000 | 822 | 1006 | -184 | -22.38% | | bench_load_vec_n5000 | 2952 | 3860 | -908 | -30.76% | | bench_iter_n10 | 2681 | 2940 | -259 | -9.66% | | bench_iter_n100 | 27785 | 30382 | -2597 | -9.35% | | bench_iter_n1000 | 494403 | 309437 | 184966 | 37.41% | | bench_iter_n5000 | 7316373 | 1544821 | 5771552 | 78.89% | | bench_clear_n10 | 96 | 96 | 0 | 0.00% | | bench_clear_n100 | 98 | 96 | 2 | 2.04% | | bench_clear_n1000 | 98 | 96 | 2 | 2.04% | | bench_clear_n5000 | 98 | 96 | 2 | 2.04% | | Bench | Before | After | Difference | Percentage | |:----------------------------------------|---------:|---------:|-----------:|-----------:| | bench_push_n10 | 6321 | 7319 | -998 | -15.79% | | bench_push_n100 | 6670 | 7339 | -669 | -10.03% | | bench_push_n1000 | 9965 | 7329 | 2636 | 26.45% | | bench_push_n5000 | 24649 | 7329 | 17320 | 70.27% | | bench_push_n_elems_into_empty_vec_n10 | 63637 | 67051 | -3414 | -5.36% | | bench_push_n_elems_into_empty_vec_n100 | 645943 | 668697 | -22754 | -3.52% | | bench_push_n_elems_into_empty_vec_n1000 | 8104285 | 6685021 | 1419264 | 17.51% | | bench_push_n_elems_into_empty_vec_n5000 | 77228220 | 33424226 | 43803994 | 56.72% | | bench_pop_n10 | 371 | 478 | -107 | -28.84% | | bench_pop_n100 | 1002 | 499 | 503 | 50.20% | | bench_pop_n1000 | 7139 | 514 | 6625 | 92.80% | | bench_pop_n5000 | 34341 | 512 | 33829 | 98.51% | | bench_get_n10 | 309 | 339 | -30 | -9.71% | | bench_get_n100 | 842 | 351 | 491 | 58.31% | | bench_get_n1000 | 6086 | 357 | 5729 | 94.13% | | bench_get_n5000 | 29358 | 357 | 29001 | 98.78% | | bench_set_n10 | 326 | 382 | -56 | -17.18% | | bench_set_n100 | 942 | 408 | 534 | 56.69% | | bench_set_n1000 | 6885 | 428 | 6457 | 93.78% | | bench_set_n5000 | 33205 | 428 | 32777 | 98.71% | | bench_first_n10 | 317 | 331 | -14 | -4.42% | | bench_first_n100 | 844 | 336 | 508 | 60.19% | | bench_first_n1000 | 6077 | 331 | 5746 | 94.55% | | bench_first_n5000 | 29349 | 331 | 29018 | 98.87% | | bench_last_n10 | 334 | 363 | -29 | -8.68% | | bench_last_n100 | 866 | 374 | 492 | 56.81% | | bench_last_n1000 | 6109 | 378 | 5731 | 93.81% | | bench_last_n5000 | 29381 | 379 | 29002 | 98.71% | | bench_len_n10 | 71 | 70 | 1 | 1.41% | | bench_len_n100 | 352 | 90 | 262 | 74.43% | | bench_len_n1000 | 2981 | 100 | 2881 | 96.65% | | bench_len_n5000 | 14617 | 100 | 14517 | 99.32% | | bench_is_empty_n10 | 109 | 108 | 1 | 0.92% | | bench_is_empty_n100 | 360 | 98 | 262 | 72.78% | | bench_is_empty_n1000 | 2984 | 103 | 2881 | 96.55% | | bench_is_empty_n5000 | 14620 | 103 | 14517 | 99.30% | | bench_swap_n10 | 729 | 808 | -79 | -10.84% | | bench_swap_n100 | 2197 | 834 | 1363 | 62.04% | | bench_swap_n1000 | 16652 | 824 | 15828 | 95.05% | | bench_swap_n5000 | 80928 | 824 | 80104 | 98.98% | | bench_swap_remove_n10 | 407 | 858 | -451 | -110.81% | | bench_swap_remove_n100 | 1008 | 850 | 158 | 15.67% | | bench_swap_remove_n1000 | 7140 | 860 | 6280 | 87.96% | | bench_swap_remove_n5000 | 34342 | 860 | 33482 | 97.50% | | bench_remove_n10 | 435 | 842 | -407 | -93.56% | | bench_remove_n100 | 1038 | 2814 | -1776 | -171.10% | | bench_remove_n1000 | 7376 | 25314 | -17938 | -243.19% | | bench_remove_n5000 | 35539 | 125314 | -89775 | -252.61% | | bench_insert_n10 | 6697 | 7115 | -418 | -6.24% | | bench_insert_n100 | 7898 | 9087 | -1189 | -15.05% | | bench_insert_n1000 | 19928 | 31257 | -11329 | -56.85% | | bench_insert_n5000 | 73451 | 129857 | -56406 | -76.79% | | bench_reverse_n10 | 487 | 552 | -65 | -13.35% | | bench_reverse_n100 | 2138 | 33463 | -31325 | -1465.15% | | bench_reverse_n1000 | 18589 | 333143 | -314554 | -1692.15% | | bench_reverse_n5000 | 91792 | 1665143 | -1573351 | -1714.04% | | bench_fill_n10 | 373 | 472 | -99 | -26.54% | | bench_fill_n100 | 1623 | 1923 | -300 | -18.48% | | bench_fill_n1000 | 14125 | 16413 | -2288 | -16.20% | | bench_fill_n5000 | 69692 | 80813 | -11121 | -15.96% | | bench_resize_grow_n10 | 60963 | 63948 | -2985 | -4.90% | | bench_resize_grow_n100 | 606882 | 636240 | -29358 | -4.84% | | bench_resize_grow_n1000 | 6066088 | 6359160 | -293072 | -4.83% | | bench_resize_grow_n5000 | 30329221 | 31794360 | -1465139 | -4.83% | | bench_resize_shrink_n10 | 379 | 376 | 3 | 0.79% | | bench_resize_shrink_n100 | 936 | 366 | 570 | 60.90% | | bench_resize_shrink_n1000 | 6615 | 366 | 6249 | 94.47% | | bench_resize_shrink_n5000 | 31852 | 366 | 31486 | 98.85% | | bench_store_vec_n10 | 60679 | 62108 | -1429 | -2.36% | | bench_store_vec_n100 | 605073 | 607970 | -2897 | -0.48% | | bench_store_vec_n1000 | 6048933 | 6066445 | -17512 | -0.29% | | bench_store_vec_n5000 | 30243981 | 30326445 | -82464 | -0.27% | | bench_load_vec_n10 | 353 | 372 | -19 | -5.38% | | bench_load_vec_n100 | 916 | 1158 | -242 | -26.42% | | bench_load_vec_n1000 | 6677 | 9061 | -2384 | -35.70% | | bench_load_vec_n5000 | 32234 | 44146 | -11912 | -36.95% | | bench_iter_n10 | 3080 | 3339 | -259 | -8.41% | | bench_iter_n100 | 55651 | 31979 | 23672 | 42.54% | | bench_iter_n1000 | 3174070 | 318179 | 2855891 | 89.98% | | bench_iter_n5000 | 74044706 | 1585179 | 72459527 | 97.86% | | bench_clear_n10 | 96 | 96 | 0 | 0.00% | | bench_clear_n100 | 96 | 96 | 0 | 0.00% | | bench_clear_n1000 | 96 | 96 | 0 | 0.00% | | bench_clear_n5000 | 96 | 96 | 0 | 0.00% | ## Checklist - [ ] I have linked to any relevant issues. - [x] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] If my change requires substantial documentation changes, I have [requested support from the DevRel team](https://github.com/FuelLabs/devrel-requests/issues/new/choose) - [x] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [x] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [x] I have requested a review from the relevant team or maintainers.
master
7 hours ago
fix typo
xunilrj/improve-rawptr-write
10 hours ago
update tests
xunilrj/improve-rawptr-write
11 hours ago
fmt and clippy issues
xunilrj/improve-rawptr-write
22 hours ago
update tests
xunilrj/improve-rawptr-write
2 days ago

Latest Branches

CodSpeed Performance Gauge
0%
Improve `raw_ptr::write` (1/n)#7646
7 hours ago
5d5a052
xunilrj/improve-rawptr-write
CodSpeed Performance Gauge
-1%
4 days ago
44836c2
Dnreikronos:typecheck/self_param_missing_error
CodSpeed Performance Gauge
0%
6 days ago
4eff7df
Dnreikronos:fix/large-data-section-ice
© 2026 CodSpeed Technology
Home Terms Privacy Docs