Skip to content
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

Splay tree: use struct member #281

Open
splitice opened this issue Jul 11, 2021 · 0 comments
Open

Splay tree: use struct member #281

splitice opened this issue Jul 11, 2021 · 0 comments
Labels
1.1 Issue related to Tinc 1.1 enhancement New feature requests or performance improvement.

Comments

@splitice
Copy link
Contributor

splitice commented Jul 11, 2021

Perhaps a refactoring of the splay tree ( splay_node_t) node would be a good idea.

Basically if you put the splay_node_t struct minus the data pointer as a member in the struct being inserted you would:

  • Reduce pointer indirection (minor)
  • Be able to local the splay_node_t without performing a search from the subnet cache (good for /32 removal)

It would be best if splay_* functions become macros referencing the named struct to enforce this (safe) usage splay_insert_node(subnet_tree, subnet, splay_global). Getting the data pointer from splay_node_t can be done with offsetof and contained within a helper macro.

There may be other improvements outside of the subnet system as well as splay_node_t is used in many places.

For an example of what I mean using the subnet_t usage of the splay tree:

typedef struct subnet_t {
struct splay_node_t splay_global;
struct splay_node_t splay_node;
// ... existing members
}

Where splay_node_t is:

typedef struct splay_node_t {
	/* Linked list part */

	struct splay_node_t *next;
	struct splay_node_t *prev;

	/* Tree part */

	struct splay_node_t *parent;
	struct splay_node_t *left;
	struct splay_node_t *right;
}
@gsliepen gsliepen added 1.1 Issue related to Tinc 1.1 enhancement New feature requests or performance improvement. labels Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.1 Issue related to Tinc 1.1 enhancement New feature requests or performance improvement.
Projects
None yet
Development

No branches or pull requests

2 participants