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

feat(bench-test): Benchmark Testing #2720

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

Conversation

muhammadahmadasifbhatti

Note: This PR is migrated from the agoric-sdk. All the comments from Mark's reviewed PR are addressed.

Description

This is PR is just a minimalistic POC to create a small tool for the benchmark testing.

How to run locally

Run the command yarn test in the packages/benchmark-test folder.

Pre-reqs of running yarn test

Install esvu globally

Select the v8 and xs from CLI so that it can download the binaries of those engines.

Install eshost-cli globally.

Run the following commands to configure the binaries of engines with eshost.

  • eshost --add "v8" d8 $ESHOST_PATH_V8
  • eshost --add "xs" xs $ESHOST_PATH_XS

Now you are good to go to run yarn test

@muhammadahmadasifbhatti muhammadahmadasifbhatti marked this pull request as ready for review February 13, 2025 07:40
@muhammadahmadasifbhatti
Copy link
Author

Currently, I am working the following changes but planing them for the follow-up PRs.

  • yarn test should run all the files in the /test folder.
  • yarn test filename should run the test from that specific file.
  • See any system level libraries that provide time in ~ns.

Copy link
Contributor

@erights erights left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!!!!

@muhammadahmadasifbhatti
Copy link
Author

@erights I have addressed the comments. I think now I can tag @kriskowal to have a final look.
Nevertheless, I am done with another small feature that when you use this tool from CLI it can take filename as the input. That PR will be ready soon and you will be able to review that on Monday.

I also have Richard's idea in mind to have an executable like ava but before that I'll write a js script that'll have an entry point in the package.json.

@muhammadahmadasifbhatti muhammadahmadasifbhatti changed the title Benchmark Testing feat(bench-test): Benchmark Testing Feb 14, 2025
@erights
Copy link
Contributor

erights commented Feb 16, 2025

Hi @muhammadahmadasifbhatti , I resolved all the conversations above that are done, or that were "No change suggested" that you thumbs-uped. That turned out to be all of them ;). I also approved the workflows and see we still have CI errors. The lint error looks like the one that would be fixed by doing a yarn format in the top level endo directory.

@muhammadahmadasifbhatti
Copy link
Author

Hi @muhammadahmadasifbhatti , I resolved all the conversations above that are done, or that were "No change suggested" that you thumbs-uped. That turned out to be all of them ;). I also approved the workflows and see we still have CI errors. The lint error looks like the one that would be fixed by doing a yarn format in the top level endo directory.

Thanks!
I just ran the yarn format command and pushed the changes. Hopefully, CI passes this time.

@erights
Copy link
Contributor

erights commented Feb 16, 2025

In the last CI run, it looks like you were also getting

command not found: eshost

errors. I'm not sure what you're supposed to do so this is available in CI. @gibson042 do you know? Since (I think) we're already using eshost for other tests, why wasn't it already available?

@kriskowal , what permission is @muhammadahmadasifbhatti missing that needed me to approve the workflow for CI to run? Whatever that is, could you add it? Thanks.

@muhammadahmadasifbhatti
Copy link
Author

In the last CI run, it looks like you were also getting

command not found: eshost

errors. I'm not sure what you're supposed to do so this is available in CI. @gibson042 do you know? Since (I think) we're already using eshost for other tests, why wasn't it already available?

@kriskowal , what permission is @muhammadahmadasifbhatti missing that needed me to approve the workflow for CI to run? Whatever that is, could you add it? Thanks.

For the above mentioned error, I think we might need to update the yaml file of the workflow to install eshost globally if that is not case already.

I am also getting another error which seems to be a linting error.

This expression is not callable.
  Type 'typeof import("/Users/muhammadahmad/Desktop/agoric-repos/endo/packages/benchmark/node_modules/@rollup/plugin-commonjs/types/index")' has no call signatures

VSCode is also squiggly here but the code is executing perfectly in both the engines. I will post the update in case I find anything.

