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

chore: use primordials #216

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

chore: use primordials #216

wants to merge 1 commit into from

Conversation

MoLow
Copy link

@MoLow MoLow commented Jul 4, 2023

this is just a POC to start the process of node exposing fs.glob.
if this PR will land, I will complete the process on all the rest of the code.
also, it seems like node-primordials needs some type fixes / additions

depends on isaacs/node-primordials#8 and isaacs/node-primordials#9

@MoLow
Copy link
Author

MoLow commented Jul 4, 2023

CC @isaacs

src/primordials.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,4 @@
export const primordials: any = // TODO export as typeof import('node-primordials'), types are wrong
// @ts-expect-error
typeof primordials !== 'undefined' ? primordials /* c8 ignore next */ :
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think c8 ignore next is a thing, is that new? I thought it only supported /* c8 ignore start */ and /* c8 ignore stop */

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Owner

Choose a reason for hiding this comment

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

Oh, that's somewhat new-ish, I think. (Like, added in the last 5 years or so probably lol.) Nice!

@isaacs
Copy link
Owner

isaacs commented Jul 5, 2023

Test failures are spurious, should be fixed by rebasing onto main to update tap.

@MoLow MoLow force-pushed the start-primodials branch 3 times, most recently from 184993c to aba228e Compare July 6, 2023 16:14
@MoLow MoLow requested a review from isaacs July 6, 2023 16:14
@MoLow
Copy link
Author

MoLow commented Jul 11, 2023

@isaacs PTAL

src/ast.ts Outdated Show resolved Hide resolved
@MoLow MoLow force-pushed the start-primodials branch from aba228e to 07c7606 Compare July 11, 2023 19:51
'$',
'\\',
'!',
])
Copy link
Owner

Choose a reason for hiding this comment

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

Does SafeSet only take arrays, not arbitrary iterables?

Copy link
Author

Choose a reason for hiding this comment

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

see the implementation here https://github.com/isaacs/node-primordials/pull/9/files# I guess it would work with any iterable, but didn't try

@isaacs
Copy link
Owner

isaacs commented Jul 11, 2023

Looks mostly fine. I'd like to get the PRs on node-primordials landed before landing this, so that it can be a simple dep update. Then the real question will be what the perf impact is, if any. If it's awful, we'll have to figure out some way to either mitigate it, or have the primordials version live side by side somehow with the normal code.

@MoLow
Copy link
Author

MoLow commented Jul 18, 2023

ping @isaacs can you take a look?

@MoLow MoLow force-pushed the start-primodials branch from 07c7606 to 1a40960 Compare July 18, 2023 18:51
@MoLow
Copy link
Author

MoLow commented Aug 3, 2023

@isaacs as we discussed - I'v ran benchmarks on the glob repo: isaacs/node-glob@main...MoLow:node-glob:primordials
the impact seems negligible to me:


--- pattern: '**' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.647s  222999
node glob10 glob syncStream  	0m1.506s  222999
node current globSync mjs    	0m1.649s  222999
node current glob syncStream  	0m1.524s  222999
~~ async ~~
node glob10 glob async mjs   	0m0.574s  222999
node glob10 glob stream      	0m0.527s  222999
node current glob async mjs   	0m0.590s  222999
node current glob stream      	0m0.535s  222999

--- pattern: '**/..' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.292s  2268
node glob10 glob syncStream  	0m1.312s  2268
node current globSync mjs    	0m1.428s  2268
node current glob syncStream  	0m1.324s  2268
~~ async ~~
node glob10 glob async mjs   	0m0.550s  2268
node glob10 glob stream      	0m0.513s  2268
node current glob async mjs   	0m0.549s  2268
node current glob stream      	0m0.542s  2268

--- pattern: './**/0/**/0/**/0/**/0/**/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.311s  10
node glob10 glob syncStream  	0m1.274s  10
node current globSync mjs    	0m1.282s  10
node current glob syncStream  	0m1.395s  10
~~ async ~~
node glob10 glob async mjs   	0m0.538s  10
node glob10 glob stream      	0m0.517s  10
node current glob async mjs   	0m0.529s  10
node current glob stream      	0m0.520s  10

--- pattern: './**/[01]/**/[12]/**/[23]/**/[45]/**/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.293s  160
node glob10 glob syncStream  	0m1.293s  160
node current globSync mjs    	0m1.325s  160
node current glob syncStream  	0m1.296s  160
~~ async ~~
node glob10 glob async mjs   	0m0.516s  160
node glob10 glob stream      	0m0.522s  160
node current glob async mjs   	0m0.528s  160
node current glob stream      	0m0.588s  160

--- pattern: './**/0/**/0/**/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.338s  5230
node glob10 glob syncStream  	0m1.294s  5230
node current globSync mjs    	0m1.381s  5230
node current glob syncStream  	0m1.324s  5230
~~ async ~~
node glob10 glob async mjs   	0m0.513s  5230
node glob10 glob stream      	0m0.521s  5230
node current glob async mjs   	0m0.519s  5230
node current glob stream      	0m0.527s  5230

