gofiber / fiber

⚡️ Express inspired web framework written in Go
https://gofiber.io
MIT License
32.97k stars 1.62k forks source link

📝 [Proposal]: Improving route matching and url parsing performance with Ada Url #3019

Open meftunca opened 3 months ago

meftunca commented 3 months ago

Feature Proposal Description

Ada Url can parse url information really fast. Because it processes simd and data in parallel, which means doing multiple operations at once. By parsing url parsing information quickly, we can actually approach the speed of fasthttp.

After Ada Url started using nodejs, they got a really big performance boost. At least we should be able to enable this feature via fiber config. https://github.com/ada-url/ada#ada-is-fast

Alignment with Express API

It does not include any changes that will affect the interface of Express JS.

HTTP RFC Standards Compliance

This feature only speeds up route matching and url fragmentation. It is not a feature that will break any existing structure.

API Stability

This feature only speeds up route matching and url fragmentation. It is not a feature that will break any existing structure. As I mentioned above, nodejs has provided more than 4x performance increase thanks to this library. It also already uses this library.

Feature Examples

import (
   "github.com/ada-url/goada"
   "fmt"
)

url, err := goada.New("https://www.GOogle.com")
if err != nil {
    t.Error("Expected no error")
}
fmt.Println(url.Href()) // prints https://www.google.com/
url.SetProtocol("http:")
url.SetHash("goada")
fmt.Println(url.Hash()) // prints #goada
fmt.Println(url.Href()) // prints http://www.google.com/#goada

Checklist:

welcome[bot] commented 3 months ago

Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

ReneWerner87 commented 3 months ago

thx for the idea

our current route matching is already quite optimized and can keep up with that of aida image

but we are happy to test it

meftunca commented 3 months ago

Can you share the results of the comparison with us? @ReneWerner87 :)

ReneWerner87 commented 3 months ago

my screenshot and the numbers from your article

ada average number image

our route parsing numbers image

ReneWerner87 commented 3 months ago

perhaps a misunderstanding

we can test the package in fiber and then look at the results just wanted to show that we already have very good results but it varies depending on which cases are used, so you can't really say which is faster and test it in an integrated way is a good idea

meftunca commented 3 months ago

Then I'll take the time to do some benchmarks over the weekend if you like, and we'll continue by adding the benchmarks here, along with the existing and island url.

nickajacks1 commented 3 months ago

This requires cgo, which would be a real shame to force on users. If it's included in fiber, I think it should be an optional addon.