Replace base::Memset's hand-written loop with std::fill_n?

36 views
Skip to first unread message

Amemiya Riya

unread,
Jun 25, 2026, 1:04:38 AM (3 days ago) Jun 25
to v8-dev
Hi all,

While implementing a packed-Smi fast path for Array.prototype.fill, I
noticed that bulk-filling through MemsetTagged did not improve
performance. It turns out that base::Memset in src/base/memcopy.h is a
hand-written for loop that clang does not vectorize well. Rewriting the
same stores with std::fill_n lowers to an optimized fill and is
considerably faster, and this would benefit every caller of
base::Memset, including MemsetTagged.

Before I prepare a CL, I have two questions. Is there an intentional
reason the loop is hand-written rather than using std::fill_n? And if
not, would you be open to me sending a CL to switch it over?

Thanks in advance for your guidance.

Best regards,
Amemiya

Jakob Kummerow

unread,
Jun 25, 2026, 9:19:14 AM (2 days ago) Jun 25
to v8-...@googlegroups.com
The existence of our own Memset probably predates the availability of std::fill_n by many years.
I assume there's no reason not to modernize it, especially if that improves things.


--
--
v8-dev mailing list
v8-...@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to v8-dev+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/v8-dev/9aab82db-e830-4a42-93f7-168f823f4f3cn%40googlegroups.com.

Amemiya Riya

unread,
Jun 26, 2026, 5:17:54 AM (yesterday) Jun 26
to v8-dev
Hi Jakob,

Thanks for the reply. I've uploaded the change to Gerrit.
https://chromium-review.googlesource.com/c/v8/v8/+/8009549

I wasn't sure who the most appropriate code owner for this area is, so
if you know someone well-suited to review it, I'd appreciate it if you
could add them as a reviewer.

Thanks!

2026年6月25日木曜日 22:19:14 UTC+9 Jakob Kummerow:
Reply all
Reply to author
Forward
0 new messages