--- pattern: '**/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.414s  200003
node glob10 glob syncStream  	0m1.406s  200003
node current globSync mjs    	0m1.497s  200003
node current glob syncStream  	0m1.452s  200003
~~ async ~~
node glob10 glob async mjs   	0m0.559s  200003
node glob10 glob stream      	0m0.542s  200003
node current glob async mjs   	0m0.592s  200003
node current glob stream      	0m0.578s  200003

--- pattern: '{**/*.txt,**/?/**/*.txt,**/?/**/?/**/*.txt,**/?/**/?/**/?/**/*.txt,**/?/**/?/**/?/**/?/**/*.txt}' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.532s  200003
node glob10 glob syncStream  	0m1.428s  200003
node current globSync mjs    	0m1.560s  200003
node current glob syncStream  	0m1.462s  200003
~~ async ~~
node glob10 glob async mjs   	0m0.576s  200003
node glob10 glob stream      	0m0.611s  200003
node current glob async mjs   	0m0.620s  200003
node current glob stream      	0m0.595s  200003

--- pattern: '**/5555/0000/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.336s  1000
node glob10 glob syncStream  	0m1.285s  1000
node current globSync mjs    	0m1.293s  1000
node current glob syncStream  	0m1.300s  1000
~~ async ~~
node glob10 glob async mjs   	0m0.517s  1000
node glob10 glob stream      	0m0.566s  1000
node current glob async mjs   	0m0.545s  1000
node current glob stream      	0m0.548s  1000

--- pattern: './**/0/**/../[01]/**/0/../**/0/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.280s  4880
node glob10 glob syncStream  	0m1.302s  4880
node current globSync mjs    	0m1.330s  4880
node current glob syncStream  	0m1.318s  4880
~~ async ~~
node glob10 glob async mjs   	0m0.545s  4880
node glob10 glob stream      	0m0.534s  4880
node current glob async mjs   	0m0.537s  4880
node current glob stream      	0m0.526s  4880

--- pattern: '**/????/????/????/????/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.412s  100000
node glob10 glob syncStream  	0m1.330s  100000
node current globSync mjs    	0m1.375s  100000
node current glob syncStream  	0m1.346s  100000
~~ async ~~
node glob10 glob async mjs   	0m0.551s  100000
node glob10 glob stream      	0m0.541s  100000
node current glob async mjs   	0m0.522s  100000
node current glob stream      	0m0.545s  100000

--- pattern: './{**/?{/**/?{/**/?{/**/?,,,,},,,,},,,,},,,}/**/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.525s  200003
node glob10 glob syncStream  	0m1.470s  200003
node current globSync mjs    	0m1.542s  200003
node current glob syncStream  	0m1.436s  200003
~~ async ~~
node glob10 glob async mjs   	0m0.578s  200003
node glob10 glob stream      	0m0.544s  200003
node current glob async mjs   	0m0.631s  200003
node current glob stream      	0m0.572s  200003

--- pattern: '**/!(0|9).txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.405s  180003
node glob10 glob syncStream  	0m1.396s  180003
node current globSync mjs    	0m1.472s  180003
node current glob syncStream  	0m1.398s  180003
~~ async ~~
node glob10 glob async mjs   	0m0.530s  180003
node glob10 glob stream      	0m0.535s  180003
node current glob async mjs   	0m0.580s  180003
node current glob stream      	0m0.538s  180003

--- pattern: './{*/**/../{*/**/../{*/**/../{*/**/../{*/**,,,,},,,,},,,,},,,,},,,,}/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.560s  200003
node glob10 glob syncStream  	0m1.541s  200003
node current globSync mjs    	0m1.627s  200003
node current glob syncStream  	0m1.553s  200003
~~ async ~~
node glob10 glob async mjs   	0m0.739s  200003
node glob10 glob stream      	0m0.642s  200003
node current glob async mjs   	0m0.751s  200003
node current glob stream      	0m0.686s  200003

--- pattern: './*/**/../*/**/../*/**/../*/**/../*/**/../*/**/../*/**/../*/**/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.532s  200003
node glob10 glob syncStream  	0m1.493s  200003
node current globSync mjs    	0m1.574s  200003
node current glob syncStream  	0m1.483s  200003
~~ async ~~
node glob10 glob async mjs   	0m0.619s  200003
node glob10 glob stream      	0m0.585s  200003
node current glob async mjs   	0m0.679s  200003
node current glob stream      	0m0.565s  200003