await null;
const start = performance.now();
for (let i = 0; i < iterations; i += 1) {
await fn();
Copy link
Contributor

Choose a reason for hiding this comment

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

@michaelfig @gibson042 , do you agree that the lint complaint about the await on this line 7 is incorrect and a bug in our lint rule, since the earlier top-level await null; on line 4 should have closed the synchronous prelude?

Copy link
Contributor

Choose a reason for hiding this comment

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

Huh. Or maybe the "no await inside a loop" is a pre-existing lint setting separate from any of our await safety rules? In which case we should turn off this pre-existing lint rule globally, i.e., everywhere our own await safety rules are enforced? Attn @kriskowal @mhofman @turadg

Copy link
Member

Choose a reason for hiding this comment

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

https://eslint.org/docs/latest/rules/no-await-in-loop is built into Eslint. It's not for safety so I don't think the Jessie rule affects whether to enable it.

btw, I don't see any linting output in CI because of this error:

Run yarn lint
Checking formatting...
All matched files use Prettier code style!
Error: rollup.config.js(12,13): error TS23[4](https://github.com/endojs/endo/actions/runs/13358283307/job/37304093134#step:7:5)9: This expression is not callable.
  Type 'typeof import("/home/runner/work/endo/endo/packages/benchmark/node_modules/@rollup/plugin-node-resolve/types/index")' has no call signatures.

Choose a reason for hiding this comment

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

I am of this opinion that we should disable no-await-in-loop rule for this line. Reason being, we actually need to check the performance of the function execution separately.

@turadg the issue you mentioned in the code snippet above is being resolved but the workflow has not been ran after the update.

Copy link
Member

Choose a reason for hiding this comment

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

@turadg writes:

It's not for safety so I don't think the Jessie rule affects whether to enable it.

Correct. I consider it a reminder for folks to use for-await-of instead if that makes the code more straightforward.

@muhammadahmadasifbhatti writes:

I am of this opinion that we should disable no-await-in-loop rule for this line.

I agree with that opinion.

@muhammadahmadasifbhatti
Copy link
Author

muhammadahmadasifbhatti commented Feb 17, 2025

test job is failing and the reason is: eshost not found. I have some solutions in mind

  • Update the .github/workflows/ci.yml and install eshost globally.
  • Install eshost in the devDependencies and then use yarn eshost.
  • Just use yarn dlx as it will temporarily installs and runs a package.

Calling out the expert opinion. I would go for the 1st one as it is the simplest solution. Also, we might be needing eshost in other yarn scripts so, it is better to install it globally.

@turadg
Copy link
Member

turadg commented Feb 17, 2025

we might be needing eshost in other yarn scripts

True, but that's not a good reason to install it globally. The downsides of a global install is isn't automatically in all environments and it may be the wrong version. This is why we have package managers 😀

I suggest a fourth option:

  • 'devDependencies' so it installs a particular version AND "npm exec eshost" so it runs independently of the package manager

@muhammadahmadasifbhatti
Copy link
Author

Fixed the CI.
Another quick follow-up PR is coming where I add the --verbose flag. Right now, the output is verbose by default and there is a bunch of info(output) that a developer does not want to see. By adding the flag, I will make it optional.

@gibson042
Copy link
Contributor

FWIW, I consider dependency upon eshost to be inappropriate here... it makes sense for esbench, but what this application really needs is an entry point configured with a collection of generic commands which it can invoke with a path to an input file—and for Agoric's purposes, the command for XS should wrap xsnap rather than xst and the command for V8 should just be node (maybe with options for self-identification as a benchmark subprocess).

But we're still iterating, and if it is delivering utility with eshost then full speed ahead and don't sweat the details.

@@ -0,0 +1,39 @@
const performance = { now: () => Date.now() * 1_000_000 };
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not representative of performance.now, which returns milliseconds.

Suggested change
const performance = { now: () => Date.now() * 1_000_000 };
const performance = { now: () => Date.now() };

Copy link
Author

Choose a reason for hiding this comment

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

Umm you are right. The name and function are conflicting.
We just want to measure the time in nano-seconds. So, if anything's gonna change it's the name of the function.

Please, do post any suggestions related to precise time measurement.

Choose a reason for hiding this comment

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

Changed the name.

@muhammadahmadasifbhatti
Copy link
Author

FWIW, I consider dependency upon eshost to be inappropriate here... it makes sense for esbench, but what this application really needs is an entry point configured with a collection of generic commands which it can invoke with a path to an input file—and for Agoric's purposes, the command for XS should wrap xsnap rather than xst and the command for V8 should just be node (maybe with options for self-identification as a benchmark subprocess).

But we're still iterating, and if it is delivering utility with eshost then full speed ahead and don't sweat the details.

@gibson042 thanks for the input. I've noted your opinion and added it in the follow-up list.
As you mentioned, and also, what I have in my mind; we are inclined towards ship and iterate. Current focus is to provide the bare minimum usability. The changes you suggested might be in the next PR.

@muhammadahmadasifbhatti
Copy link
Author

@gibson042 just leaving a reminder to have a final look at the PR.

@muhammadahmadasifbhatti
Copy link
Author

I have created all the follow-up tickets on the SRE board. Here is the link to them.

@gibson042 please feel free to leave more suggestions and feedbacks. I would highly appreciate if you can review it today.

Copy link
Contributor

@gibson042 gibson042 left a comment

Choose a reason for hiding this comment

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

LGTM after addressing a few notes.


[also, capturing comments from elsewhere (without them blocking this PR)]

I think we want to drop the nesting; there's no need for a test function.

import { benchmark } from '@endo/benchmark';

// Each benchmark will be run with each element of the cross product of all arguments:
// * length 10, fillWith 'x'
// * length 100, fillWith 'x'
// * length 1000, fillWith 'x'
//
// This supports investigation of both scaling properties and of asymmetric input
// (cache hit vs. miss, match vs. not, accept vs. reject, small vs. large input, etc.).
// But such configuration is optional; when absent, each benchmark is observed without variations.
benchmark.setArgumentDomains({
  length: [10, 100, 1000],
  fillWith: ['x'],
});

// This assumes that values from `setArgumentDomains` are provided as
// separate arguments. Another alternative is providing a single record with
// named properties, albeit with the minor extra costs and boilerplate
// associated with destructuring (e.g., `(b, { length, fillWith }) => {…}`).
benchmark('Array(length).fill', (b, length, fillWith) => {
  // To support measuring fast code that would be distorted by otherwise
  // unnecessary function calls, `N` tells the function under test how
  // many times to exercise itself. Each callback body should therefore
  // have this for-loop shape, and the framework might even detect
  // incorrect callbacks by initializing `N` to a self-replacing getter
  // (e.g., `{ gotN = true; defineProperty(b, 'N', { value: N }); return N; }`).
  for (let i = b.N; i >= 0; i--) {
    b.result = Array(length).fill(fillWith);
  }
});

// `benchmark.withTransform` is *roughly* analogous to ava `test.macro`.
// Transformation functionality is important for e.g. measuring
// `passStyleOf(bigObject)` without inappropriately including the time to
// construct `bigObject`.
const fromFiller = benchmark.withTransform((b, length, fillWith) => {
  // This transformation of length → { length } and fillWith → () => fillWith
  // takes place outside of measurement, and therefore avoids distorting it.
  return [{ length }, () => fillWith];
});
benchmark('Array.from', fromFiller, (b, lengthObj, fillFn) => {
  for (let i = b.N; i >= 0; i--) {
    b.result = Array.from(lengthObj, fillFn);
  }
});

// or with the record approach:
// ```js
// const fromFiller = benchmark.withTransform((b, { length, fillWith }) => {
//   return { lengthObj: { length }, fillFn: () => fillWith };
// });
// benchmark('Array.from', fromFiller, (b, { lengthObj, fillFn }) => {…});
// ```

// or further dropping the "with" formal pattern:
// ```js
// const fromFiller = (b, { length, fillWith }) => {
//   b.context = { lengthObj: { length }, fillFn: () => fillWith };
// };
// benchmark('Array.from', fromFiller, b => {
//   const { lengthObj, fillFn } = b.context;
//   for (let i = b.N; i >= 0; i--) {
//     b.result = Array.from(lengthObj, fillFn);
//   }
// });
// ```

Comment on lines 13 to 15
Run the following commands to configure the binaries of engines with `eshost`.
* `eshost --add "v8" d8 $ESHOST_PATH_V8`
* `eshost --add "xs" xs $ESHOST_PATH_XS`
Copy link
Contributor

Choose a reason for hiding this comment

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

Installing eshost-cli does not create these variables AFAIK; they're just suggestions from its README.

Suggested change
Run the following commands to configure the binaries of engines with `eshost`.
* `eshost --add "v8" d8 $ESHOST_PATH_V8`
* `eshost --add "xs" xs $ESHOST_PATH_XS`
Run the following commands to configure the binaries of engines with `eshost`.
* `eshost --add "v8" d8 "$HOME/.esvu/bin/v8"`
* `eshost --add "xs" xs "$HOME/.esvu/bin/xs"`

Choose a reason for hiding this comment

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

I copied from the eshost with the same motivation that sometimes people change the directories manually. So, instead of a hardcode path just using a variable.
But, I get the idea. I think it should be more straight forward. Changing it.

@@ -0,0 +1,17 @@
# `@endo/benchmark`

This package just provides just minimalistic ava-like interface to run benchmark tests.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This package just provides just minimalistic ava-like interface to run benchmark tests.
This package just provides a minimalistic ava-like interface to run benchmark tests.

"postpack": "git clean -f '*.d.ts*'",
"prepack": "tsc --build tsconfig.build.json",
"test": "./run-tests.sh",
"bench": "yarn rollup -c && node --jitless --cpu-prof dist/bundle.js"
Copy link
Contributor

Choose a reason for hiding this comment

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

I find it very strange for yarn bench to run node --cpu-prof against the hard-coded test/index.test.js file.

Suggested change
"bench": "yarn rollup -c && node --jitless --cpu-prof dist/bundle.js"
"cpu-prof-test": "yarn rollup -c && node --jitless --cpu-prof dist/bundle.js"


set -e

echo $(yarn --version)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
echo $(yarn --version)
echo "yarn version: $(yarn --version)"

Comment on lines +14 to +16
echo "Installing engines..."
INSTALL_OUTPU_XS=$(yarn dlx esvu install xs 2>&1) || INSTALL_STATUS_XS=$?
INSTALL_OUTPU_V8=$(yarn dlx esvu install v8 2>&1) || INSTALL_STATUS_V8=$?
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not comfortable with yarn test modifying $HOME.

Suggested change
echo "Installing engines..."
INSTALL_OUTPU_XS=$(yarn dlx esvu install xs 2>&1) || INSTALL_STATUS_XS=$?
INSTALL_OUTPU_V8=$(yarn dlx esvu install v8 2>&1) || INSTALL_STATUS_V8=$?
echo "xs and/or v8 not found in $HOME/.esvu/engines; please esvu install them."
# The bash "command not found" exit status code is 127.
# https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html#Exit-Status-1
exit 127

Choose a reason for hiding this comment

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

I get the idea but what we are gonna do for the CI? As per your suggestion, we need to update the ci.yaml to install esvu and then install the engines using esvu. But, for this particular PR, I am not comfortable with changing the ci.yaml file. Open for the suggestions.

Nevertheless, it's gonna change in the next couple of PRs when we will be using node and xsnap to run these tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Changing ci.yaml is entirely appropriate; this adds a new requirement on the host environment just like the one currently fulfilled by setup-node.

Copy link
Contributor

Choose a reason for hiding this comment

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

And for local purposes, a package.json script for use like yarn run install-engines would make the consequences more clear.

Copy link
Author

Choose a reason for hiding this comment

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

I am still having second thoughts about this change. Reason being, there are follow-up tasks aligned and this code might not even exist in the next PR. Also, if we make this change we have to reverse the ci.yaml?

Another reason is ci.yaml is being run for every package in the package/ directory. So, it will be an unnecessary side effects for other packages to install esvu and eshost globally.

@turadg had a similar idea in his mind to not install esvu and eshost globally. Link to the comment.

I am more inclined towards having different script (as you mentioned in the second comment).

And for local purposes, a package.json script for use like yarn run install-engines would make the consequences more clear.

  • yarn install-engines which will do all the esvu and eshost related stuff.
  • yarn test:bench to run the benchmark tests. In this case bundle the code and run the tests in index.test.js
  • yarn test to run yarn install-engines and yarn test:bench. Might be vague in names but open for suggestions.

Choose a reason for hiding this comment

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

But, even with different scripts yarn will be modifying the $HOME directory.

Copy link
Contributor

@gibson042 gibson042 Feb 25, 2025

Choose a reason for hiding this comment

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

I am still having second thoughts about this change. Although, what you are saying is right, but we know that there are follow-up tasks aligned. This code might not even exist in the next PR. So, we have to reverse the ci.yaml again?

Yes. You can add a comment as a reminder.

Another reason is ci.yaml is being run for every package in the package/ directory. So, it will be unnecessary side effects to install esvu and eshost globally.

That's not what I'm seeing at https://github.com/endojs/endo/blob/master/.github/workflows/ci.yml. Only the job "test" runs yarn test at package scope, and it does so after some setup steps. So what I'm asking for is insertion of esvu engine installation and eshost setup before its yarn build step, which will run exactly as often as the rest of those steps (i.e., once for each item of the (node-version: [18.x, 20.x, 22.4.1], platform: [ubuntu-latest]) matrix cross product).

I am more inclined towards having different script (as you mentioned in the second comment).

Having the separate package.json script is good, and the CI job step could even use it to reduce duplication. But the step on its own does not resolve this issue, because CI must have the engines but local yarn test must not install them.

And for local purposes, a package.json script for use like yarn run install-engines would make the consequences more clear.

  • yarn install-engines which will do all the esvu and eshost related stuff.
  • yarn test:bench to run the benchmark tests. In this case bundle the code and run the tests in index.test.js
  • yarn test to run yarn install-engines and yarn test:bench. Might be vague in names but open for suggestions.

No, I'm still objecting to yarn test modifying $HOME.

Comment on lines +11 to +28
if are_engines_installed; then
echo "Engines already installed. Skipping installation."
else
echo "Installing engines..."
INSTALL_OUTPU_XS=$(yarn dlx esvu install xs 2>&1) || INSTALL_STATUS_XS=$?
INSTALL_OUTPU_V8=$(yarn dlx esvu install v8 2>&1) || INSTALL_STATUS_V8=$?
fi

if [ -n "$INSTALL_STATUS_XS" ] || [ -n "$INSTALL_STATUS_V8" ]; then
if are_engines_installed; then
echo "Engines installed successfully despite esvu error."
else
echo "Error installing XS or V8:"
echo "$INSTALL_OUTPU_XS"
echo "$INSTALL_OUTPU_V8"
exit 1
fi
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not comfortable with yarn test modifying $HOME.

Suggested change
if are_engines_installed; then
echo "Engines already installed. Skipping installation."
else
echo "Installing engines..."
INSTALL_OUTPU_XS=$(yarn dlx esvu install xs 2>&1) || INSTALL_STATUS_XS=$?
INSTALL_OUTPU_V8=$(yarn dlx esvu install v8 2>&1) || INSTALL_STATUS_V8=$?
fi
if [ -n "$INSTALL_STATUS_XS" ] || [ -n "$INSTALL_STATUS_V8" ]; then
if are_engines_installed; then
echo "Engines installed successfully despite esvu error."
else
echo "Error installing XS or V8:"
echo "$INSTALL_OUTPU_XS"
echo "$INSTALL_OUTPU_V8"
exit 1
fi
fi
if are_engines_installed; then
echo "Engines already installed. Skipping installation."
else
echo "xs and/or v8 not found in $HOME/.esvu/engines; please esvu install them."
# The bash "command not found" exit status code is 127.
# https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html#Exit-Status-1
exit 127
fi

Choose a reason for hiding this comment

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

Addressed above.

Comment on lines 31 to 38
ls -la "$HOME/.esvu/engines"
ls -la "$HOME/.esvu/engines/xs"
ls -la "$HOME/.esvu/engines/v8"


chmod +x "$HOME/.esvu/engines/xs/xst"
chmod +x "$HOME/.esvu/engines/v8/d8"

Copy link
Contributor

Choose a reason for hiding this comment

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

What purpose is served by these commands?

Suggested change
ls -la "$HOME/.esvu/engines"
ls -la "$HOME/.esvu/engines/xs"
ls -la "$HOME/.esvu/engines/v8"
chmod +x "$HOME/.esvu/engines/xs/xst"
chmod +x "$HOME/.esvu/engines/v8/d8"

Choose a reason for hiding this comment

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

The first three are the logs for the debugging purposes. I still wanted to have them in case something goes off after merging the PR in the CI.

In the last two lines, we are changing the permissions of engine binaries so that we can execute them to run our bundled.

Copy link
Contributor

Choose a reason for hiding this comment

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

The first three are the logs for the debugging purposes. I still wanted to have them in case something goes off after merging the PR in the CI.

But they won't serve that purpose without either a preceding echo or a set -x.

In the last two lines, we are changing the permissions of engine binaries so that we can execute them to run our bundled.

Aren't they already marked executable when installed? I've never had to chmod them locally.

Copy link
Author

Choose a reason for hiding this comment

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

But they won't serve that purpose without either a preceding echo or a set -x

I am able to see the logs both on local and on ci. Nevertheless, pushing an echo because that seems right.
image

Aren't they already marked executable when installed? I've never had to chmod them locally.

Nope, I had to change the mod locally. Also, at first I pushed the changes without changing the mod and got an error on the CI i.e. Either the file does not exist or it is not executable.

Comment on lines +39 to +42
yarn eshost --add "xs" xs "$HOME/.esvu/engines/xs/xst"
yarn eshost --add "v8" d8 "$HOME/.esvu/engines/v8/d8"

yarn eshost --list
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
yarn eshost --add "xs" xs "$HOME/.esvu/engines/xs/xst"
yarn eshost --add "v8" d8 "$HOME/.esvu/engines/v8/d8"
yarn eshost --list
yarn eshost -h xs,v8 -se true >/dev/null 2>&1 || ESHOST_STATUS=$?
if [ "${ESHOST_STATUS:-0}" != 0 ]; then
echo "xs and/or v8 not known to eshost; please eshost --add them per README.md."
exit $ESHOST_STATUS
fi

Choose a reason for hiding this comment

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

Again, I did this for the CI.

Copy link
Contributor

Choose a reason for hiding this comment

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

But it shouldn't degrade the local experience. Something like this would still accomplish CI visibility:

yarn eshost -h xs,v8 -se true >/dev/null 2>&1 || ESHOST_STATUS=$?
if [ "${ESHOST_STATUS:-0}" != 0 ]; then
    echo "xs and/or v8 not known to eshost; please eshost --add them per README.md."
    echo "# eshost --list"
    yarn eshost --list
    exit $ESHOST_STATUS
fi

Choose a reason for hiding this comment

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

I think we are not on the same page here.
Let's suppose I accept the suggested changes. Now, the CI will run yarn test and it we will immediately faill because of error xs and/or v8 not known to eshost; please eshost --add them per README.md.

This will work only if we update the ci.yaml to run these commands (of adding the engines) for us.

Copy link
Contributor

Choose a reason for hiding this comment

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

This will work only if we update the ci.yaml to run these commands (of adding the engines) for us.

Yes, that's exactly what I'm requesting. yarn test on its own requires the engines to already exist and fails with an informative message when they don't. ci.yaml makes sure that the engines are installed before invoking yarn test.

Comment on lines 44 to 48
echo "Running eshost..."

yarn rollup -c

yarn eshost -h xs,v8 dist/bundle.js
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
echo "Running eshost..."
yarn rollup -c
yarn eshost -h xs,v8 dist/bundle.js
yarn rollup -c
yarn eshost -h xs,v8 dist/bundle.js

@muhammadahmadasifbhatti
Copy link
Author

For this comment.
By looking at the code you suggested, I guess this will change the whole scope of the PR. What do you think? The idea is to ship and iterate and think this way we will be blocked on this another couple of days.

One more thing; Although, we both agree that benchmark should not be nested but we might need some other opinions on this. So, we can ask this question in the endo channel and then work on it.

@gibson042
Copy link
Contributor

For this comment. By looking at the code you suggested, I guess this will change the whole scope of the PR. What do you think? The idea is to ship and iterate and think this way we will be blocked on this another couple of days.

Right, I hoped the preface would make that clear. That comment is not requesting changes for this PR, just documenting more publicly where I want things to end up.

Comment on lines +31 to +41
echo $(ls -la "$HOME/.esvu/engines")
echo $(ls -la "$HOME/.esvu/engines/xs")
echo $(ls -la "$HOME/.esvu/engines/v8")


chmod +x "$HOME/.esvu/engines/xs/xst"
chmod +x "$HOME/.esvu/engines/v8/d8"

yarn eshost --add "xs" xs "$HOME/.esvu/engines/xs/xst"
yarn eshost --add "v8" d8 "$HOME/.esvu/engines/v8/d8"

Copy link
Contributor

Choose a reason for hiding this comment

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

None of this belongs outside of a "setup host environment" container.

Suggested change
echo $(ls -la "$HOME/.esvu/engines")
echo $(ls -la "$HOME/.esvu/engines/xs")
echo $(ls -la "$HOME/.esvu/engines/v8")
chmod +x "$HOME/.esvu/engines/xs/xst"
chmod +x "$HOME/.esvu/engines/v8/d8"
yarn eshost --add "xs" xs "$HOME/.esvu/engines/xs/xst"
yarn eshost --add "v8" d8 "$HOME/.esvu/engines/v8/d8"

Comment on lines +31 to +33
echo $(ls -la "$HOME/.esvu/engines")
echo $(ls -la "$HOME/.esvu/engines/xs")
echo $(ls -la "$HOME/.esvu/engines/v8")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you misunderstood my "echo" suggestion; the point was to indicate which directory is being listed.

Suggested change
echo $(ls -la "$HOME/.esvu/engines")
echo $(ls -la "$HOME/.esvu/engines/xs")
echo $(ls -la "$HOME/.esvu/engines/v8")
for d in "$HOME/.esvu/engines" "$HOME/.esvu/engines/xs" "$HOME/.esvu/engines/v8"; do
echo "# $d"
ls -la "$d"
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants