Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61778 +/- ##
========================================
Coverage 89.74% 89.74%
========================================
Files 675 675
Lines 204642 204761 +119
Branches 39322 39328 +6
========================================
+ Hits 183657 183767 +110
- Misses 13257 13264 +7
- Partials 7728 7730 +2
🚀 New features to boost your workflow:
|
b45c314 to
010d87f
Compare
010d87f to
eb0a347
Compare
eb0a347 to
57c45d0
Compare
|
Benchmarks are not good... Closing. |
| Local<String> source = args[0].As<String>(); | ||
| source->WriteUtf8V2(isolate, | ||
| static_cast<char*>(bs->Data()), | ||
| bs->MaxByteLength(), |
There was a problem hiding this comment.
| bs->MaxByteLength(), | |
| bs->ByteLength(), |
This is not a resizable array buffer, so no need to use this.
| std::unique_ptr<BackingStore> bs = ArrayBuffer::NewBackingStore( | ||
| isolate, output_length, BackingStoreInitializationMode::kUninitialized); | ||
| CHECK(bs); |
There was a problem hiding this comment.
I think we should also handle the error here.
| std::unique_ptr<BackingStore> bs = ArrayBuffer::NewBackingStore( | |
| isolate, output_length, BackingStoreInitializationMode::kUninitialized); | |
| CHECK(bs); | |
| std::unique_ptr<BackingStore> bs = ArrayBuffer::NewBackingStore( | |
| isolate, output_length, BackingStoreInitializationMode::kUninitialized, | |
| BackingStoreOnFailureMode::kReturnNull); | |
| if (!bs) [[unlikely]] { | |
| THROW_ERR_MEMORY_ALLOCATION_FAILED(isolate); | |
| return MaybeLocal<Uint8Array>(); | |
| } |
| std::unique_ptr<BackingStore> bs = ArrayBuffer::NewBackingStore( | ||
| isolate, utf8_length, BackingStoreInitializationMode::kUninitialized); | ||
| CHECK(bs); |
There was a problem hiding this comment.
| std::unique_ptr<BackingStore> bs = ArrayBuffer::NewBackingStore( | |
| isolate, utf8_length, BackingStoreInitializationMode::kUninitialized); | |
| CHECK(bs); | |
| std::unique_ptr<BackingStore> bs = ArrayBuffer::NewBackingStore( | |
| isolate, utf8_length, BackingStoreInitializationMode::kUninitialized, | |
| BackingStoreOnFailureMode::kReturnNull); | |
| if (!bs) [[unlikely]] { | |
| THROW_ERR_MEMORY_ALLOCATION_FAILED(isolate); | |
| return MaybeLocal<Uint8Array>(); | |
| } |
| } else { | ||
| conversion_buffer.AllocateSufficientStorage(length); | ||
| conversion_buffer.SetLength(length); | ||
| simdutf::to_well_formed_utf16(data, length, conversion_buffer.out()); |
There was a problem hiding this comment.
In this case is there really much to be gained from this juggling compared to just using WriteUtf8V2?
| // Use a cached ObjectTemplate so every result shares the same hidden class | ||
| // (map). This gives V8 fast-properties objects with inline storage, unlike | ||
| // DictionaryTemplate which creates slow dictionary-mode objects. | ||
| Local<Context> context = env->context(); |
There was a problem hiding this comment.
I think this will make it even slower than dictionary objects? Dictionary is only slow in comparison to fast properties whose reads get compiled into a memory offset read. If it's in comparison to jumping through the hoops to invoke a C++ accessor it's still faster.
| text_encoder->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "TextEncoder")); | ||
| Local<v8::Signature> signature = v8::Signature::New(isolate, text_encoder); | ||
|
|
||
| Local<FunctionTemplate> encode = |
There was a problem hiding this comment.
You can just use the SetProtoMethodNoSideEffect helpers for these methods? If you need to set length you can just add a new parameter to that.
In an attempt to improve performance, and reduce the code bloat in internal/util.js... Pending benchmark CI.
Benchmark CI: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/1798/