--- pattern: './*/**/../*/**/../*/**/../*/**/../*/**/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.477s  200003
node glob10 glob syncStream  	0m1.432s  200003
node current globSync mjs    	0m1.553s  200003
node current glob syncStream  	0m1.440s  200003
~~ async ~~
node glob10 glob async mjs   	0m0.571s  200003
node glob10 glob stream      	0m0.527s  200003
node current glob async mjs   	0m0.637s  200003
node current glob stream      	0m0.535s  200003

--- pattern: './0/**/../1/**/../2/**/../3/**/../4/**/../5/**/../6/**/../7/**/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m0.063s  0
node glob10 glob syncStream  	0m0.062s  0
node current globSync mjs    	0m0.073s  0
node current glob syncStream  	0m0.114s  0
~~ async ~~
node glob10 glob async mjs   	0m0.065s  0
node glob10 glob stream      	0m0.070s  0
node current glob async mjs   	0m0.076s  0
node current glob stream      	0m0.082s  0

--- pattern: './**/?/**/?/**/?/**/?/**/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.388s  100000
node glob10 glob syncStream  	0m1.343s  100000
node current globSync mjs    	0m1.424s  100000
node current glob syncStream  	0m1.379s  100000
~~ async ~~
node glob10 glob async mjs   	0m0.518s  100000
node glob10 glob stream      	0m0.549s  100000
node current glob async mjs   	0m0.537s  100000
node current glob stream      	0m0.525s  100000

--- pattern: '**/*/**/*/**/*/**/*/**' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.501s  222380
node glob10 glob syncStream  	0m1.443s  222380
node current globSync mjs    	0m1.522s  222380
node current glob syncStream  	0m1.447s  222380
~~ async ~~
node glob10 glob async mjs   	0m0.591s  222380
node glob10 glob stream      	0m0.553s  222380
node current glob async mjs   	0m0.644s  222380
node current glob stream      	0m0.561s  222380

--- pattern: './**/*/**/*/**/*/**/*/**/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.478s  200000
node glob10 glob syncStream  	0m1.452s  200000
node current globSync mjs    	0m1.556s  200000
node current glob syncStream  	0m1.430s  200000
~~ async ~~
node glob10 glob async mjs   	0m0.574s  200000
node glob10 glob stream      	0m0.521s  200000
node current glob async mjs   	0m0.590s  200000
node current glob stream      	0m0.529s  200000

--- pattern: '**/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.447s  200003
node glob10 glob syncStream  	0m1.364s  200003
node current globSync mjs    	0m1.478s  200003
node current glob syncStream  	0m1.440s  200003
~~ async ~~
node glob10 glob async mjs   	0m0.543s  200003
node glob10 glob stream      	0m0.532s  200003
node current glob async mjs   	0m0.571s  200003
node current glob stream      	0m0.535s  200003

--- pattern: './**/**/**/**/**/**/**/**/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.420s  200003
node glob10 glob syncStream  	0m1.408s  200003
node current globSync mjs    	0m1.511s  200003
node current glob syncStream  	0m1.390s  200003
~~ async ~~
node glob10 glob async mjs   	0m0.598s  200003
node glob10 glob stream      	0m0.534s  200003
node current glob async mjs   	0m0.579s  200003
node current glob stream      	0m0.527s  200003

--- pattern: '**/*/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.441s  200003
node glob10 glob syncStream  	0m1.378s  200003
node current globSync mjs    	0m1.523s  200003
node current glob syncStream  	0m1.393s  200003
~~ async ~~
node glob10 glob async mjs   	0m0.584s  200003
node glob10 glob stream      	0m0.527s  200003
node current glob async mjs   	0m0.611s  200003
node current glob stream      	0m0.528s  200003

--- pattern: '**/*/**/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.473s  200003
node glob10 glob syncStream  	0m1.392s  200003
node current globSync mjs    	0m1.490s  200003
node current glob syncStream  	0m1.411s  200003
~~ async ~~
node glob10 glob async mjs   	0m0.578s  200003
node glob10 glob stream      	0m0.532s  200003
node current glob async mjs   	0m0.622s  200003
node current glob stream      	0m0.525s  200003

--- pattern: '**/[0-9]/**/*.txt' ---
~~ sync ~~
node glob10 globSync mjs    	0m1.365s  100000
node glob10 glob syncStream  	0m1.353s  100000
node current globSync mjs    	0m1.434s  100000
node current glob syncStream  	0m1.397s  100000
~~ async ~~
node glob10 glob async mjs   	0m0.535s  100000
node glob10 glob stream      	0m0.529s  100000
node current glob async mjs   	0m0.533s  100000
node current glob stream      	0m0.558s  100000

@MoLow MoLow force-pushed the start-primodials branch from 1a40960 to 75695eb Compare August 4, 2023 05:45
@MoLow MoLow requested a review from isaacs August 5, 2023 18:12
Copy link

@Karinza38 Karinza38 left a comment

Choose a reason for hiding this comment

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

MoLow:start-primodials

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.

4 participants