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

New release #8113

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

New release #8113

wants to merge 11 commits into from

Conversation

waghanza
Copy link
Collaborator

@waghanza waghanza commented Jan 3, 2025

Hi,

This PR will update release.

I have however an issue with axum, with version 0.8

root@699c7e31e802:/# /usr/src/app/target/release/server
thread 'main' panicked at src/main.rs:10:10:
Path segments must not start with `:`. For capture groups, use `{capture}`. If you meant to literall@khry match a segment starting with a colon, call `without_v07_checks` on the router.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Aborted (core dumped)

cc @wyatt-herkamp @krishnaTORQUE @davidpdrsn @jplatte

@waghanza waghanza added the release This PR contains results update label Jan 3, 2025
@wyatt-herkamp
Copy link
Contributor

wyatt-herkamp commented Jan 3, 2025

Starting in Axum 0.8 path variables went from being declared like :user to being declared like {user}

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 3, 2025

Yes, sorry for the ping. I've noticed it in tokio-rs/axum#2645

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 3, 2025

@trikko @whiplash could you check serverino implementation plz ? CI is failing

@trikko
Copy link
Contributor

trikko commented Jan 3, 2025

@trikko @whiplash could you check serverino implementation plz ? CI is failing

Try building with last version (0.7.14)

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 3, 2025

Thanks, it's working @trikko

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 3, 2025

When I try to compile httpz with zig build -Doptimize=ReleaseFast, I have

thread 26 panic: reached unreachable code
Panicked during a panic. Aborting.
error: the following build command crashed:
/home/ziguser/.zig-cache/o/a1900f3a86f3a4650490386b5a009115/build /usr/local/zig/zig /home/ziguser /home/ziguser/.zig-cache /home/ziguser/.cache/zig --seed 0x4541726d -Zaa0959d512e2acaa -Doptimize=ReleaseFast

Any idea @karlseguin @Kayden1412 @zigster64 ?

I'm on aarch64 using

const std = @import("std");

@Kayden1412
Copy link
Contributor

@waghanza #7961 (comment)

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 4, 2025

I wonder how bun make for being compiled on ARM then ;-) @Kayden1412

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 4, 2025

@kpicaza any plan to support 8.4 ?

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 4, 2025

I can not test with ice or phalcon with php 8.4 due to missing file #include <ext/standard/php_rand.h>

any idea @mruz @niden ?

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 4, 2025

@snowbldr The version of uwebsockets in https://github.com/SRFNStack/spliffy/blob/2e56844d4102cd6279c8dceb9fbe283da6032086/package.json#L36
is not compatible with the last LTS of node

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 4, 2025

@mimiMonads for vixeny-bun, I have

