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

refactor(router/atc): remove unnecessary tb_nkeys() #13043

Closed
wants to merge 1 commit into from

Conversation

chronolaw
Copy link
Contributor

@chronolaw chronolaw commented May 17, 2024

Summary

KAG-4138

Checklist

  • The Pull Request has tests
  • A changelog file has been created under changelog/unreleased/kong or skip-changelog label added on PR if changelog is unnecessary. README.md
  • There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE

Issue reference

Fix #[issue number]

@github-actions github-actions bot added core/router cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee labels May 17, 2024
@chronolaw
Copy link
Contributor Author

I checked the code in runloop/handler, the item in route_and_service array should always has two elements,
do we really need this assert? I think that removing this check will get some speed improvement.

@hanshuebner , I think that you introduced this check before, do you have some opnions?

@chronolaw chronolaw marked this pull request as ready for review May 17, 2024 01:10
@bungle
Copy link
Member

bungle commented May 17, 2024

I checked the code in runloop/handler, the item in route_and_service array should always has two elements, do we really need this assert? I think that removing this check will get some speed improvement.

@hanshuebner , I think that you introduced this check before, do you have some opnions?

Yes, I was wondering the same. We have a lot of other places in code too where we have asserts like we don’t trust the input (here it happens in a loop). If we error here it leads most probably to issue where router is never build, but we have cleaner error message. But this probably never happens.

I would say that if you have 10000 routes and one of then errors in this, it is still better to have new router. Thus logging this rare/imposdible case would be softer, but I am fine removing it altogether.

@hanshuebner
Copy link
Contributor

The assert is there for robustness. It fulfills no functional purpose and my expectation was that the performance impact was negligible.

@chronolaw
Copy link
Contributor Author

Though table.nkey() is fast and JITable, but it will be run many times in the loop, I think removing it should be acceptable.

Copy link
Contributor

@ADD-SP ADD-SP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function split_routes_and_services_by_path was called when rebuilding router, this is not the hot path when proxying.

Doing this kind of assertion for robustness when rebuilding router is acceptable for me.

@chronolaw
Copy link
Contributor Author

�Close due to ADD-SP's comment

@chronolaw chronolaw closed this May 20, 2024
@chronolaw chronolaw deleted the refactor/clean_split_routes_and_services branch May 20, 2024 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick kong-ee schedule this PR for cherry-picking to kong/kong-ee core/router size/XS skip-changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants