-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nmt: switch NS convention to big-endian
The canonical representation of a namespace ID is [u8; N] (N=4 for now). However, it seems to be useful at least for debugging purposes to parse and display the namespace as an unsigned integer. Prior this change, the integer form was defined as little-endian, just because it's a default. Most of modern architectures are LE by default, wasm is LE, etc. Mostly it doesn't matter, performance differences are neglegible either way 99% of the time. I suppose the reason for this is that LE has a marginal advantage because of the things like that you don't need byte shuffle when reinterpreting value type (e.g. u32 and u16) behind the same pointer and stuff like that. However, big endian also has it's benefits. First is a human readable representation, which is important here since this is more of a developer convenience representation. Another, benefit is that BE corresponds to the byte ordering. E.g., 256 > 255 (0x0100 > 0x00ff), which doesn't hold in LE. And we do care about the ordering of namespaces, at present because the NMT must literally be built in order, but in future I also think it would be a useful property to have blobs sorted. At the same time, the performance gains of using LE are neglegible. So given all of that I propose we change the canonical integer representation to BE.
- Loading branch information
Showing
7 changed files
with
52 additions
and
38 deletions.
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
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
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