root@b05a5df00cca:/usr/src/app# bun run app.ts
1 | const app = await import('./server.ts')
2 |
3 | Bun.serve({
4 |   fetch: await app.compose(),
                       ^
TypeError: app.compose is not a function. (In 'app.compose()', 'app.compose' is undefined)
      at /usr/src/app/app.ts:4:20

Bun v1.1.42 (Linux arm64)

@niden
Copy link

niden commented Jan 4, 2025

I can not test with ice or phalcon with php 8.4 due to missing file #include <ext/standard/php_rand.h>

any idea @mruz @niden ?

Phalcon does not have support for PHP 8.4 yet. We are working on it

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 5, 2025

I have switch to pm2 6 (yes, still in beta) for bun (I needed before to disable reuse-port), except for :

  • stricjs
  • express
  • elysia
  • fastify
  • vixeny

Seems like reuse-port is enabled by default for those libs, and then pm2 could not run 😛

If you know how to disable this ... any help is ❤️ appreciated

As for now, I use the old cluster.ts way (exec ditsmod that use a custom solution)

cc @mario-huang @mcollina @SaltyAom @aquapi @KostyaTretyak @mimiMonads

@mcollina
Copy link
Collaborator

mcollina commented Jan 5, 2025

I would not recommend using pm2 in any benchmarks, as it monkeypatches some things inside core, making the benchmark about pm2.

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 6, 2025

What do you recommend then @mcollina ? The idea is to mimic production use, and mainly to spread on all cores

@KostyaTretyak
Copy link
Contributor

@waghanza, I also think you don't need to use pm2 in your tests at all. Which of its features do you use at work? Restart the process? But why is it in the case of benchmarks? I think that if one of the frameworks crashes when it has such a simple code, then there is no need to raise it. Let the maintainers take care of its proper settings.

You also using pm2 for cluster mode. But in this case, it is better to use the native code for the corresponding web server, because in the case of Node.js - this is one way, and in the case of Bun.js - it is another way.

for Node.js:

import cluster from 'node:cluster';
import { availableParallelism } from 'node:os';

const numCpus = availableParallelism();

if (numCpus > 1 && cluster.isPrimary) {
  for (let i = 0; i < numCpus; i++) {
    cluster.fork();
  }
} else {
  // here past your code to create the app and webserver
  app.server.listen(3000, '0.0.0.0');
}

for Bun.js:

import { availableParallelism } from 'node:os';

const numCpus = availableParallelism();

for (let i = 0; i < numCpus; i++) {
  Bun.spawn(['bun', 'app.ts'], { // here may be replace it with "*.js"
    stdio: ['inherit', 'inherit', 'inherit'],
    env: { ...process.env },
  });
}

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 6, 2025

I understand your points @KostyaTretyak @mcollina. The idea is to mimic production usage, mainly with pm2 (or alternative), but we do not need them here, because :

  • it could change results (add a little overhead)
  • no need of its feature
  • we do not test any framework features

Agree. It's better to stick to native solution.

Let's use native solution for durian.js then @mario-huang

@zigster64
Copy link

zigster64 commented Jan 6, 2025

When I try to compile httpz with zig build -Doptimize=ReleaseFast, I have

thread 26 panic: reached unreachable code
Panicked during a panic. Aborting.
error: the following build command crashed:
/home/ziguser/.zig-cache/o/a1900f3a86f3a4650490386b5a009115/build /usr/local/zig/zig /home/ziguser /home/ziguser/.zig-cache /home/ziguser/.cache/zig --seed 0x4541726d -Zaa0959d512e2acaa -Doptimize=ReleaseFast

Any idea @karlseguin @Kayden1412 @zigster64 ?

I'm on aarch64 using

const std = @import("std");

Thanks - will have a look, although looking through your code + build config + dockerfile, I dont see anything obvious :(

I do have 1 situation where I get this exact same error, and haven't had time to go through a solution yet (just worked around it in the interim)

The situation where I can reproduce the same "panic during panic" error is :

  • I have a repo using zig latest 0.14.dev, and httpz
  • Builds fine on local
  • docker build also works fine when I run it on my dedicated and up to date docker server
  • Drone CI build fails with this exact same error for a linux-x86_64 build. Hmmm. (Drone pulls the repo, and builds from the dockerfile)
  • My dockerfile that works on local and fails on drone looks similar to yours - base off Debian, manually fetch and untar zig, then zig build with optimize=ReleaseFast

Only differences I can think of between the Drone CI instance that fails with this error, and my own docker server is

  • Drone CI is running under Alpine, which uses musl and busybox compared to Debian full
  • Drone CI machine is running linux, but an older kernel compared to my more up to date and working docker server

Will have to double check which linux kernel version is on the failing machine - I think it's the previous Ubuntu LTS version 20.x or something. Will have to double check that

I know that I spun up a quick vultr Ubuntu server on the same old kernel version, and tried zig build from there - that worked fine

I also tried spinning up a vultr Alpine based server and tried zig build of the project from there - that worked fine as well, although it was running the newer kernel compared to the Drone CI linux kernel that was failing

So yeah - not a solution, but some more clues towards a solution maybe. The error Im getting during compile happens pretty quickly in the build process (about 5 seconds in), and is the exact same error that you are seeing "Panic during panic"

I put it down to some weird combination of linux kernel + musl + zig version for the time being, with a note to look deeper into it in the new year. Its now the new year :)

Another red herring is that my repo also uses a C library to write XLSX files - so I was thinking that might be part of my problem as well. Not sure yet

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 7, 2025

Thanks @zigster64 for heads up. You provide some meaningful insights. If this project could help any community, zig here, it will be 👍🏻

The dockefile is use is

FROM debian:bullseye-slim AS build

# Set a non-root user for added security
RUN useradd -m ziguser

# Install dependencies (update to latest secure versions)
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    wget xz-utils \
    ca-certificates && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Download the latest stable Zig binary from the official website
ARG ZIG_VERSION=0.13.0
RUN wget https://ziglang.org/download/0.13.0/zig-linux-aarch64-0.13.0.tar.xz

RUN tar -xvf zig-linux-aarch64-0.13.0.tar.xz

RUN mv zig-linux-aarch64-0.13.0 /usr/local/zig

# Add Zig to the PATH
ENV PATH="/usr/local/zig:$PATH"

WORKDIR /home/ziguser

COPY 'build.zig' 'build.zig'
RUN chown ziguser build.zig
COPY 'src/main.zig' 'src/main.zig'
RUN chown ziguser src/main.zig
COPY 'build.zig.zon' 'build.zig.zon'
RUN chown ziguser build.zig.zon
RUN chown -R ziguser src

# Switch to the non-root user
USER ziguser

RUN zig build -Doptimize=ReleaseFast

FROM debian

RUN apt-get -qq update
RUN apt-get -qy install ca-certificates curl

COPY --from=build /app/zig-out/bin/httpz /server

ENTRYPOINT ["/home/ziguser/server"]

HEALTHCHECK CMD curl --fail http://0.0.0.0:3000 || exit

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 7, 2025

After taking a closer look, the debian version in use is different : 11 for compilation step and 12 to run.

I have change this for

FROM debian:12-slim AS build

# Set a non-root user for added security
RUN useradd -m ziguser

# Install dependencies (update to latest secure versions)
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    wget xz-utils \
    ca-certificates && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Download the latest stable Zig binary from the official website
ARG ZIG_VERSION=0.13.0
RUN wget https://ziglang.org/download/0.13.0/zig-linux-aarch64-0.13.0.tar.xz

RUN tar -xvf zig-linux-aarch64-0.13.0.tar.xz

RUN mv zig-linux-aarch64-0.13.0 /usr/local/zig

# Add Zig to the PATH
ENV PATH="/usr/local/zig:$PATH"

WORKDIR /home/ziguser

COPY 'build.zig' 'build.zig'
RUN chown ziguser build.zig
COPY 'src/main.zig' 'src/main.zig'
RUN chown ziguser src/main.zig
COPY 'build.zig.zon' 'build.zig.zon'
RUN chown ziguser build.zig.zon
RUN chown -R ziguser src

# Switch to the non-root user
USER ziguser

RUN zig build -Doptimize=ReleaseFast

FROM debian:12-slim

RUN apt-get -qq update
RUN apt-get -qy install ca-certificates curl

COPY --from=build /app/zig-out/bin/httpz /server

ENTRYPOINT ["/home/ziguser/server"]

HEALTHCHECK CMD curl --fail http://0.0.0.0:3000 || exit

but no change

@waghanza waghanza closed this Jan 7, 2025
@waghanza waghanza deleted the update branch January 7, 2025 19:38
@waghanza waghanza reopened this Jan 7, 2025
@waghanza
Copy link
Collaborator Author

waghanza commented Jan 7, 2025

Seems to compile on CI (x86_64)

@trikko
Copy link
Contributor

trikko commented Jan 12, 2025

You accidentally downgraded serverino. Last version is 0.7.15, not 0.7.4.

@waghanza
Copy link
Collaborator Author

@enghitalo With web, I have

[veb] Running app on http://localhost:3000/
V panic: array.get: index out of range (i,a.len):0, 0
v hash: a93d94a
sh: 1: addr2line: not found
/app/server(+0x5a3b0) [0xaaaacf99a3b0]
sh: 1: addr2line: not found
/app/server(+0x5e854) [0xaaaacf99e854]
sh: 1: addr2line: not found
/app/server(+0x69258) [0xaaaacf9a9258]
sh: 1: addr2line: not found
/app/server(+0x6b9f4) [0xaaaacf9ab9f4]
sh: 1: addr2line: not found
/app/server(+0x723fc) [0xaaaacf9b23fc]
sh: 1: addr2line: not found
/app/server(+0xa740) [0xaaaacf94a740]
sh: 1: addr2line: not found
/lib/aarch64-linux-gnu/libc.so.6(+0x27740) [0xffff73317740]
sh: 1: addr2line: not found
/lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0x98) [0xffff73317818]
sh: 1: addr2line: not found
/app/server(+0xa830) [0xaaaacf94a830]

@waghanza
Copy link
Collaborator Author

@msmakouz @butschster @wolfy-j I have

 => ERROR [30/31] RUN php public/index.php configure                                                                                                                                                        0.2s
------
 > [30/31] RUN php public/index.php configure:
0.124
0.124 Deprecated: Constant E_STRICT is deprecated in /usr/src/app/public/index.php on line 13
0.135 [ErrorException]
0.135 Spiral\YiiErrorHandler\HtmlRenderer::render(): Implicitly marking parameter $format as nullable is deprecated, the explicit nullable type must be used instead in vendor/spiral-packages/yii-error-handler-bridge/src/HtmlRenderer.php:25
0.135 [ErrorException]
0.135 Constant E_STRICT is deprecated in public/index.php:13
------
.Dockerfile.road-runner:47
--------------------
  45 |         RUN composer install --no-dev --prefer-dist --classmap-authoritative
  46 |         RUN composer dumpautoload -o
  47 | >>>     RUN php public/index.php configure
  48 |         RUN vendor/bin/rr get-binary
  49 |
--------------------
ERROR: failed to solve: process "/bin/sh -c php public/index.php configure" did not complete successfully: exit code: 255
make: *** [php/spiral//.Makefile:2: build] Error 1

for spiral. Can you take a look ?

@trikko
Copy link
Contributor

trikko commented Jan 19, 2025

@waghanza Wrong serverino version update?

@waghanza
Copy link
Collaborator Author

I've set 0.7.16 in dub.json @trikko , but anyway 0.7.x is taken so ... last one

@trikko
Copy link
Contributor

trikko commented Jan 19, 2025

Just because you have no cache luckily 🙂

@waghanza
Copy link
Collaborator Author

@jim-king-2000 @danteissaias how can I run fast with deno server --parallel app.ts ?
I try this

import fast from "https://deno.land/x/[email protected]/mod.ts";

// Create the Fast app
const app = fast();

// Define routes
app.get("/", (req, res) => {
  res.text("Welcome to Fast with Deno Serve!");
});

app.get("/json", (req, res) => {
  res.json({ message: "This is a JSON response from Fast!" });
});

app.get("/hello/:name", (req, res) => {
  const name = req.params.name;
  res.text(`Hello, ${name}!`);
});

export default fetch ;

but without success

@danteissaias
Copy link

@jim-king-2000 @danteissaias how can I run fast with deno server --parallel app.ts ? I try this

import fast from "https://deno.land/x/[email protected]/mod.ts";

// Create the Fast app
const app = fast();

// Define routes
app.get("/", (req, res) => {
  res.text("Welcome to Fast with Deno Serve!");
});

app.get("/json", (req, res) => {
  res.json({ message: "This is a JSON response from Fast!" });
});

app.get("/hello/:name", (req, res) => {
  const name = req.params.name;
  res.text(`Hello, ${name}!`);
});

export default fetch ;

but without success

Hmm, I’ll probably have to release an update to expose the fetch handler.

@enghitalo
Copy link
Contributor

@waghanza V fixed on current master

@aquapi
Copy link
Contributor

aquapi commented Jan 19, 2025

@waghanza Can you add this as a Bun framework?

Code:

import { router, jitc } from '@mapl/app';

const app = router()
   .build('/', () => '')
   .post('/user', () => '')
   .get('/user/*', (params) => params[0]);

// Port 3000
export default await jitc(app, { exposeStatic: true });

@waghanza
Copy link
Collaborator Author

Could you make an external PR to have a clear separation.

Will be a mess, otherwise

Also, may you ping the author ?

@aquapi
Copy link
Contributor

aquapi commented Jan 19, 2025

@waghanza I'm the author XD
Anyways do I need to include cluster stuff in my PR?

@waghanza
Copy link
Collaborator Author

Make a PR not from master, I'll push cluster thing it ⭐

@danteissaias
Copy link

@jim-king-2000 @danteissaias how can I run fast with deno server --parallel app.ts ? I try this

import fast from "https://deno.land/x/[email protected]/mod.ts";

// Create the Fast app
const app = fast();

// Define routes
app.get("/", (req, res) => {
  res.text("Welcome to Fast with Deno Serve!");
});

app.get("/json", (req, res) => {
  res.json({ message: "This is a JSON response from Fast!" });
});

app.get("/hello/:name", (req, res) => {
  const name = req.params.name;
  res.text(`Hello, ${name}!`);
});

export default fetch ;

but without success

Have you tried out of interest?

import fast from "https://deno.land/x/[email protected]/mod.ts";

// Create the Fast app
const app = fast();

// Define routes
app.get("/", (req, res) => {
  res.text("Welcome to Fast with Deno Serve!");
});

app.get("/json", (req, res) => {
  res.json({ message: "This is a JSON response from Fast!" });
});

app.get("/hello/:name", (req, res) => {
  const name = req.params.name;
  res.text(`Hello, ${name}!`);
});

export default { fetch: app.handle }

@waghanza
Copy link
Collaborator Author

Yes @danteissaias , but without sucess

For info, I'm running it in

FROM denoland/deno:2.1.5

WORKDIR /usr/src/app


  COPY 'app.ts' 'app.ts'

  RUN deno install


RUN apt-get -qq update
RUN apt-get -qy install curl
HEALTHCHECK CMD curl --fail http://0.0.0.0:3000 || exit 1

ENTRYPOINT deno serve --parallel  --port 3000 --allow-net --allow-read=. --allow-env app.ts

@waghanza
Copy link
Collaborator Author

@waghanza I'm the author XD Anyways do I need to include cluster stuff in my PR?

Not for deno @aquapi
what is build method ?

@waghanza
Copy link
Collaborator Author

waghanza commented Jan 19, 2025

@yusukebe @SaltyAom is clustering enabled by default with hono ? -> for bun
When I use the script cluster.ts above, I have

Bun v1.1.45 (Linux arm64)
 7 |       if (typeof entryNamespace?.default?.fetch === 'function')  {
 8 |         const server = Bun.serve(entryNamespace.default);
 9 |         console.debug(`Started ${server.development ? 'development ' : ''}server: ${server.protocol}://${server.hostname}:${server.port}`);
10 |       }
11 |    }, reportError);
12 |    const server = Bun.serve(entryNamespace.default);
               ^
error: Failed to start server. Is port 3000 in use?
 syscall: "listen",
   errno: 0,
    code: "EADDRINUSE"

      at bun:main:12:28

EDIT : SOLVED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release This PR contains results update
Projects
None yet
Development

Successfully merging this pull request may close these issues.