Luukdegram / apple_pie

Basic HTTP server implementation in Zig
MIT License
163 stars 21 forks source link

router performance #50

Open petar-dambovaliev opened 3 years ago

petar-dambovaliev commented 3 years ago

Hey there, i am a zig newbie here. It looks to me that the router is splitting the called url path by slash and matching on those substrings. The trie is the correct data structure for this but it will be much more efficient to match on characters or bytes.

https://github.com/darpi-rs/darpi/blob/master/gonzales/src/lib.rs

If you think its worthwhile to improve this, you can checkout my router implementation in my rust web framework. It also has case insensitive capability without runtime costs.

Luukdegram commented 3 years ago

Yep, it's a quickly implemented version just to get it working. As the sever has 0 dependencies on it, people can just implement their own version. For that reason it's simply not high on my priority list for now, there's more to implement first as routing isn't even part of the spec. I do have one other implementation that I someday will adapt and increase its performance of, but that's not going to be soon: https://github.com/Luukdegram/ctradix

petar-dambovaliev commented 3 years ago

Yep, it's a quickly implemented version just to get it working. As the sever has 0 dependencies on it, people can just implement their own version. For that reason it's simply not high on my priority list for now, there's more to implement first as routing isn't even part of the spec. I do have one other implementation that I someday will adapt and increase its performance of, but that's not going to be soon: https://github.com/Luukdegram/ctradix

Yea, that is very similar to what i have. I am trying to get into zig and thinking about whether it's metaprograming capabilities will be powerful enough to make these handler functions nicer. Meaning, having alternative to the Rust macro capabilities to be able to have framework provided object extractors from the request bytes and stuff like that.