iotaledger / entangled

enTangle'd is an amalgamation of all things Tangle
Apache License 2.0
113 stars 66 forks source link

flex_trits_insert: check for aligned trits to use memcpy #1371

Closed semenov-vladyslav closed 5 years ago

semenov-vladyslav commented 5 years ago

Added a special case in flex_trits_insert and flex_trits_insert_from_pos such that memcpy is used when source and destination flex trits are aligned.

Test Plan:

Added tests (test_flex_trits_insert) which cover boundary conditions. Also, need to run benchmarks and profiling.

thibault-martinez commented 5 years ago

Before we merge I'd be interested in a benchmark, even very basic just timing the test you wrote with and without your change.

Le mar. 23 juil. 2019 à 08:48, Tsvi Sabo notifications@github.com a écrit :

@tsvisabo approved this pull request.

— You are receiving this because your review was requested. Reply to this email directly, view it on GitHub https://github.com/iotaledger/entangled/pull/1371?email_source=notifications&email_token=AAZG43GYAOZ4I2JVV7DY3ZDQA2SSZA5CNFSM4IF3TCTKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOB7HKCTQ#pullrequestreview-265199950, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZG43DILIBQUVPKWJOGCDDQA2SSZANCNFSM4IF3TCTA .

semenov-vladyslav commented 5 years ago

flex_trits_insert is the bottleneck in transaction_serialize. All the chunks of a transaction are of fixed size and are multiple of 3, which make it perfect for TE3: all the buffers are aligned and memcpy is used. It's easy to confirm: